This was a big commit! I included lots of documentation below, but generally I
did a few things. I wrote many many many new tests, either in old test files or in the three new test files I made. I also did some code-keeping work, deleting trailing whitespace and deleting vestigial code. Lastly, I fixed the parts of the code which I realized were broken thru the process of running tests. =============================================================================== Deleted trailing whitespace: =============================================================================== --\ mediagoblin/decorators.py --\ mediagoblin/auth/tools.py --\ mediagoblin/db/migrations.py --\ mediagoblin/db/models.py --\ mediagoblin/gmg_commands/users.py --\ mediagoblin/moderation/forms.py --\ mediagoblin/moderation/tools.py --\ mediagoblin/moderation/views.py --\ mediagoblin/templates/mediagoblin/moderation/media_panel.html --\ mediagoblin/templates/mediagoblin/moderation/report.html --\ mediagoblin/templates/mediagoblin/moderation/report_panel.html --\ mediagoblin/templates/mediagoblin/moderation/user.html --\ mediagoblin/templates/mediagoblin/moderation/user_panel.html --\ mediagoblin/templates/mediagoblin/user_pages/report.html --\ mediagoblin/templates/mediagoblin/utils/report.html --\ mediagoblin/user_pages/lib.py --\ mediagoblin/user_pages/views.py =============================================================================== Deleted Vestigial Code =============================================================================== --\ mediagoblin/db/util.py --\ mediagoblin/tests/test_notifications.py =============================================================================== Modified the Code: =============================================================================== --\ mediagoblin/moderation/tools.py --| Encapsulated the code around giving/taking away privileges into two | funtions. --\ mediagoblin/moderation/views.py --| Imported and used the give/take away privilege functions --| Replaced 'require_admin_or_moderator_login' with |'user_has_privilege(u"admin")' for adding/taking away privileges, only | admins are allowed to do this. --\ mediagoblin/templates/mediagoblin/banned.html --| Added relevant translation tags --| Added ability to display indefinite banning --\ mediagoblin/templates/mediagoblin/user_pages/media.html --| Made sure the add comments button was only visible for users with the | `commenter` privilege --\ mediagoblin/tests/test_submission.py --| Paroneayea fixed a DetachedInstanceError I was having with the our_user | function --\ mediagoblin/tests/tools.py --| Added a fixture_add_comment_report function for testing. --\ mediagoblin/tools/response.py --| Fixed a minor error where a necessary return statement was missing --| Fit the code within 80 columns --\ mediagoblin/user_pages/views.py --| Added a necessary decorator to ensure that only users with the 'commenter' | privilege can post comments =============================================================================== Wrote new tests for an old test file: =============================================================================== --\ mediagoblin/tests/test_auth.py --| Added a new test to make sure privilege granting on registration happens | correctly --\ mediagoblin/tests/test_modelmethods.py* --| Added a test to ensure the User method has_privilege works properly =============================================================================== Wrote entirely new files full of tests: =============================================================================== --\ mediagoblin/tests/test_moderation.py --\ mediagoblin/tests/test_privileges.py --\ mediagoblin/tests/test_reporting.py =============================================================================== =============================================================================== NOTE: Any files I've marked with a * in this commit report, were actually subm- itted in my last commit. I made that committ to fix an error I was having, so they weren't properly documented in that report. =============================================================================== ===============================================================================
This commit is contained in:
@@ -19,7 +19,7 @@ from mediagoblin.tools.template import render_template
|
||||
from mediagoblin.tools.translate import pass_to_ugettext as _
|
||||
from mediagoblin import mg_globals
|
||||
from mediagoblin.db.base import Session
|
||||
from mediagoblin.db.models import (CollectionItem, MediaReport, CommentReport,
|
||||
from mediagoblin.db.models import (CollectionItem, MediaReport, CommentReport,
|
||||
MediaComment, MediaEntry)
|
||||
from mediagoblin.user_pages import forms as user_forms
|
||||
|
||||
@@ -80,14 +80,14 @@ def add_media_to_collection(collection, media, note=None, commit=True):
|
||||
|
||||
def build_report_object(report_form, media_entry=None, comment=None):
|
||||
"""
|
||||
This function is used to convert a form object (from a User filing a
|
||||
This function is used to convert a form object (from a User filing a
|
||||
report) into either a MediaReport or CommentReport object.
|
||||
|
||||
:param report_form should be a MediaReportForm or a CommentReportForm
|
||||
:param report_form should be a MediaReportForm or a CommentReportForm
|
||||
object
|
||||
:param
|
||||
:param
|
||||
|
||||
:returns either of MediaReport or a CommentReport object that has not been
|
||||
:returns either of MediaReport or a CommentReport object that has not been
|
||||
saved. In case of an improper form_dict, returns None
|
||||
"""
|
||||
|
||||
|
||||
@@ -162,6 +162,7 @@ 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):
|
||||
"""
|
||||
recieves POST from a MediaEntry() comment form, saves the comment.
|
||||
@@ -651,13 +652,13 @@ def file_a_report(request, media, comment=None):
|
||||
'form':form}
|
||||
|
||||
if request.method == "POST":
|
||||
report_table = build_report_object(form,
|
||||
media_entry=media,
|
||||
report_object = build_report_object(form,
|
||||
media_entry=media,
|
||||
comment=comment)
|
||||
|
||||
# if the object was built successfully, report_table will not be None
|
||||
if report_table:
|
||||
report_table.save()
|
||||
if report_object:
|
||||
report_object.save()
|
||||
return redirect(
|
||||
request,
|
||||
'index')
|
||||
@@ -671,5 +672,5 @@ def file_a_report(request, media, comment=None):
|
||||
@require_active_login
|
||||
@get_user_media_entry
|
||||
@get_media_comment_by_id
|
||||
def file_a_comment_report(request, media, comment):
|
||||
def file_a_comment_report(request, media, comment):
|
||||
return file_a_report(request, comment=comment)
|
||||
|
||||
Reference in New Issue
Block a user