diff --git a/nyaa/models.py b/nyaa/models.py index 602e2fa..cd4ecb0 100644 --- a/nyaa/models.py +++ b/nyaa/models.py @@ -518,6 +518,15 @@ class User(db.Model): elif self.level >= UserLevelType.MODERATOR: return 'Moderator' + @property + def userstatus_str(self): + if self.status == UserStatusType.INACTIVE: + return 'Inactive' + elif self.status == UserStatusType.ACTIVE: + return 'Active' + elif self.status == UserStatusType.BANNED: + return 'Banned' + @property def userlevel_color(self): if self.level == UserLevelType.REGULAR: diff --git a/nyaa/routes.py b/nyaa/routes.py index e19cf18..2dd6b6f 100644 --- a/nyaa/routes.py +++ b/nyaa/routes.py @@ -338,6 +338,9 @@ def view_user(user_name): elif selection == 'moderator': user.level = models.UserLevelType.MODERATOR log = "[{}]({}) changed to moderator user".format(user_name, url) + elif selection == 'disabled': + user.status = models.UserStatusType.BANNED + log = "[{}]({}) changed to banned user".format(user_name, url) adminlog = models.AdminLog(log=log, admin_id=flask.g.user.id) db.session.add(user) @@ -871,19 +874,36 @@ def view_reports(): report_id = report_action.report.data torrent = models.Torrent.by_id(torrent_id) report = models.Report.by_id(report_id) + report_user = models.User.by_id(report.user_id) if not torrent or not report or report.status != 0: flask.abort(404) else: + log = "Report #{}: {} [#{}]({}), reported by [{}]({})" if action == 'delete': torrent.deleted = True report.status = 1 + log = log.format(report_id, 'Deleted', torrent_id, + flask.url_for('view_torrent', torrent_id=torrent_id), + report_user.username, + flask.url_for('view_user', user_name=report_user.username)) elif action == 'hide': + log = log.format(report_id, 'Hid', torrent_id, + flask.url_for('view_torrent', torrent_id=torrent_id), + report_user.username, + flask.url_for('view_user', user_name=report_user.username)) torrent.hidden = True report.status = 1 else: + log = log.format(report_id, 'Closed', torrent_id, + flask.url_for('view_torrent', torrent_id=torrent_id), + report_user.username, + flask.url_for('view_user', user_name=report_user.username)) report.status = 2 + adminlog = models.AdminLog(log=log, admin_id=flask.g.user.id) + db.session.add(adminlog) + models.Report.remove_reviewed(torrent_id) db.session.commit() flask.flash('Closed report #{}'.format(report.id), 'success') @@ -949,6 +969,7 @@ def _create_user_class_choices(user): choices.append(('trusted', 'Trusted')) if flask.g.user.is_superadmin: choices.append(('moderator', 'Moderator')) + choices.append(('disabled', 'Disabled')) if user: if user.is_moderator: diff --git a/nyaa/templates/user.html b/nyaa/templates/user.html index aaf8ed1..2e69a51 100644 --- a/nyaa/templates/user.html +++ b/nyaa/templates/user.html @@ -13,44 +13,46 @@ {% from "_formhelpers.html" import render_menu_with_button %} {% if g.user and g.user.is_moderator %} -

User Information


-
-
- -
-
-
-
User ID:
-
{{ user.id }}
-
Account created on:
-
{{ user.created_time }}
-
Email address:
-
{{ user.email }}
-
User class:
-
{{ level }}
- {%- if g.user.is_superadmin -%} -
Last login IP:
-
{{ user.ip_string }}

- {%- endif -%} -
-
-
- {% if admin_form %} -
- {{ admin_form.csrf_token }} +

User Information


+
+
+ +
+
+
+
User ID:
+
{{ user.id }}
+
Account created on:
+
{{ user.created_time }}
+
Email address:
+
{{ user.email }}
+
User class:
+
{{ level }}
+
User status:
+
{{ user.userstatus_str }} + {%- if g.user.is_superadmin -%} +
Last login IP:
+
{{ user.ip_string }}

+ {%- endif -%} +
+
+
+ {% if admin_form %} + + {{ admin_form.csrf_token }} -
-
- {{ render_menu_with_button(admin_form.user_class) }} -
-
-
-
- {% endif %} +
+
+ {{ render_menu_with_button(admin_form.user_class) }} +
+
+ +
+ {% endif %} {% endif %}

- Browsing {{ user.username }}'{{ '' if user.username[-1] == 's' else 's' }} torrents + Browsing {{ user.username }}'{{ '' if user.username[-1] == 's' else 's' }} torrents

{% include "search_results.html" %}