diff options
author | tilly-Q <nattilypigeonfowl@gmail.com> | 2013-09-03 16:19:07 -0400 |
---|---|---|
committer | tilly-Q <nattilypigeonfowl@gmail.com> | 2013-09-03 16:19:07 -0400 |
commit | 8e91df87349b91611a4dfcf3f2640cb540307144 (patch) | |
tree | cc0a46a95a6411cb3c2dfe84a0ca0733ace0938b /mediagoblin/user_pages/views.py | |
parent | dc31cd1b658067d25cda470795020d3c377feae0 (diff) | |
download | mediagoblin-8e91df87349b91611a4dfcf3f2640cb540307144.tar.lz mediagoblin-8e91df87349b91611a4dfcf3f2640cb540307144.tar.xz mediagoblin-8e91df87349b91611a4dfcf3f2640cb540307144.zip |
I did some more code-keeping in this commit. I added a lot of documentation, so
that most of my functions do indeed have effective docstrings. I also changed
the decorators so that they imply eachother in a logical way. I also modified
the one decorator get_media_comment_by_id to be more usable with the variable
urls of mediagoblin.user_pages.views:file_a_report. I also noticed a few tests
had broken, so I went through them and fixed them up, finding that mostly there
were problems in my actual writing of the tests. I also did a few other small
tasks such as creating a new User method to check whether or not a User is ban-
-ned.
===============================================================================
Added in documentation
===============================================================================
--\ mediagoblin/db/models.py
--\ mediagoblin/decorators.py
--\ mediagoblin/moderation/forms.py
--\ mediagoblin/moderation/tools.py
--\ mediagoblin/moderation/views.py
--\ mediagoblin/user_pages/lib.py
===============================================================================
Rearranged decorators to be more efficient
===============================================================================
--\ mediagoblin/decorators.py
--| Made it so that user_not_banned is encapsulated in require_active_login
--| Made it so that require_active_login is encapsulated in user_has_privilege
--| Changed get_media_comment_by_id into get_optional_media_comment_by_id. It
| now returns valid code if the MediaComment id is absent. This makes it pos-
| -sible to use this decorator for the function:
| mediagoblin.user_pages.views:file_a_report
--\ mediagoblin/user_pages/views.py
--| Replaced the mediagoblin.user_pages.views:file_a_comment_report with the
| decorator mentioned above
--\ mediagoblin/user_pages/routing.py
-----------------------------------------------------------
| took out unnecessary @user_not_banned decorators |
-----------------------------------------------------------
--\ mediagoblin/submit/views.py
--\ mediagoblin/user_pages/views.py
===============================================================================
Fixed broken tests
===============================================================================
--\ mediagoblin/tests/test_auth.py
--\ mediagoblin/tests/test_privileges.py
--\ mediagoblin/tests/test_submission.py
===============================================================================
Fixed broken code
===============================================================================
--\ mediagoblin/tools/response.py
===============================================================================
Other Tasks
===============================================================================
--\ mediagoblin/db/models.py
--| Added in User.is_banned() method
--\ mediagoblin/decorators.py
--| Utitilized User.is_banned() method in the user_not_banned decorator
--\ mediagoblin/moderation/views.py
--| Made it impossible for an admin to ban themself.
--| Got rid of a vestigial print statement
--\ mediagoblin/templates/mediagoblin/base.html
--| Made it so the top panel does not show up for users that are banned.
--\ mediagoblin/templates/mediagoblin/moderation/user.html
--| Rearranged the javascript slightly
===============================================================================
Diffstat (limited to 'mediagoblin/user_pages/views.py')
-rw-r--r-- | mediagoblin/user_pages/views.py | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index 83aecf31..931b740c 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -34,10 +34,10 @@ from mediagoblin.notifications import trigger_notification, \ add_comment_subscription, mark_comment_notification_seen from mediagoblin.decorators import (uses_pagination, get_user_media_entry, - get_media_entry_by_id, user_has_privilege, + get_media_entry_by_id, user_has_privilege, user_not_banned, require_active_login, user_may_delete_media, user_may_alter_collection, get_user_collection, get_user_collection_item, active_user_from_url, - get_media_comment_by_id, user_not_banned) + get_optional_media_comment_by_id) from werkzeug.contrib.atom import AtomFeed from werkzeug.exceptions import MethodNotAllowed @@ -161,7 +161,6 @@ def media_home(request, media, page, **kwargs): @get_media_entry_by_id -@require_active_login @user_has_privilege(u'commenter') def media_post_comment(request, media): """ @@ -291,7 +290,6 @@ def media_collect(request, media): #TODO: Why does @user_may_delete_media not implicate @require_active_login? -@user_not_banned @get_media_entry_by_id @require_active_login @user_may_delete_media @@ -380,7 +378,6 @@ def collection_list(request, url_user=None): @get_user_collection_item @require_active_login @user_may_alter_collection -@user_not_banned def collection_item_confirm_remove(request, collection_item): form = user_forms.ConfirmCollectionItemRemoveForm(request.form) @@ -420,7 +417,7 @@ def collection_item_confirm_remove(request, collection_item): {'collection_item': collection_item, 'form': form}) -@user_not_banned + @get_user_collection @require_active_login @user_may_alter_collection @@ -604,7 +601,6 @@ def collection_atom_feed(request): return feed.get_response() -@user_not_banned @require_active_login def processing_panel(request): """ @@ -649,21 +645,27 @@ def processing_panel(request): 'failed_entries': failed_entries, 'processed_entries': processed_entries}) -@require_active_login @get_user_media_entry @user_has_privilege(u'reporter') -def file_a_report(request, media, comment=None): +@get_optional_media_comment_by_id +def file_a_report(request, media, comment): + """ + This view handles the filing of a MediaReport or a CommentReport. + """ if comment is not None: + if not comment.get_media_entry.id == media.id: + return render_404(request) + form = user_forms.CommentReportForm(request.form) - form.reporter_id.data = request.user.id context = {'media': media, 'comment':comment, 'form':form} else: form = user_forms.MediaReportForm(request.form) - form.reporter_id.data = request.user.id context = {'media': media, 'form':form} + form.reporter_id.data = request.user.id + if request.method == "POST": report_object = build_report_object(form, @@ -683,8 +685,3 @@ def file_a_report(request, media, comment=None): 'mediagoblin/user_pages/report.html', context) -@require_active_login -@get_user_media_entry -@get_media_comment_by_id -def file_a_comment_report(request, media, comment): - return file_a_report(request, comment=comment) |