Use the media id for attachmemt editing.

And remove some stray white space from the output.
This commit is contained in:
Elrond 2013-02-24 11:30:17 +01:00
parent ac7c918096
commit 954b407cf8
4 changed files with 23 additions and 20 deletions

View File

@ -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']:

View File

@ -15,7 +15,7 @@
# 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" %}
{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
@ -28,13 +28,14 @@
{% block mediagoblin_content %}
<form action="{{ request.urlgen('mediagoblin.edit.attachments',
user= media.get_uploader.username,
media= media.id) }}"
media_id=media.id) }}"
method="POST" enctype="multipart/form-data">
<div class="form_box">
<h1>
{% trans media_title=media.title -%}
{%- trans media_title=media.title -%}
Editing attachments for {{ media_title }}
{%- endtrans %}</h1>
{%- endtrans -%}
</h1>
<div style="text-align: center;" >
<img src="{{ media.thumb_url }}" />
</div>
@ -42,19 +43,19 @@
{% if media.attachment_files|count %}
<h2>{% trans %}Attachments{% endtrans %}</h2>
<ul>
{% for attachment in media.attachment_files %}
{%- for attachment in media.attachment_files %}
<li>
<a target="_blank" href="{{ request.app.public_store.file_url(
attachment['filepath']) }}">
{{- attachment.name -}}
</a>
</li>
{% endfor %}
{%- endfor %}
</ul>
{% endif %}
<h2>{% trans %}Add attachment{% endtrans %}</h2>
{{ wtforms_util.render_divs(form) }}
{{- wtforms_util.render_divs(form) }}
<div class="form_submit_buttons">
<a href="{{ media.url_for_self(request.urlgen) }}">
{%- trans %}Cancel{% endtrans -%}

View File

@ -15,7 +15,7 @@
# 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" %}
{% 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 %}
<h3>{% trans %}Attachments{% endtrans %}</h3>
<ul>
{% for attachment in media.attachment_files %}
{%- for attachment in media.attachment_files %}
<li>
<a href="{{ request.app.public_store.file_url(attachment.filepath) }}">
{{- attachment.name -}}
</a>
</li>
{% endfor %}
{%- endfor %}
</ul>
{% 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 %}
<h3>{% trans %}Attachments{% endtrans %}</h3>
{% endif %}
{%- endif %}
<p>
<a href="{{ request.urlgen('mediagoblin.edit.attachments',
user=media.get_uploader.username,
media=media.id) }}">{% trans %}Add attachment{% endtrans %}</a>
media_id=media.id) }}">
{%- trans %}Add attachment{% endtrans -%}
</a>
</p>
{% endif %}
{%- endif %}
{% template_hook("media_sideinfo") %}

View File

@ -87,5 +87,5 @@ add_route('mediagoblin.edit.edit_media',
'mediagoblin.edit.views:edit_media')
add_route('mediagoblin.edit.attachments',
'/u/<string:user>/m/<string:media>/attachments/',
'/u/<string:user>/m/<int:media_id>/attachments/',
'mediagoblin.edit.views:edit_attachments')