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

View File

@ -15,7 +15,7 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # 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 %} {% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
{% from "mediagoblin/utils/pagination.html" import render_pagination %} {% from "mediagoblin/utils/pagination.html" import render_pagination %}
@ -155,31 +155,33 @@
{% include "mediagoblin/utils/exif.html" %} {% include "mediagoblin/utils/exif.html" %}
{% if media.attachment_files|count %} {%- if media.attachment_files|count %}
<h3>{% trans %}Attachments{% endtrans %}</h3> <h3>{% trans %}Attachments{% endtrans %}</h3>
<ul> <ul>
{% for attachment in media.attachment_files %} {%- for attachment in media.attachment_files %}
<li> <li>
<a href="{{ request.app.public_store.file_url(attachment.filepath) }}"> <a href="{{ request.app.public_store.file_url(attachment.filepath) }}">
{{- attachment.name -}} {{- attachment.name -}}
</a> </a>
</li> </li>
{% endfor %} {%- endfor %}
</ul> </ul>
{% endif %} {%- endif %}
{% if app_config['allow_attachments'] {%- if app_config['allow_attachments']
and request.user and request.user
and (media.uploader == request.user.id and (media.uploader == request.user.id
or request.user.is_admin) %} or request.user.is_admin) %}
{% if not media.attachment_files|count %} {%- if not media.attachment_files|count %}
<h3>{% trans %}Attachments{% endtrans %}</h3> <h3>{% trans %}Attachments{% endtrans %}</h3>
{% endif %} {%- endif %}
<p> <p>
<a href="{{ request.urlgen('mediagoblin.edit.attachments', <a href="{{ request.urlgen('mediagoblin.edit.attachments',
user=media.get_uploader.username, user=media.get_uploader.username,
media=media.id) }}">{% trans %}Add attachment{% endtrans %}</a> media_id=media.id) }}">
{%- trans %}Add attachment{% endtrans -%}
</a>
</p> </p>
{% endif %} {%- endif %}
{% template_hook("media_sideinfo") %} {% template_hook("media_sideinfo") %}

View File

@ -87,5 +87,5 @@ add_route('mediagoblin.edit.edit_media',
'mediagoblin.edit.views:edit_media') 'mediagoblin.edit.views:edit_media')
add_route('mediagoblin.edit.attachments', 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') 'mediagoblin.edit.views:edit_attachments')