__mapper_args__ = {'polymorphic_identity': 'media_report'}
id = Column('id',Integer, ForeignKey('core__reports.id'), primary_key=True)
- media_entry_id = Column(Integer, ForeignKey(MediaEntry.i
+ media_entry_id = Column(Integer, ForeignKey(MediaEntry.id), nullable=False)
class ArchivedReport_v0(ReportBase_v0):
__tablename__ = 'core__reports_archived'
privilege_dictionary = {}
user = User.query.get(user_id)
users_privileges = [p_item.privilege_name for p_item in user.all_privileges]
- for privilege_name in FOUNDATIONS[Privilege]:
- privilege_name = privilege_name[0]
+ #TODO update this to account for plugins that may add foundations
+ for privilege in FOUNDATIONS[Privilege]:
+ privilege_name = privilege['privilege_name']
if privilege_name in users_privileges:
privilege_dictionary[privilege_name]=True
else:
from mediagoblin import mg_globals as mgg
from mediagoblin import messages
-from mediagoblin.db.models import MediaEntry, User, MediaComment,
- UserBan
-from mediagoblin.tools.response import redirect, render_404
+from mediagoblin.db.models import (MediaEntry, User, MediaComment,
+ UserBan, Privilege)
+from mediagoblin.tools.response import redirect, render_404, render_user_banned
from mediagoblin.tools.translate import pass_to_ugettext as _
"""
@wraps(controller)
def new_controller_func(request, *args, **kwargs):
- admin_privilege = Privilege.one({'privilege_name':u'admin'})
- moderator_privilege = Privilege.one({'privilege_name':u'moderator'})
+ admin_privilege = Privilege.query.filter(
+ Privilege.privilege_name==u'admin').one()
+ moderator_privilege = Privilege.query.filter(
+ Privilege.privilege_name==u'moderator').one()
if request.user and \
not admin_privilege in request.user.all_privileges and \
not moderator_privilege in request.user.all_privileges:
entry.status = u'active'
entry.email_verified = True
default_privileges = [
- db.Privilege.one({'privilege_name':u'commenter'}),
- db.Privilege.one({'privilege_name':u'uploader'}),
- db.Privilege.one({'privilege_name':u'reporter'}),
- db.Privilege.one({'privilege_name':u'active'})
-]
+ db.Privilege.query.filter(
+ db.Privilege.privilege_name==u'commenter').one(),
+ db.Privilege.query.filter(
+ db.Privilege.privilege_name==u'uploader').one(),
+ db.Privilege.query.filter(
+ db.Privilege.privilege_name==u'reporter').one(),
+ db.Privilege.query.filter(
+ db.Privilege.privilege_name==u'active').one()
+ ]
entry.all_privileges = default_privileges
entry.save()
if user:
user.is_admin = True
user.all_privileges.append(
- db.Privilege.one({
- 'privilege_name':u'admin'})
- )
+ db.Privilege.query.filter(
+ db.Privilege.privilege_name==u'admin').one()
+ )
user.save()
print 'The user is now Admin'
else:
# punitive actions that a moderator could take.
if u'takeaway' in form.action_to_resolve.data:
for privilege_name in form.take_away_privileges.data:
- privilege = Privilege.one({u'privilege_name':privilege_name})
+ privilege = Privilege.query.filter(
+ Privilege.privilege_name==privilege_name).one()
form.resolution_content.data += \
u"<br>%s took away %s\'s %s privileges" % (
request.user.username,
form = moderation_forms.ReportResolutionForm(request.form)
report = ReportBase.query.get(request.matchdict['report_id'])
- form.take_away_privileges.choices = [(s.privilege_name,s.privilege_name.title()) for s in report.reported_user.all_privileges]
+ form.take_away_privileges.choices = [
+ (s.privilege_name,s.privilege_name.title()) \
+ for s in report.reported_user.all_privileges
+ ]
if request.method == "POST" and form.validate():
user = User.query.get(form.targeted_user.data)
'''
form = moderation_forms.PrivilegeAddRemoveForm(request.form)
if request.method == "POST" and form.validate():
- privilege = Privilege.one({'privilege_name':form.privilege_name.data})
+ privilege = Privilege.query.filter(
+ Privilege.privilege_name==form.privilege_name.data).one()
if privilege in url_user.all_privileges:
url_user.all_privileges.remove(privilege)
else:
<a href="{{ request.urlgen('mediagoblin.moderation.users') }}">
{%- trans %}User management panel{% endtrans -%}
</a>
+ <a href="{{ request.urlgen('mediagoblin.moderation.reports') }}">
+ {%- trans %}Report management panel{% endtrans -%}
+ </a>
</p>
{% endif %}
{% include 'mediagoblin/fragments/header_notifications.html' %}
from mediagoblin.tools.pagination import Pagination
from mediagoblin.user_pages import forms as user_forms
from mediagoblin.user_pages.lib import (send_comment_email,
- add_media_to_collection)
+ add_media_to_collection, build_report_object)
from mediagoblin.notifications import trigger_notification, \
add_comment_subscription, mark_comment_notification_seen