Browse Source

Small adjustments

sh4nks 11 years ago
parent
commit
e295b3fb7c
2 changed files with 10 additions and 10 deletions
  1. 2 4
      flaskbb/admin/models.py
  2. 8 6
      flaskbb/admin/views.py

+ 2 - 4
flaskbb/admin/models.py

@@ -109,16 +109,14 @@ class Setting(db.Model):
         """Returns a Form for all settings found in :class:`SettingsGroup`.
 
         :param group: The settingsgroup name. It is used to get the settings
-                      which are in the specified group. Aborts with 404 if the
-                      group is found.
+                      which are in the specified group.
         """
-        settings = SettingsGroup.query.filter_by(key=group).first_or_404()
 
         class SettingsForm(Form):
             pass
 
         # now parse that shit
-        for setting in settings.settings:
+        for setting in group.settings:
             field_validators = []
 
             # generate the validators

+ 8 - 6
flaskbb/admin/views.py

@@ -52,12 +52,14 @@ def overview():
 @admin.route("/settings/<path:slug>", methods=["GET", "POST"])
 @admin_required
 def settings(slug=None):
-    # Get all settinggroups so that we can build the settings navigation
-    settingsgroup = SettingsGroup.query.all()
-
     slug = slug if slug else "general"
 
-    SettingsForm = Setting.get_form(slug)
+    # get the currently active group
+    active_group = SettingsGroup.query.filter_by(key=slug).first_or_404()
+    # get all groups - used to build the navigation
+    all_groups = SettingsGroup.query.all()
+
+    SettingsForm = Setting.get_form(active_group)
 
     old_settings = Setting.as_dict(from_group=slug)
     new_settings = {}
@@ -72,7 +74,7 @@ def settings(slug=None):
                     continue
                 else:
                     new_settings[key] = form.__dict__[key].data
-            except (KeyError, ValueError):
+            except KeyError:
                 pass
 
         Setting.update(settings=new_settings, app=current_app)
@@ -84,7 +86,7 @@ def settings(slug=None):
                 pass
 
     return render_template("admin/settings.html", form=form,
-                           settingsgroup=settingsgroup)
+                           all_groups=all_groups, active_group=active_group)
 
 
 @admin.route("/users", methods=['GET', 'POST'])