Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

sh4nks 11 лет назад
Родитель
Сommit
84eb55c02e
3 измененных файлов с 14 добавлено и 16 удалено
  1. 1 10
      docs/plugins.rst
  2. 9 5
      flaskbb/admin/views.py
  3. 4 1
      flaskbb/plugins/__init__.py

+ 1 - 10
docs/plugins.rst

@@ -10,15 +10,6 @@ This part of the documenation explains how to create and use plugins.
 Plugin Class
 ------------
 
-.. autoclass:: Plugin
-   :members:
-   :inherited-members:
-
-
-Plugin Loader
--------------
-
-.. module:: flaskbb.plugins.loader
-.. autoclass:: PluginLoader
+.. autoclass:: FlaskBBPlugin
    :members:
    :inherited-members:

+ 9 - 5
flaskbb/admin/views.py

@@ -19,6 +19,7 @@ from flask.ext.plugins import get_all_plugins, get_plugin, get_plugin_from_all
 
 from flaskbb import __version__ as flaskbb_version
 from flaskbb.forum.forms import UserSearchForm
+from flaskbb.utils.settings import flaskbb_config
 from flaskbb.utils.helpers import render_template
 from flaskbb.utils.decorators import admin_required
 from flaskbb.extensions import db
@@ -98,12 +99,12 @@ def users():
 
     if search_form.validate():
         users = search_form.get_results().\
-            paginate(page, current_app.config['USERS_PER_PAGE'], False)
+            paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
         return render_template("admin/users.html", users=users,
                                search_form=search_form)
 
     users = User.query. \
-        paginate(page, current_app.config['USERS_PER_PAGE'], False)
+        paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
 
     return render_template("admin/users.html", users=users,
                            search_form=search_form)
@@ -115,7 +116,7 @@ def groups():
     page = request.args.get("page", 1, type=int)
 
     groups = Group.query.\
-        paginate(page, current_app.config['USERS_PER_PAGE'], False)
+        paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
 
     return render_template("admin/groups.html", groups=groups)
 
@@ -133,7 +134,7 @@ def reports():
     page = request.args.get("page", 1, type=int)
     reports = Report.query.\
         order_by(Report.id.asc()).\
-        paginate(page, current_app.config['USERS_PER_PAGE'], False)
+        paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
 
     return render_template("admin/reports.html", reports=reports)
 
@@ -200,6 +201,8 @@ def uninstall_plugin(plugin):
     plugin = get_plugin_from_all(plugin)
     if plugin.uninstallable:
         plugin.uninstall()
+        Setting.invalidate_cache()
+
         flash("Plugin {} has been uninstalled.".format(plugin.name), "success")
     else:
         flash("Cannot uninstall Plugin {}".format(plugin.name), "danger")
@@ -212,6 +215,7 @@ def install_plugin(plugin):
     plugin = get_plugin_from_all(plugin)
     if plugin.installable and not plugin.uninstallable:
         plugin.install()
+        Setting.invalidate_cache()
         flash("Plugin {} has been installed.".format(plugin.name), "success")
     else:
         flash("Cannot install Plugin {}".format(plugin.name), "danger")
@@ -226,7 +230,7 @@ def unread_reports():
     reports = Report.query.\
         filter(Report.zapped == None).\
         order_by(Report.id.desc()).\
-        paginate(page, current_app.config['USERS_PER_PAGE'], False)
+        paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
 
     return render_template("admin/unread_reports.html", reports=reports)
 

+ 4 - 1
flaskbb/plugins/__init__.py

@@ -6,17 +6,20 @@ from flaskbb.management.models import SettingsGroup
 
 class FlaskBBPlugin(Plugin):
 
-    #: Set this to true if the plugin needs to install additional things
+    #: This is the :class:`SettingsGroup` key - if your the plugin needs to install
+    #: additional things you must set it, else it won't install anything.
     settings_key = None
 
     @property
     def installable(self):
+        """Is ``True`` if the Plugin can be installed."""
         if self.settings_key is not None:
             return True
         return False
 
     @property
     def uninstallable(self):
+        """Is ``True`` if the Plugin can be uninstalled."""
         if self.installable:
             group = SettingsGroup.query.filter_by(key=self.settings_key).first()
             if group and len(group.settings.all()) > 0: