Skip to content

Commit

Permalink
users: activation button improvements (nyaadevs#506)
Browse files Browse the repository at this point in the history
Now uses flask.flash to give the person who clicks it feedback
when it's clicked, because caching may make things confusing.

Also only activate a user if they're inactive, as again, caching
can lead to staff pressing the button multiple times in a row,
leading to unnecessary log messages.
  • Loading branch information
CounterPillow authored and Arylide committed Jul 10, 2018
1 parent 8644472 commit e892f35
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions nyaa/views/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ def view_user(user_name):
db.session.add(adminlog)

if admin_form.activate_user.data and not user.is_banned:
user.status = models.UserStatusType.ACTIVE
adminlog = models.AdminLog("[{}]({}) was manually activated"
.format(user_name, url),
admin_id=flask.g.user.id)
db.session.add(adminlog)
if user.status != models.UserStatusType.ACTIVE:
user.status = models.UserStatusType.ACTIVE
adminlog = models.AdminLog("[{}]({}) was manually activated"
.format(user_name, url), admin_id=flask.g.user.id)
db.session.add(adminlog)
flask.flash('{} was manually activated'.format(user_name), 'success')

db.session.add(user)
db.session.commit()
Expand Down

0 comments on commit e892f35

Please sign in to comment.