[odrs-web/oscp] Enable moderator accounts by default



commit 17ebae2f03fde31d3e507011b159cd4093b593ce
Author: Richard Hughes <richard hughsie com>
Date:   Fri Jul 19 16:54:37 2019 +0100

    Enable moderator accounts by default
    
    Also, allow moderators to become admins too.

 app_data/odrs/models.py               | 2 +-
 app_data/odrs/templates/modadmin.html | 9 +++------
 app_data/odrs/views_admin.py          | 1 +
 3 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/app_data/odrs/models.py b/app_data/odrs/models.py
index 3d77354..49a8997 100644
--- a/app_data/odrs/models.py
+++ b/app_data/odrs/models.py
@@ -346,7 +346,7 @@ class Moderator(db.Model):
     def __init__(self, username=None, password=None, display_name=None):
         self.username = username
         self.display_name = display_name
-        self.is_enabled = False
+        self.is_enabled = True
         self.is_admin = False
         self.locales = None
         self.locales = password
diff --git a/app_data/odrs/templates/modadmin.html b/app_data/odrs/templates/modadmin.html
index 0151da3..eec9aea 100644
--- a/app_data/odrs/templates/modadmin.html
+++ b/app_data/odrs/templates/modadmin.html
@@ -13,7 +13,7 @@
     </tr>
     <tr>
       <td>User Hash:</td>
-      <td><input type="text" class="form-control" name="user_hash" value="{{u.user_hash}}" required></td>
+      <td><input type="text" class="form-control" name="user_hash" value="{{u.user_hash}}"></td>
     </tr>
     <tr>
       <td>Languages Spoken<br/>(e.g. <code>en,fr,pl</code> or <code>*</code>):</td>
@@ -29,11 +29,8 @@
     <tr>
       <td>Parameters:</td>
       <td>
-{% if u.is_enabled %}
-        <input class="checkbox" type="checkbox" name="is_enabled" value="1" checked>Account enabled</input>
-{% else %}
-        <input class="checkbox" type="checkbox" name="is_enabled" value="1"/>Account enabled</input>
-{% endif %}
+        <input class="checkbox" type="checkbox" name="is_enabled" value="1" {{ 'checked' if u.is_enabled 
}}>Account enabled</input>
+        <input class="checkbox" type="checkbox" name="is_admin" value="1" {{ 'checked' if u.is_admin }}>Is 
admin account</input>
      </td>
     </tr>
 {% endif %}
diff --git a/app_data/odrs/views_admin.py b/app_data/odrs/views_admin.py
index fcc56bf..ad38242 100644
--- a/app_data/odrs/views_admin.py
+++ b/app_data/odrs/views_admin.py
@@ -847,6 +847,7 @@ def admin_user_modify_by_admin(moderator_id):
 
     # set each thing in turn
     mod.is_enabled = 'is_enabled' in request.form
+    mod.is_admin = 'is_admin' in request.form
     for key in ['display_name',
                 'password',
                 'user_hash',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]