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)
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
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,
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
);
</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>
</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>
<td>
{% if user.is_admin() %}
{{ _("Admin") }}
- {% elif user.is_tester() %}
- {{ _("Tester") }}
{% else %}
{{ _("User") }}
{% end %}
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)
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 = []
user.realname = realname
if pass1:
user.passphrase = pass1
- user.state = state
# Get the timezone settings.
tz = self.get_argument("timezone", None)