From: Michael Tremer Date: Wed, 1 Nov 2017 20:10:53 +0000 (+0000) Subject: users: Drop state X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e304790f6cf165cf7ffdf27d2223fe2a71bb98f2;p=people%2Fjschlag%2Fpbs.git users: Drop state This is kind of pointless and now the system only knows admins and regular users. Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/users.py b/src/buildservice/users.py index 01cf497..b6f3d4a 100644 --- a/src/buildservice/users.py +++ b/src/buildservice/users.py @@ -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 diff --git a/src/database.sql b/src/database.sql index c706ee6..244e939 100644 --- a/src/database.sql +++ b/src/database.sql @@ -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 ); diff --git a/src/templates/modules/modal-build-comment.html b/src/templates/modules/modal-build-comment.html index e8094bd..bd1b72a 100644 --- a/src/templates/modules/modal-build-comment.html +++ b/src/templates/modules/modal-build-comment.html @@ -21,25 +21,23 @@ - {% if current_user.has_perm("vote") %} -
- -
- - - -
+
+ +
+ + +
- {% end %} +
{% else %}

diff --git a/src/templates/user-profile-edit.html b/src/templates/user-profile-edit.html index f3533c2..7e34480 100644 --- a/src/templates/user-profile-edit.html +++ b/src/templates/user-profile-edit.html @@ -77,31 +77,6 @@ - {% if current_user.is_admin() %} -

- {{ _("Admin actions") }} - -
- -
- - - - {{ _("Define the permissions of the user.") }} - -
-
-
- {% end %} -
{{ _("Account security settings") }} diff --git a/src/templates/user-profile.html b/src/templates/user-profile.html index 56139c7..f2819f9 100644 --- a/src/templates/user-profile.html +++ b/src/templates/user-profile.html @@ -48,8 +48,6 @@ {% if user.is_admin() %} {{ _("Admin") }} - {% elif user.is_tester() %} - {{ _("Tester") }} {% else %} {{ _("User") }} {% end %} diff --git a/src/web/packages.py b/src/web/packages.py index 8842931..cc038f7 100644 --- a/src/web/packages.py +++ b/src/web/packages.py @@ -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) diff --git a/src/web/users.py b/src/web/users.py index 76e3012..f796491 100644 --- a/src/web/users.py +++ b/src/web/users.py @@ -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)