]> git.ipfire.org Git - pbs.git/commitdiff
users: Drop state
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2017 20:10:53 +0000 (20:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2017 20:10:53 +0000 (20:10 +0000)
This is kind of pointless and now the system only knows
admins and regular users.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/users.py
src/database.sql
src/templates/modules/modal-build-comment.html
src/templates/user-profile-edit.html
src/templates/user-profile.html
src/web/packages.py
src/web/users.py

index 01cf4972d765f82f0743e10017cdf07054e12b31..b6f3d4aaa6095bebcc0326bf5e52e07d5a7c806b 100644 (file)
@@ -413,16 +413,8 @@ class User(base.DataObject):
        def send_template(self, *args, **kwargs):
                return self.backend.messages.send_template(self, *args, **kwargs)
 
-       def set_state(self, state):
-               self._set_attribute("state", state)
-
-       state = property(lambda s: s.data.state, set_state)
-
        def is_admin(self):
-               return self.state == "admin"
-
-       def is_tester(self):
-               return self.state == "tester"
+               return self.data.admin is True
 
        def get_locale(self):
                return tornado.locale.get(self.data.locale)
@@ -512,10 +504,6 @@ class User(base.DataObject):
                if self.is_admin():
                        return True
 
-               # Exception for voting. All testers are allowed to vote.
-               if perm == "vote" and self.is_tester():
-                       return True
-
                # All others must be checked individually.
                return self.perms.get(perm, False) == True
 
index c706ee6bf673406de7e9e63729eaaaf547c5162a..244e9398d6240007ca12bd74c1668014fdf8de0b 100644 (file)
@@ -1426,7 +1426,6 @@ CREATE TABLE users (
     name text NOT NULL,
     realname text,
     passphrase text,
-    state text DEFAULT 'user'::text NOT NULL,
     locale text,
     timezone text,
     activated boolean DEFAULT false NOT NULL,
@@ -1434,7 +1433,8 @@ CREATE TABLE users (
     registered timestamp without time zone DEFAULT now() NOT NULL,
     ldap_dn text,
     password_recovery_code text,
-    password_recovery_code_expires_at timestamp without time zone
+    password_recovery_code_expires_at timestamp without time zone,
+    admin boolean DEFAULT false NOT NULL
 );
 
 
index e8094bda9ed4580d9e53fee37670e4440db0f75f..bd1b72a8c7b9b32de7c1418c53d0789cbb5e15e0 100644 (file)
                                </div>
                        </div>
 
-                       {% if current_user.has_perm("vote") %}
-                               <div class="control-group">
-                                       <label class="control-label">{{ _("Vote") }}</label>
-                                       <div class="controls">
-                                               <label class="radio">
-                                                       <input type="radio" name="vote" id="vote1" value="option1" checked>
-                                                       {{ _("Not tested.") }}
-                                               </label>
-                                               <label class="radio">
-                                                       <input type="radio" name="vote" id="vote2" value="up">
-                                                       {{ _("Works for me.") }}
-                                               </label>
-                                               <label class="radio">
-                                                       <input type="radio" name="vote" id="vote3" value="down">
-                                                       {{ _("Does not work.") }}
-                                               </label>
-                                       </div>
+                       <div class="control-group">
+                               <label class="control-label">{{ _("Vote") }}</label>
+                               <div class="controls">
+                                       <label class="radio">
+                                               <input type="radio" name="vote" id="vote1" value="option1" checked>
+                                               {{ _("Not tested.") }}
+                                       </label>
+                                       <label class="radio">
+                                               <input type="radio" name="vote" id="vote2" value="up">
+                                               {{ _("Works for me.") }}
+                                       </label>
+                                       <label class="radio">
+                                               <input type="radio" name="vote" id="vote3" value="down">
+                                               {{ _("Does not work.") }}
+                                       </label>
                                </div>
-                       {% end %}
+                       </div>
                </fieldset>
        {% else %}
                <p>
index f3533c2dc1d5c83da494e53b248070bcd4378b15..7e3448075ec5d81ba471f3a80a44a884cc815fc2 100644 (file)
 
                </fieldset>
 
-               {% if current_user.is_admin() %}
-                       <fieldset>
-                               <legend>{{ _("Admin actions") }}</legend>
-
-                               <div class="control-group">
-                                       <label class="control-label" for="inputState">{{ _("State") }}</label>
-                                       <div class="controls">
-                                               <select class="input-xlarge" id="inputState" name="state">
-                                                       <option value="user">{{ _("User") }}</option>
-                                                       <option value="tester" {% if user.is_tester() %}selected="selected"{% end %}>
-                                                               {{ _("Tester") }}
-                                                       </option>
-                                                       <option value="admin" {% if user.is_admin() %}selected="selected"{% end %}>
-                                                               {{ _("Admin") }}
-                                                       </option>
-                                               </select>
-
-                                               <span class="help-block">
-                                                       {{ _("Define the permissions of the user.") }}
-                                               </span>
-                                       </div>
-                               </div>
-                       </fieldset>
-               {% end %}
-
                <fieldset>
                        <legend>{{ _("Account security settings") }}</legend>
 
index 56139c71aefc6962c1ded8c217cea2e7e62a2d41..f2819f96ce87a2b023c88bef2c688521b84c4938 100644 (file)
@@ -48,8 +48,6 @@
                                                <td>
                                                        {% if user.is_admin() %}
                                                                {{ _("Admin") }}
-                                                       {% elif user.is_tester() %}
-                                                               {{ _("Tester") }}
                                                        {% else %}
                                                                {{ _("User") }}
                                                        {% end %}
index 88429310b121b4de3b8b3a39b0aae54e3143f836..cc038f71a8e352bc2ee874778222b542c2deabb5 100644 (file)
@@ -122,13 +122,8 @@ class PackageDetailHandler(base.BaseHandler):
                action = self.get_argument("action", None)
 
                if action == "comment":
-                       vote = self.get_argument("vote", None)
-                       if not self.current_user.is_tester() and \
-                                       not self.current_user.is_admin():
-                               vote = None
-
                        pkg.comment(self.current_user.id, self.get_argument("text"),
-                               vote or "none")
+                               self.get_argument("vote", None) or "none")
 
                self.render("package-detail.html", pkg=pkg)
 
index 76e30127327f53ef1a8669d0802cdf8b6d7c232d..f796491ca5e9ad01f43777a146cd7834cb11164c 100644 (file)
@@ -154,12 +154,6 @@ class UserEditHandler(base.BaseHandler):
                        pass2 = self.get_argument("pass2", None)
                        locale = self.get_argument("locale", "")
 
-                       # Only an admin can alter the state of a user.
-                       if self.current_user.is_admin():
-                               state = self.get_argument("state", user.state)
-                       else:
-                               state = user.state
-
                        # Collect error messages
                        msgs = []
 
@@ -184,7 +178,6 @@ class UserEditHandler(base.BaseHandler):
                        user.realname = realname
                        if pass1:
                                user.passphrase = pass1
-                       user.state = state
 
                        # Get the timezone settings.
                        tz = self.get_argument("timezone", None)