From 954b407cf8386f3c40ce1f51c2c7f321075b0fe6 Mon Sep 17 00:00:00 2001 From: Elrond Date: Sun, 24 Feb 2013 11:30:17 +0100 Subject: [PATCH] Use the media id for attachmemt editing. And remove some stray white space from the output. --- mediagoblin/edit/views.py | 4 ++-- .../mediagoblin/edit/attachments.html | 15 +++++++------ .../mediagoblin/user_pages/media.html | 22 ++++++++++--------- mediagoblin/user_pages/routing.py | 2 +- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py index ceab52d0..cdb5c713 100644 --- a/mediagoblin/edit/views.py +++ b/mediagoblin/edit/views.py @@ -27,7 +27,7 @@ from mediagoblin.edit import forms from mediagoblin.edit.lib import may_edit_media from mediagoblin.decorators import (require_active_login, active_user_from_url, get_media_entry_by_id, - get_user_media_entry, user_may_alter_collection, get_user_collection) + user_may_alter_collection, get_user_collection) from mediagoblin.tools.response import render_to_response, redirect from mediagoblin.tools.translate import pass_to_ugettext as _ from mediagoblin.tools.text import ( @@ -98,7 +98,7 @@ UNSAFE_MIMETYPES = [ 'text/svg+xml'] -@get_user_media_entry +@get_media_entry_by_id @require_active_login def edit_attachments(request, media): if mg_globals.app_config['allow_attachments']: diff --git a/mediagoblin/templates/mediagoblin/edit/attachments.html b/mediagoblin/templates/mediagoblin/edit/attachments.html index 55d446de..3fbea3be 100644 --- a/mediagoblin/templates/mediagoblin/edit/attachments.html +++ b/mediagoblin/templates/mediagoblin/edit/attachments.html @@ -15,7 +15,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . #} -{% extends "mediagoblin/base.html" %} +{%- extends "mediagoblin/base.html" %} {% import "/mediagoblin/utils/wtforms.html" as wtforms_util %} @@ -28,13 +28,14 @@ {% block mediagoblin_content %}

- {% trans media_title=media.title -%} + {%- trans media_title=media.title -%} Editing attachments for {{ media_title }} - {%- endtrans %}

+ {%- endtrans -%} +
@@ -42,19 +43,19 @@ {% if media.attachment_files|count %}

{% trans %}Attachments{% endtrans %}

    - {% for attachment in media.attachment_files %} + {%- for attachment in media.attachment_files %}
  • {{- attachment.name -}}
  • - {% endfor %} + {%- endfor %}
{% endif %}

{% trans %}Add attachment{% endtrans %}

- {{ wtforms_util.render_divs(form) }} + {{- wtforms_util.render_divs(form) }}
{%- trans %}Cancel{% endtrans -%} diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index 7550c6c1..535ee448 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -15,7 +15,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . #} -{% extends "mediagoblin/base.html" %} +{%- extends "mediagoblin/base.html" %} {% import "/mediagoblin/utils/wtforms.html" as wtforms_util %} {% from "mediagoblin/utils/pagination.html" import render_pagination %} @@ -155,31 +155,33 @@ {% include "mediagoblin/utils/exif.html" %} - {% if media.attachment_files|count %} + {%- if media.attachment_files|count %}

{% trans %}Attachments{% endtrans %}

- {% endif %} - {% if app_config['allow_attachments'] + {%- endif %} + {%- if app_config['allow_attachments'] and request.user and (media.uploader == request.user.id or request.user.is_admin) %} - {% if not media.attachment_files|count %} + {%- if not media.attachment_files|count %}

{% trans %}Attachments{% endtrans %}

- {% endif %} + {%- endif %}

{% trans %}Add attachment{% endtrans %} + media_id=media.id) }}"> + {%- trans %}Add attachment{% endtrans -%} +

- {% endif %} + {%- endif %} {% template_hook("media_sideinfo") %} diff --git a/mediagoblin/user_pages/routing.py b/mediagoblin/user_pages/routing.py index 6ea3c3e2..7de3ab60 100644 --- a/mediagoblin/user_pages/routing.py +++ b/mediagoblin/user_pages/routing.py @@ -87,5 +87,5 @@ add_route('mediagoblin.edit.edit_media', 'mediagoblin.edit.views:edit_media') add_route('mediagoblin.edit.attachments', - '/u//m//attachments/', + '/u//m//attachments/', 'mediagoblin.edit.views:edit_attachments') -- 2.25.1