Browse Source

Move validate_plugin into the plugin utils module

Peter Justin 7 years ago
parent
commit
37b5dfe809
2 changed files with 23 additions and 11 deletions
  1. 23 0
      flaskbb/plugins/utils.py
  2. 0 11
      flaskbb/utils/helpers.py

+ 23 - 0
flaskbb/plugins/utils.py

@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+"""
+    flaskbb.plugins.utils
+    ~~~~~~~~~~~~~~~~~~~~~
+
+    This module provides registration and a basic DB backed key-value
+    store for plugins.
+
+    :copyright: (c) 2017 by the FlaskBB Team.
+    :license: BSD, see LICENSE for more details.
+"""
+from flask import current_app, flash, redirect, url_for
+from flask_babelplus import gettext as _
+
+def validate_plugin(name):
+    """Tries to look up the plugin by name. Upon failure it will flash
+    a message and abort. Returns the plugin module on success.
+    """
+    plugin_module = current_app.pluggy.get_plugin(name)
+    if plugin_module is None:
+        flash(_("Plugin %(plugin)s not found.", plugin=name), "error")
+        return redirect(url_for("management.plugins"))
+    return plugin_module

+ 0 - 11
flaskbb/utils/helpers.py

@@ -664,17 +664,6 @@ def parse_pkg_metadata(dist_name):
     return metadata
 
 
-def validate_plugin(name):  # better name?
-    """Tries to look up the plugin by name. Upon failure it will flash
-    a message and abort. Returns the plugin module on success.
-    """
-    plugin_module = current_app.pluggy.get_plugin(name)
-    if plugin_module is None:
-        flash(_("Plugin %(plugin)s not found.", plugin=name), "error")
-        return redirect(url_for("management.plugins"))
-    return plugin_module
-
-
 def anonymous_required(f):
 
     @wraps(f)