This update I mostly did work on the templates for the admin pages. I did a co-
authortilly-Q <nattilypigeonfowl@gmail.com>
Mon, 8 Jul 2013 18:20:28 +0000 (14:20 -0400)
committertilly-Q <nattilypigeonfowl@gmail.com>
Mon, 8 Jul 2013 18:20:28 +0000 (14:20 -0400)
-uple other small changes. I changed the information around the media processi-
ng panel to be more specific, since it was written when it was the only admin
page. Git didn't catch this, but I renamed the templates, so mediagoblin/templ-
ates/admin/user.html now referrs to the page which shows the details of a spec-
ific user. The list view pages are now named ELEMENT_panel.html(ie. user_panel)
I also added a column reported_user_id to the ReportBase table, and had to add
to Report filing to make sure that column gets created. Also I moved the report
media button (on a media page) to the sidebar, though it still needs some form-
atting

--\ mediagoblin/static/images/icon_clipboard.png
--| Added this image for use in template mediagoblin/admin/report.html.
--| Distributed by the GNOME project http://www.gnome.org
--| Under a GNU LGPL v.3 or Creative Commons BY-SA 3.0 license.
--| I'm still trying to figure out the appropriate way to attribute this in
  | the code

--\ mediagoblin/templates/mediagoblin/admin/media_panel.html
--| This template is actually the template formerly know as media.html. I
  | renamed it for clarity

--\ mediagoblin/templates/mediagoblin/admin/report_panel.html
--| This template is actually the template formerly know as report.html. I
  | renamed it for clarity

--\ mediagoblin/templates/mediagoblin/admin/user_panel.html
--| This template is actually the template formerly know as user.html. I renam-
  | -ed it for clarity

--\ mediagoblin/templates/mediagoblin/utils/report.html
--| This template is included in the media_home page. It is the report media
  | button. I figured I'd write it like this in case it got more complicated.

--\ mediagoblin/admin/routing.py
--| I changed the routing path /a/panel to /a/media for specificity

--\ mediagoblin/admin/views.py
--| I renamed admin_processing_panel to admin_media_processing_panel
--| I wrote a new view function admin_reports_detail
--| I wrote a new view function admin_users_detail

--\ mediagoblin/db/migrations.py
--| I added in the column reported_user_id to the ReportBase_v0 class

--\ mediagoblin/db/models.py
--| I added in the column reported_user_id to the ReportBase class

--\ mediagoblin/static/css/base.css
--| I added in css classes to display a report. Right now, they are just echo-
  | -ing the ways comments are displayed, but with the link in another color

--\ mediagoblin/templates/mediagoblin/admin/report.html
--| Created this new template (although git doesn't realize it) to show the de-
  | -tails of a specific report, indicated in the URL

--\ mediagoblin/templates/mediagoblin/admin/user.html
--| Created this new template (although git doesn't realize it) to show the de-
  | -tails of a specific user, indicated in the URL

--\ mediagoblin/templates/mediagoblin/base.html
--| Redirected the link from /a/panel to /a/media

--\ mediagoblin/templates/mediagoblin/user_pages/media.html
--| Moved the media report button to the sidebar

--\ mediagoblin/user_pages/lib.py
--| Changed the creation of reports, so that they also assign a column for rep-
  | -orted_user_id.

17 files changed:
mediagoblin/admin/routing.py
mediagoblin/admin/views.py
mediagoblin/db/migrations.py
mediagoblin/db/mixin.py
mediagoblin/db/models.py
mediagoblin/decorators.py
mediagoblin/static/css/base.css
mediagoblin/static/images/icon_clipboard.png [new file with mode: 0644]
mediagoblin/templates/mediagoblin/admin/media_panel.html [moved from mediagoblin/templates/mediagoblin/admin/panel.html with 100% similarity]
mediagoblin/templates/mediagoblin/admin/report.html
mediagoblin/templates/mediagoblin/admin/report_panel.html [new file with mode: 0644]
mediagoblin/templates/mediagoblin/admin/user.html
mediagoblin/templates/mediagoblin/admin/user_panel.html [new file with mode: 0644]
mediagoblin/templates/mediagoblin/base.html
mediagoblin/templates/mediagoblin/user_pages/media.html
mediagoblin/templates/mediagoblin/utils/report.html [new file with mode: 0644]
mediagoblin/user_pages/lib.py

index d5edac0ff17c0935320fbc19623fe916579763a9..c7ca5b92f098b292ec547498b0cd7bbc9b404e6f 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 admin_routes = [
-    ('mediagoblin.admin.panel',
-        '/panel',
-        'mediagoblin.admin.views:admin_processing_panel'),
+    ('mediagoblin.admin.media_panel',
+        '/media',
+        'mediagoblin.admin.views:admin_media_processing_panel'),
     ('mediagoblin.admin.users',
         '/users',
         'mediagoblin.admin.views:admin_users_panel'),
     ('mediagoblin.admin.reports',
         '/reports',
-        'mediagoblin.admin.views:admin_reports_panel')]
+        'mediagoblin.admin.views:admin_reports_panel'),
+    ('mediagoblin.admin.users_detail',
+        '/users/<string:user>',
+        'mediagoblin.admin.views:admin_users_detail'),
+    ('mediagoblin.admin.reports_detail',
+        '/reports/<int:report_id>',
+        'mediagoblin.admin.views:admin_reports_detail')]
index 7a4dfbd43964ba81f8225e4715a8cee878896486..9797057757b7d5baa10b16d2ab93fe6364c11d36 100644 (file)
 
 from werkzeug.exceptions import Forbidden
 
-from mediagoblin.db.models import MediaEntry, User, MediaComment, CommentReport, ReportBase
+from mediagoblin.db.models import (MediaEntry, User, MediaComment, \
+                                   CommentReport, ReportBase, Privilege)
 from mediagoblin.decorators import require_admin_login
 from mediagoblin.tools.response import render_to_response
 
 @require_admin_login
-def admin_processing_panel(request):
+def admin_media_processing_panel(request):
     '''
     Show the global media processing panel for this instance
     '''
@@ -38,7 +39,7 @@ def admin_processing_panel(request):
     # Render to response
     return render_to_response(
         request,
-        'mediagoblin/admin/panel.html',
+        'mediagoblin/admin/media_panel.html',
         {'processing_entries': processing_entries,
          'failed_entries': failed_entries,
          'processed_entries': processed_entries})
@@ -50,12 +51,30 @@ def admin_users_panel(request):
     '''
     user_list = User.query
 
-    # Render to response
     return render_to_response(
         request,
-        'mediagoblin/admin/user.html',
+        'mediagoblin/admin/user_panel.html',
         {'user_list': user_list})
 
+@require_admin_login
+def admin_users_detail(request):
+    '''
+    Shows details about a particular user.
+    '''
+    user = User.query.filter_by(username=request.matchdict['user']).first()
+    privileges = Privilege.query
+    active_reports = user.reports_filed_on.filter(
+        ReportBase.resolved==None).limit(5)
+    closed_reports = user.reports_filed_on.filter(
+        ReportBase.resolved!=None).all()
+
+    return render_to_response(
+        request,
+        'mediagoblin/admin/user.html',
+        {'user':user,
+         'privileges':privileges,
+         'reports':active_reports})
+
 @require_admin_login
 def admin_reports_panel(request):
     '''
@@ -72,7 +91,25 @@ def admin_reports_panel(request):
     # Render to response
     return render_to_response(
         request,
-        'mediagoblin/admin/report.html',
+        'mediagoblin/admin/report_panel.html',
         {'report_list':report_list,
          'closed_report_list':closed_report_list})
 
+@require_admin_login
+def admin_reports_detail(request):
+    report = ReportBase.query.get(request.matchdict['report_id'])
+    if report.discriminator == 'comment_report':
+        comment = MediaComment.query.get(report.comment_id)
+        media_entry = None
+    elif report.discriminator == 'media_report':
+        media_entry = MediaEntry.query.get(report.media_entry_id)
+        comment = None
+
+    return render_to_response(
+        request,
+        'mediagoblin/admin/report.html',
+        {'report':report,
+         'media_entry':media_entry,
+         'comment':comment})
+    
+
index 053f3db250316476bb180374f43fe7fdaec96d9e..a32f5932fdf0ef7ac11ab53b0c13806f3c474eb1 100644 (file)
@@ -26,7 +26,8 @@ from sqlalchemy.sql import and_
 from migrate.changeset.constraint import UniqueConstraint
 
 from mediagoblin.db.migration_tools import RegisterMigration, inspect_table
-from mediagoblin.db.models import MediaEntry, Collection, User, MediaComment, Privilege
+from mediagoblin.db.models import (MediaEntry, Collection, User, 
+                                   MediaComment, Privilege, ReportBase)
 
 MIGRATIONS = {}
 
@@ -296,6 +297,7 @@ class ReportBase_v0(declarative_base()):
     id = Column(Integer, primary_key=True)
     reporter_id = Column(Integer, ForeignKey(User.id), nullable=False)
     report_content = Column(UnicodeText)
+    reported_user_id = Column(Integer, ForeignKey(User.id), nullable=False)
     created = Column(DateTime, nullable=False, default=datetime.datetime.now) 
     resolved = Column(DateTime)
     discriminator = Column('type', Unicode(50))
@@ -357,5 +359,3 @@ def create_moderation_tables(db):
     Privilege_v0.__table__.create(db.bind)
     PrivilegeUserAssociation_v0.__table__.create(db.bind)
     db.commit()
-
-
index 9f566e36d5a7ce9d6ad15ed90d50565886ab5c40..70c9dd4102116a417784d182d290ff3a457d44e7 100644 (file)
@@ -45,7 +45,6 @@ class UserMixin(object):
     def bio_html(self):
         return cleaned_markdown_conversion(self.bio)
 
-
 class GenerateSlugMixin(object):
     """
     Mixin to add a generate_slug method to objects.
index e0419c92502626cd37c957ec00a47341e2af2fac..e4c97a2cf4722ec957b5d4192110e537c6214599 100644 (file)
@@ -496,8 +496,16 @@ class ReportBase(Base):
         User, 
         backref=backref("reports_filed_by",
             lazy="dynamic",
-            cascade="all, delete-orphan"))
+            cascade="all, delete-orphan"),
+        primaryjoin="User.id==ReportBase.reporter_id")
     report_content = Column(UnicodeText)
+    reported_user_id = Column(Integer, ForeignKey(User.id), nullable=False)
+    reported_user = relationship(
+        User, 
+        backref=backref("reports_filed_on",
+            lazy="dynamic",
+            cascade="all, delete-orphan"),
+        primaryjoin="User.id==ReportBase.reported_user_id")
     created = Column(DateTime, nullable=False, default=datetime.datetime.now())
     resolved = Column(DateTime)
     discriminator = Column('type', Unicode(50))
@@ -590,7 +598,7 @@ class PrivilegeUserAssociation(Base):
         primary_key=True)
 
 
-privilege_foundations = [[u'admin'], [u'moderator'], [u'commenter'], [u'uploader'],[u'reporter'],[u'active']]
+privilege_foundations = [[u'admin'], [u'moderator'], [u'uploader'],[u'reporter'], [u'commenter'] ,[u'active']]
 
 MODELS = [
     User, MediaEntry, Tag, MediaTag, MediaComment, Collection, CollectionItem, 
index 206957fa1eb5c060bd3ab4aa54573877810a1f98..fefbccef1ff097d15214ff260f58f48beab1a159 100644 (file)
@@ -64,7 +64,6 @@ def active_user_from_url(controller):
     return wrapper
 
 def user_has_privilege(privilege_name):
-#TODO handle possible errors correctly
     def user_has_privilege_decorator(controller):
         @wraps(controller)
         def wrapper(request, *args, **kwargs):
index 5b8226e6d86d2f12aaa1cac71880f16c1aed6e36..1cded530a6d632f03f8ac51c40c5367d2bd10aa8 100644 (file)
@@ -346,40 +346,40 @@ textarea#description, textarea#bio {
 
 /* comments */
 
-.comment_wrapper {
+.comment_wrapper, .report_wrapper {
   margin-top: 20px;
   margin-bottom: 20px;
 }
 
-.comment_wrapper p {
+.comment_wrapper p, .report_wrapper p {
   margin-bottom: 2px;
 }
 
-.comment_author {
+.comment_author, .report_author {
   padding-top: 4px;
   font-size: 0.9em;
 }
 
-a.comment_authorlink {
+a.comment_authorlink, a.report_authorlink {
   text-decoration: none;
   padding-right: 5px;
   font-weight: bold;
   padding-left: 2px;
 }
 
-a.comment_authorlink:hover {
+a.comment_authorlink:hover, a.report_authorlink:hover {
   text-decoration: underline;
 }
 
-a.comment_whenlink {
+a.comment_whenlink, a.report_whenlink {
   text-decoration: none;
 }
 
-a.comment_whenlink:hover {
+a.comment_whenlink:hover, a.report_whenlink:hover {
   text-decoration: underline;
 }
 
-.comment_content {
+.comment_content, .report_content {
   margin-left: 8px;
   margin-top: 8px;
 }
@@ -397,6 +397,11 @@ textarea#comment_content {
        padding-right: 6px;
 }
 
+
+a.report_authorlink, a.report_whenlink {
+  color: #D486B1;
+}
+
 /* media galleries */
 
 .media_thumbnail {
@@ -597,6 +602,21 @@ table.media_panel th {
   text-align: left;
 }
 
+/* admin panels */
+
+table.admin_panel {
+  width: 100%
+}
+
+table.admin_side_panel {
+  width: 60%
+}
+
+table.admin_panel th, table.admin_side_panel th {
+  font-weight: bold;
+  padding-bottom: 4px;
+  text-align: left;
+}
 
 /* Delete panel */
 
diff --git a/mediagoblin/static/images/icon_clipboard.png b/mediagoblin/static/images/icon_clipboard.png
new file mode 100644 (file)
index 0000000..6f94498
Binary files /dev/null and b/mediagoblin/static/images/icon_clipboard.png differ
index ff5cb427cd68ba7f4290cf68aa0902ec9f8d5576..2e8021984f0115236c223667fd0f8a20f6c3190d 100644 (file)
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #}
-{% extends "mediagoblin/base.html" %}
+{%- extends "mediagoblin/base.html" %}
 
-{% block title -%}
-  {% trans %}Report panel{% endtrans %} &mdash; {{ super() }}
-{%- endblock %}
-
-{% block mediagoblin_content %}
-
-<h1>{% trans %}Report panel{% endtrans %}</h1>
-
-<p>
-  {% trans %}Here you can look up users in order to take punitive actions on them.{% endtrans %}
-</p>
-    
-<h2>{% trans %}Reports Filed on Comments{% endtrans %}</h2>
-
-{% if report_list.count() %}
-  <table class="media_panel processing">
-    <tr>
-      <th>ID</th>
-      <th>Report Type</th>
-      <th>Offender</th>
-      <th>When Reported</th>
-      <th>Reported By</th>
-      <th>Reason</th>
-      <th>Reported Comment or Media Entry</th>
-    </tr>
-    {% for report in report_list %}
-      <tr>
-        {% if report.discriminator == "comment_report" %}
-            <td>{{ report.id }}</td>
-            <td>Comment Report</td>
-            <td>{{ report.comment.get_author.username }}</td>
-            <td>{{ report.created.strftime("%F %R") }}</td>
-            <td>{{ report.reporter.username }}</td>
-            <td>{{ report.report_content }}</td>
-            <td><a href="{{ report.comment.get_media_entry.url_for_self(request.urlgen) }}">{{ report.comment.get_media_entry.title }}</a></td>
-        {% elif report.discriminator == "media_report" %}
-            <td>{{ report.id }}</td>
-            <td>Media Report</td>
-            <td>{{ report.media_entry.get_uploader.username }}</td>
-            <td>{{ report.created.strftime("%F %R") }}</td>
-            <td>{{ report.reporter.username }}</td>
-            <td>{{ report.report_content[0:20] }}...</td>
-            <td><a href="{{ report.media_entry.url_for_self(request.urlgen) }}">{{ report.media_entry.title }}</a></td>
-        {% endif %}
-      </tr>
-    {% endfor %}
-  </table>
+{%- block mediagoblin_content %}
+{% if not report %}
+  Sorry, no such report found.
 {% else %}
-  <p><em>{% trans %}No open reports found.{% endtrans %}</em></p>
+  <h2> Report #{{ report.id }}</h2>
+  {% if comment %}
+    Reported comment:
+    {% set reported_user = comment.get_author %}
+    <div id="comment-{{ comment.id }}"
+        class="comment_wrapper">
+      <div class="comment_author">
+        <img src="{{ request.staticdirect('/images/icon_comment.png') }}" />
+            <a href="{{ request.urlgen('mediagoblin.admin.users_detail',
+                            user=comment.get_author.username) }}"
+               class="comment_authorlink">
+          {{- reported_user.username -}}
+        </a>
+        <a href="{{ request.urlgen('mediagoblin.user_pages.media_home.view_comment',
+                        comment=comment.id,
+                        user=comment.get_media_entry.get_uploader.username,
+                        media=comment.get_media_entry.slug_or_id) }}#comment"
+           class="comment_whenlink">
+          <span title='{{- comment.created.strftime("%I:%M%p %Y-%m-%d") -}}'>
+            {%- trans formatted_time=timesince(comment.created) -%}
+              {{ formatted_time }} ago
+            {%- endtrans -%}
+          </span></a>:
+      </div>
+      <div class=comment_content>
+        {% autoescape False %}
+          {{ comment.content_html }}
+        {% endautoescape %}
+      </div>
+    </div>
+  {% elif media_entry %}
+    <div class="media_thumbnail">
+      <a href="request.urlgen('mediagoblin.user_pages.media_home'),
+                                                              user=media_entry.get_uploader.username,
+                                                              media=media_entry.slug_or_id)"><img src="{{ media_entry.thumb_url}}"/></a>
+      <a href="request.urlgen('mediagoblin.user_pages.media_home'),
+                    user=media_entry.get_uploader.username,
+                    media=media_entry.slug_or_id)" class=thumb_entry_title>{{ media_entry.title }}</a>
+    </div>
+    <div class=clear></div>
+  {% endif %}
+  Reason for report:
+  <div id="report-{{ report.id }}"
+       class="report_wrapper">
+    <div class="report_author">
+        <img src="{{ request.staticdirect('/images/icon_clipboard.png') }}" />
+        <a href="{{ request.urlgen('mediagoblin.admin.users_detail',
+                        user=report.reporter.username) }}"
+           class="report_authorlink">
+        {{- report.reporter.username -}}
+        </a>
+        <a href="{{ request.urlgen('mediagoblin.admin.reports_detail',
+                        report_id=report.id) }}"
+           class="report_whenlink">
+          <span title='{{- report.created.strftime("%I:%M%p %Y-%m-%d") -}}'>
+            {%- trans formatted_time=timesince(report.created) -%}
+              {{ formatted_time }} ago
+            {%- endtrans -%}
+          </span>
+        </a>
+    </div>
+    <div class="report_content">
+      {{ report.report_content }}
+    </div>
+  </div>
 {% endif %}
-<h2>{% trans %}Closed Reports on Comments{% endtrans %}</h2>
-{% if closed_report_list.count() %}
-  <table class="media_panel processing">
-    <tr>
-      <th>ID</th>
-      <th>Offender</th>
-      <th>When Reported</th>
-      <th>Reported By</th>
-      <th>Reason</th>
-      <th>Comment Posted On</th>
-    </tr>
-    {% for report in closed_report_list %}
-      <tr>
-        <td>{{ report.id }}</td>
-        <td>{{ report.comment.get_author.username }}</td>
-        <td>{{ report.created.strftime("%F %R") }}</td>
-        <td>{{ report.reporter.username }}</td>
-        <td>{{ report.report_content }}</td>
-        <td><a href="{{ report.comment.get_media_entry.url_for_self(request.urlgen) }}">{{ report.comment.get_media_entry.title }}</a></td>
-      </tr>
-    {% endfor %}
-  </table>
-{% else %}
-  <p><em>{% trans %}No closed reports found.{% endtrans %}</em></p>
-{% endif %} 
 {% endblock %}
diff --git a/mediagoblin/templates/mediagoblin/admin/report_panel.html b/mediagoblin/templates/mediagoblin/admin/report_panel.html
new file mode 100644 (file)
index 0000000..3019457
--- /dev/null
@@ -0,0 +1,95 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#}
+{% extends "mediagoblin/base.html" %}
+
+{% block title -%}
+  {% trans %}Report panel{% endtrans %} &mdash; {{ super() }}
+{%- endblock %}
+
+{% block mediagoblin_content %}
+
+<h1>{% trans %}Report panel{% endtrans %}</h1>
+
+<p>
+  {% trans %}Here you can look up users in order to take punitive actions on them.{% endtrans %}
+</p>
+    
+<h2>{% trans %}Reports Filed on Comments{% endtrans %}</h2>
+
+{% if report_list.count() %}
+  <table class="admin_panel processing">
+    <tr>
+      <th>ID</th>
+      <th>Report Type</th>
+      <th>Offender</th>
+      <th>When Reported</th>
+      <th>Reported By</th>
+      <th>Reason</th>
+      <th>Reported Comment or Media Entry</th>
+    </tr>
+    {% for report in report_list %}
+      <tr>
+        {% if report.discriminator == "comment_report" %}
+            <td>{{ report.id }}</td>
+            <td>Comment Report</td>
+            <td>{{ report.comment.get_author.username }}</td>
+            <td>{{ report.created.strftime("%F %R") }}</td>
+            <td>{{ report.reporter.username }}</td>
+            <td>{{ report.report_content }}</td>
+            <td><a href="{{ report.comment.get_media_entry.url_for_self(request.urlgen) }}">{{ report.comment.get_media_entry.title }}</a></td>
+        {% elif report.discriminator == "media_report" %}
+            <td>{{ report.id }}</td>
+            <td>Media Report</td>
+            <td>{{ report.media_entry.get_uploader.username }}</td>
+            <td>{{ report.created.strftime("%F %R") }}</td>
+            <td>{{ report.reporter.username }}</td>
+            <td>{{ report.report_content[0:20] }}...</td>
+            <td><a href="{{ report.media_entry.url_for_self(request.urlgen) }}">{{ report.media_entry.title }}</a></td>
+        {% endif %}
+      </tr>
+    {% endfor %}
+  </table>
+{% else %}
+  <p><em>{% trans %}No open reports found.{% endtrans %}</em></p>
+{% endif %}
+<h2>{% trans %}Closed Reports on Comments{% endtrans %}</h2>
+{% if closed_report_list.count() %}
+  <table class="media_panel processing">
+    <tr>
+      <th>ID</th>
+      <th>Offender</th>
+      <th>When Reported</th>
+      <th>Reported By</th>
+      <th>Reason</th>
+      <th>Comment Posted On</th>
+    </tr>
+    {% for report in closed_report_list %}
+      <tr>
+        <td>{{ report.id }}</td>
+        <td>{{ report.comment.get_author.username }}</td>
+        <td>{{ report.created.strftime("%F %R") }}</td>
+        <td>{{ report.reporter.username }}</td>
+        <td>{{ report.report_content }}</td>
+        <td><a href="{{ report.comment.get_media_entry.url_for_self(request.urlgen) }}">{{ report.comment.get_media_entry.title }}</a></td>
+      </tr>
+    {% endfor %}
+  </table>
+{% else %}
+  <p><em>{% trans %}No closed reports found.{% endtrans %}</em></p>
+{% endif %} 
+{% endblock %}
index 6b6d226a528d6c78d5a77194fd2db7cfbc696f78..90b3f583ad69eae4aca55fac5876a5b9379c9bfa 100644 (file)
 #}
 {% extends "mediagoblin/base.html" %}
 
-{% block title -%}
-  {% trans %}User panel{% endtrans %} &mdash; {{ super() }}
-{%- endblock %}
-
-{% block mediagoblin_content %}
-
-<h1>{% trans %}User panel{% endtrans %}</h1>
-
-<p>
-  {% trans %}Here you can look up users in order to take punitive actions on them.{% endtrans %}
-</p>
-    
-<h2>{% trans %}Active Users{% endtrans %}</h2>
-
-{% if user_list.count() %}
-  <table class="media_panel processing">
-    <tr>
-      <th>ID</th>
-      <th>Username</th>
-      <th>When Joined</th>
-      <th># of Comments Posted</th>
-    </tr>
-    {% for user in user_list %}
+
+{% block title %}
+  {%- if user -%}
+    {%- trans username=user.username -%}
+      User: {{ username }}
+    {%- endtrans %} &mdash; {{ super() }}
+  {%- else -%}
+    {{ super() }}
+  {%- endif -%}
+{% endblock %}
+
+
+{% block mediagoblin_content -%}
+  {# If no user... #}
+  {% if not user %}
+    <p>{% trans %}Sorry, no such user found.{% endtrans %}</p>
+
+  {# User exists, but needs verification #}
+  {% elif user.status == "needs_email_verification" %}
+    <div class="form_box">
+    <h1>{% trans %}Email verification needed{% endtrans %}</h1>
+
+    <p>
+      {% trans -%}
+        Someone has registered an account with this username, but it still has to be activated.
+      {%- endtrans %}
+    </p>
+  
+    <p>
+      {% trans login_url=request.urlgen('mediagoblin.auth.login') -%}
+        If you are that person but you've lost your verification email, you can <a href="{{ login_url }}">log in</a> and resend it.
+      {%- endtrans %}
+    </p>
+    </div>
+
+  {# Active(?) (or at least verified at some point) user, horray! #}
+  {% else %}
+    <h1>
+      {%- trans username=user.username %}{{ username }}'s profile{% endtrans -%}
+    </h1>
+
+    {% if not user.url and not user.bio %}
+        <div class="profile_sidebar empty_space">
+          <p>
+            {% trans -%}
+              This user hasn't filled in their profile (yet).
+            {%- endtrans %}
+          </p>
+    {% else %}
+      <div class="profile_sidebar">
+        {% include "mediagoblin/utils/profile.html" %}
+        {% if request.user and
+              (request.user.id == user.id or request.user.is_admin) %}
+          <a href="{{ request.urlgen('mediagoblin.edit.profile',
+                   user=user.username) }}">
+            {%- trans %}Edit profile{% endtrans -%}
+          </a>
+        {% endif %}
+    {% endif %}
+      <p>
+        <a href="{{ request.urlgen('mediagoblin.user_pages.collection_list',
+                                           user=user.username) }}">
+          {%- trans %}Browse collections{% endtrans -%}
+        </a>
+      </p>
+    </div>
+  {% endif %}
+  {% if user %}
+    <h2>{%- trans %}Active Reports on{% endtrans -%} {{ user.username }}</h2>
+    {% if reports.count() %}
+    <table class="admin_side_panel">
       <tr>
-        <td>{{ user.id }}</td>
-        <td>{{ user.username }}</td>
-        <td>{{ user.created.strftime("%F %R") }}</td>
-        <td>{{ user.posted_comments.count() }}</td>
+        <th>{%- trans %}Report ID{% endtrans -%}</th>
+        <th>{%- trans %}Reported Content{% endtrans -%}</th>
+        <th>{%- trans %}Description of Report{% endtrans -%}</th>
       </tr>
-    {% endfor %}
-  </table>
-{% else %}
-  <p><em>{% trans %}No users found.{% endtrans %}</em></p>
-{% endif %} 
+      {% for report in reports %}
+        <tr>
+          <td>
+            <img src="{{ request.staticdirect('/images/icon_clipboard.png') }}" />
+            <a href="{{ request.urlgen('mediagoblin.admin.reports_detail',
+                                               report_id=report.id) }}">
+              {%- trans %}Report #{% endtrans -%}{{ report.id }}
+            </a>
+          </td>
+          <td>
+            {% if report.discriminator == "comment_report" %}
+              <a>{%- trans %}Reported Comment{% endtrans -%}</a>
+            {% elif report.discriminator == "media_report" %}
+              <a>{%- trans %}Reported Media Entry{% endtrans -%}</a>
+            {% endif %}
+          </td>
+          <td>{{ report.report_content[:21] }}{% if report.report_content|count >20 %}...{% endif %}</td>
+          <td>{%- trans %}Resolve{% endtrans -%}</td>
+        </tr>
+      {% endfor %}
+        <tr><td></td><td></td>
+    </table>
+    {% else %}
+      {%- trans %}No active reports filed on{% endtrans -%} {{ user.username }}
+    {% endif %}
+    <a class="right_align">{{ user.username }}'s report history</a>
+    <span class=clear></span>
+    <h2>{{ user.username }}'s Privileges</h2>
+    <table class="admin_panel">
+        <tr>
+          <th>{% trans %}Privilege{% endtrans %}</th>
+          <th>{% trans %}User Has Privilege{% endtrans %}</th>
+      {% for privilege in privileges %}
+        <tr>
+          <td>{{ privilege.privilege_name }}</td>
+          <td>{% if privilege in user.all_privileges %}Yes{% else %}No{% endif %}</td>
+          <td>{% if privilege in user.all_privileges and privilege.id < request.user.get_highest_privilege().id %}<a>{% trans %}Take Away{% endtrans %}</a>{% else %}<a>{% trans %}Give Privilege{% endtrans %}</a>{% endif %}</td>
+        </tr>
+      {% endfor %}
+    </table>
+  {% endif %}
 {% endblock %}
diff --git a/mediagoblin/templates/mediagoblin/admin/user_panel.html b/mediagoblin/templates/mediagoblin/admin/user_panel.html
new file mode 100644 (file)
index 0000000..cc965b7
--- /dev/null
@@ -0,0 +1,55 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#}
+{% extends "mediagoblin/base.html" %}
+
+{% block title -%}
+  {% trans %}User panel{% endtrans %} &mdash; {{ super() }}
+{%- endblock %}
+
+{% block mediagoblin_content %}
+
+<h1>{% trans %}User panel{% endtrans %}</h1>
+
+<p>
+  {% trans %}Here you can look up users in order to take punitive actions on them.{% endtrans %}
+</p>
+    
+<h2>{% trans %}Active Users{% endtrans %}</h2>
+
+{% if user_list.count() %}
+  <table class="admin_panel processing">
+    <tr>
+      <th>{% trans %}ID{% endtrans %}</th>
+      <th>{% trans %}Username{% endtrans %}</th>
+      <th>{% trans %}When Joined{% endtrans %}</th>
+      <th>{% trans %}# of Comments Posted{% endtrans %}</th>
+    </tr>
+    {% for user in user_list %}
+      <tr>
+        <td>{{ user.id }}</td>
+        <td><a href="{{ request.urlgen('mediagoblin.admin.users_detail',
+                                         user= user.username) }}">{{ user.username }}</a></td>
+        <td>{{ user.created.strftime("%F %R") }}</td>
+        <td>{{ user.posted_comments.count() }}</td>
+      </tr>
+    {% endfor %}
+  </table>
+{% else %}
+  <p><em>{% trans %}No users found.{% endtrans %}</em></p>
+{% endif %} 
+{% endblock %}
index 6c7c07d06204bc6a4d04d2496de76edd00abed1b..e9a18f22c8aa765b83e88a566e6980428d602f6a 100644 (file)
               {% if request.user.is_admin %}
                 <p>
                   <span class="dropdown_title">Admin powers:</span>
-                  <a href="{{ request.urlgen('mediagoblin.admin.panel') }}">
+                  <a href="{{ request.urlgen('mediagoblin.admin.media_panel') }}">
                     {%- trans %}Media processing panel{% endtrans -%}
                   </a>
                 </p>
index 134a80ad403e641b145491315bd6a98485f2a780..1e64ae07322424aefbce70eaacf2165311f84602 100644 (file)
           {% trans %}Add a comment{% endtrans %}
         </a>
       {% endif %}
-        <a 
-          {% if not request.user -%}
-            href="{{ request.urlgen('mediagoblin.auth.login') }}"
-          {% else %}
-            href="{{ request.urlgen('mediagoblin.user_pages.media_home.report_media',
-                            user=media.get_uploader.username,
-                             media=media.slug_or_id) }}"
-          {% endif %}
-          class="button_action" id="button_reportmedia" title="Report media">
-          {% trans %}Report media{% endtrans %}
-        </a>
       {% if request.user %}
         <form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment',
                                          user= media.get_uploader.username,
 
     {% include "mediagoblin/utils/collections.html" %}
 
+    {% include "mediagoblin/utils/report.html" %}
+
     {% include "mediagoblin/utils/license.html" %}
 
     {% include "mediagoblin/utils/exif.html" %}
diff --git a/mediagoblin/templates/mediagoblin/utils/report.html b/mediagoblin/templates/mediagoblin/utils/report.html
new file mode 100644 (file)
index 0000000..4108cd8
--- /dev/null
@@ -0,0 +1,33 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#}
+
+{% block report_content -%}
+  <p>
+    <a 
+      {% if not request.user -%}
+        href="{{ request.urlgen('mediagoblin.auth.login') }}"
+      {% else %}
+            href="{{ request.urlgen('mediagoblin.user_pages.media_home.report_media',
+                            user=media.get_uploader.username,
+                             media=media.slug_or_id) }}"
+      {% endif %}
+        class="button_action" id="button_reportmedia" title="Report media">
+        {% trans %}Report media{% endtrans %}
+    </a>
+  </p>
+{% endblock %}
index 557c4853c4004c0c6b8ba7e95f5fb722ff05c8ee..2558b06692b5c1d5ec9e4b2f2c21d161cc18c6bb 100644 (file)
@@ -19,7 +19,8 @@ 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
 
 
@@ -99,9 +100,13 @@ def build_report_form(form_dict):
     if report_form.validate() and 'comment_id' in form_dict.keys():
         report_model = CommentReport()
         report_model.comment_id = report_form.comment_id.data
+        report_model.reported_user_id = MediaComment.query.get(
+            report_model.comment_id).get_author.id
     elif report_form.validate() and 'media_entry_id' in form_dict.keys():
         report_model = MediaReport()
         report_model.media_entry_id = report_form.media_entry_id.data
+        report_model.reported_user_id = MediaEntry.query.get(
+            report_model.media_entry_id).get_uploader.id
     else:
         return None