This has been an update to clean out the code a little bit. The primary change

I made was I added the method has_privilege (which takes a variable amount of
unicode privilege names as an argument) to the User model. This method allowed
for much cleaner checks as to whether or not a user has a privilege. Other-
wise, I also made it impossible for moderators to punish admins. I created a
new url path and three new pages for Users to look at filed reports and the
code of conduct for the mg instance.

=== Made reports on admins not resolvable by moderators:
--\   mediagoblin/moderation/views.py
--\   mediagoblin/templates/mediagoblin/moderation/report.html

=== Created new files for the new pages:
--\   mediagoblin/meta/__init__.py
--\   mediagoblin/meta/routing.py
--\   mediagoblin/meta/views.py
--\   mediagoblin/templates/mediagoblin/meta/code_of_conduct.html
--\   mediagoblin/templates/mediagoblin/meta/reports_details.html
--\   mediagoblin/templates/mediagoblin/meta/reports_panel.html
--\   mediagoblin/routing.py
--\   mediagoblin/static/css/base.css

=== Replaced vestigial methods of checking a user's privilege with the more
====== effective method has_privilege(u'privilege_name'):
--\   mediagoblin/db/models.py
--|   Added in the has_privilege method to the User class

--\   mediagoblin/db/migrations.py
--\   mediagoblin/db/models.py
--\   mediagoblin/decorators.py
--\   mediagoblin/edit/lib.py
--\   mediagoblin/edit/views.py
--\   mediagoblin/gmg_commands/users.py
--\   mediagoblin/moderation/views.py
--\   mediagoblin/templates/mediagoblin/base.html
--\   mediagoblin/templates/mediagoblin/user_pages/collection.html
--\   mediagoblin/templates/mediagoblin/user_pages/media.html
--\   mediagoblin/templates/mediagoblin/user_pages/user.html
--\   mediagoblin/templates/mediagoblin/utils/collection_gallery.html
--\   mediagoblin/user_pages/views.py

=== Minor UI changes
--\   mediagoblin/templates/mediagoblin/moderation/report_panel.html
--\   mediagoblin/templates/mediagoblin/moderation/user.html

=== Other Bugs:
--\   mediagoblin/tools/response.py
--\   mediagoblin/db/migrations.py
This commit is contained in:
tilly-Q
2013-08-13 18:38:00 -04:00
parent 9d6e453f8f
commit 8394febbe1
25 changed files with 219 additions and 63 deletions

View File

@@ -74,15 +74,12 @@ def moderation_users_detail(request):
ReportBase.discriminator=='archived_report').all()
privileges = Privilege.query
user_banned = UserBan.query.get(user.id)
user_privileges = user_privileges_to_dictionary(user.id)
requesting_user_privileges = user_privileges_to_dictionary(request.user.id)
return render_to_response(
request,
'mediagoblin/moderation/user.html',
{'user':user,
'privileges': privileges,
'requesting_user_privileges':requesting_user_privileges,
'reports':active_reports,
'user_banned':user_banned})
@@ -121,7 +118,10 @@ def moderation_reports_detail(request):
for s in report.reported_user.all_privileges
]
if request.method == "POST" and form.validate():
if request.method == "POST" and form.validate() and not (
not request.user.has_privilege(u'admin') and
report.reported_user.has_privilege(u'admin')):
user = User.query.get(form.targeted_user.data)
return take_punitive_actions(request, form, report, user)