In this commit, I'm deleting the ArchivedReports object, at paroneyea's recom-

-mendation. Instead, all of its functionality will be in the ReportBase object.
This commit is contained in:
tilly-Q
2013-09-11 17:09:21 -04:00
parent 6acf4ee60e
commit c906887025
6 changed files with 63 additions and 100 deletions

View File

@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from mediagoblin import mg_globals
from mediagoblin.db.models import User, Privilege, ArchivedReport, UserBan
from mediagoblin.db.models import User, Privilege, UserBan
from mediagoblin.db.base import Session
from mediagoblin.tools.mail import send_email
from mediagoblin.tools.response import redirect
@@ -68,15 +68,6 @@ def take_punitive_actions(request, form, report, user):
u"<br>%s sent a warning email to the offender." % (
request.user.username)
archive = ArchivedReport(
reporter_id=report.reporter_id,
report_content=report.report_content,
reported_user_id=report.reported_user_id,
created=report.created,
resolved=datetime.now(),
resolver_id=request.user.id
)
if u'delete' in form.action_to_resolve.data and \
report.is_comment_report():
deleted_comment = report.comment
@@ -91,20 +82,12 @@ def take_punitive_actions(request, form, report, user):
form.resolution_content.data += \
u"<br>%s deleted the media entry." % (
request.user.username)
# If the moderator didn't delete the content we then attach the
# content to the archived report. We also have to actively delete the
# old report, since it won't be deleted by cascading.
elif report.is_comment_report():
archive.comment_id = report.comment_id
Session.delete(report)
elif report.is_media_entry_report():
archive.media_entry_id = report.media_entry.id
Session.delete(report)
archive.result=form.resolution_content.data
Session.add(archive)
report.archive(
resolver_id=request.user.id,
resolved=datetime.now(),
result=form.resolution_content.data)
Session.add(report)
Session.commit()
if message_body:
send_email(

View File

@@ -18,7 +18,7 @@ from werkzeug.exceptions import Forbidden
from mediagoblin.db.models import (MediaEntry, User, MediaComment, \
CommentReport, ReportBase, Privilege, \
UserBan, ArchivedReport)
UserBan)
from mediagoblin.decorators import (require_admin_or_moderator_login, \
active_user_from_url, user_has_privilege)
from mediagoblin.tools.response import render_to_response, redirect
@@ -72,9 +72,9 @@ def moderation_users_detail(request):
'''
user = User.query.filter_by(username=request.matchdict['user']).first()
active_reports = user.reports_filed_on.filter(
ReportBase.discriminator!='archived_report').limit(5)
ReportBase.resolved==None).limit(5)
closed_reports = user.reports_filed_on.filter(
ReportBase.discriminator=='archived_report').all()
ReportBase.resolved!=None).all()
privileges = Privilege.query
user_banned = UserBan.query.get(user.id)
ban_form = moderation_forms.BanForm()
@@ -108,10 +108,10 @@ def moderation_reports_panel(request):
for key,val in filters.viewitems()]
all_active = ReportBase.query.filter(
ReportBase.discriminator!="archived_report").filter(
ReportBase.resolved==None).filter(
*filters)
all_closed = ReportBase.query.filter(
ReportBase.discriminator=="archived_report").filter(
ReportBase.resolved!=None).filter(
*filters)
# report_list and closed_report_list are the two lists of up to 10