model = MediaCorpusRelated
+
+class CollectionRelatedInline(InlineFormSet):
+
+ model = MediaCollectionRelated
+
+
+class ItemRelatedInline(InlineFormSet):
+
+ model = MediaItemRelated
+
(<a href="{% url "telemeta-collection-m3u" collection.public_id %}">M3U</a>,
<a href="{% url "telemeta-collection-xspf" collection.public_id %}">XSPF</a>)</h3>
</div>
- <!-- This is Jeroen Wijering's Flash MP3 Player,
- under CC Attribution-NonCommercial-ShareAlike 2.0 license
- from: http://www.jeroenwijering.com/?item=Flash_MP3_Player-->
- <p id="collection_player_c">
- <a href="http://www.macromedia.com/go/getflashplayer">Get Flash</a> to see this player.
- </p>
- <script type="text/javascript">
- var so = new SWFObject('{{ STATIC_URL }}telemeta/swf/mp3player.swf','playlist','362','200','7');
- so.addVariable("file","{% url "telemeta-collection-xspf" collection.public_id %}");
- so.addVariable("displayheight","0");
- so.addParam("wmode", "opaque");
- so.write('collection_player_c');
- </script>
</div>
</div>
{% endif %}
{% extends "telemeta/collection_detail.html" %}
{% load i18n %}
{% load telemeta_utils %}
+{% load bootstrap3 %}
{% block title %}
<img src="{{ STATIC_URL }}telemeta/images/collections_red.png" style="vertical-align:middle" /> Collection : {{ collection }}
{% endblock %}
+
{% block title_buttons %}
- <a href="{% url "telemeta-collection-detail" collection.public_id %}" class="component_icon button icon_cancel">{% trans "Cancel" %}</a>
- <a href="#" class="component_icon button icon_save"
- onclick="document.getElementById('_editCollectionForm').submit(); return false;">{% trans "Save" %}</a>
+ <a href="{% url "telemeta-collection-detail" object.public_id %}" class="component_icon button icon_cancel">{% trans "Cancel" %}</a>
{% endblock %}
{% block infos %}
- <div class="infos">
- <form method="post" id="_editCollectionForm" action="">{% csrf_token %}
- <table>
- <tr><td colspan="2">{% for error in form.non_field_errors %}<li class="error">{{ error }}</li>{% endfor %}</td></tr>
- {% for field in form %}
- <tr>
- {% if field.html_name == "copied_from_item" %}
- <td>{{ field.label_tag.as_hidden }}</td><td>{{ field.as_hidden }}</td>
- {% else %}
- <tr><td class="error">{{ field.errors }}</td></tr>
- <td>{{ field.label_tag }}:</td><td> {{ field }}</td>
- {% endif %}
- </tr>
- {% endfor %}
- <tr>
- <td style="padding-top: 1em">{% trans "Related media" %}:</td>
- <td style="padding-top: 1em"><a href="{% url "telemeta-collection-related_edit" collection.public_id %}" class="component_icon button icon_edit">{% trans "Edit"%} {% trans "related media"%}</a></td>
- </tr>
- </table>
- <div align="center" style="margin-top:3ex;">
- <a href="{% url "telemeta-collection-detail" collection.public_id %}" class="component_icon button icon_cancel">{% trans "Cancel" %}</a>
- <a href="#" class="component_icon button icon_save"
- onclick="document.getElementById('_editCollectionForm').submit(); return false;">{% trans "Save" %}</a>
- </div>
- </form>
- </div>
+
+ <div>
+ <form method="post" id="_editForm" action="">{% csrf_token %}
+
+ <ul class="nav nav-tabs" role="tablist">
+ <li class="active"><a href="#general" role="tab" data-toggle="tab">General</a></li>
+ <li><a href="#related" role="tab" data-toggle="tab">Related media</a></li>
+ </ul>
+
+ <div class="tab-content">
+
+ <div class="tab-pane fade in active" id="general">
+ <script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
+ <script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
+ <script type="text/javascript" src="/static/admin/js/actions.min.js"></script>
+
+ {{ form.media }}
+ {% bootstrap_form form %}
+ </div>
+
+ <div class="tab-pane" id="related">
+ {% for formset in inlines %}
+ {{ formset.management_form }}
+ {% for form in formset %}
+ <hr />
+ {% bootstrap_form form %}
+ {# {{ form.as_table }} #}
+ {% endfor %}
+ {% endfor %}
+ </div>
+
+ </div>
+
+
+ <div align="center" style="margin-top:3ex;">
+ <a href="{% url "telemeta-collection-detail" object.public_id %}" class="component_icon button icon_cancel">{% trans "Cancel" %}</a>
+ {% if perms.telemeta.change_mediacollection %}
+ <input type="submit" value="Enregistrer" class="default" name="_save"/>
+ {% endif %}
+ {# <a href="#" class="component_icon button icon_save" id="submit_button">{% trans "Save" %}</a> #}
+ </div>
+
+ </form>
+ </div>
+
{% endblock infos%}
{% block delete %}
</ul>
</div>
- {% if user.is_authenticated and perms.telemeta.add_mediacollection %}
+ {% if user.is_authenticated and perms.telemeta.add_mediacollection %}
<a href="{% url "telemeta-collection-add" %}" class="component_icon button icon_add">{% trans "Add" %}</a>
- {% endif %}
+ {% endif %}
{% endblock %}
{% block content %}
<div class="fullpage">
+{% with object_list as collections %}
{% include "telemeta/inc/collection_list.html" %}
-</div>
+{% endwith %}
{% endblock %}
{% load telemeta_utils %}
{% load i18n %}
-{% if object_list %}
+{% if collections %}
<table class="listing">
<tr>
<th>{% trans "Recording period" %}</th>
<th>{% trans "Sound" %}</th>
</tr>
-{% for collection in object_list %}
+{% for collection in collections %}
<tr {% if not forloop.counter0|divisibleby:"2" %}class="odd"{% endif %}>
<td class="highlight">
<a href="{% url "telemeta-collection-detail" collection.public_id %}">{{ collection.title }}</a>
{% load telemeta_utils %}
{% load i18n %}
-{% if object_list %}
+{% if items %}
<table class="listing">
<tr>
<th>{% trans "Year of recording" %}</th>
<th>{% trans "Sound" %}</th>
</tr>
-{% for item in object_list %}
+{% for item in items %}
<tr {% if not forloop.counter0|divisibleby:"2" %}class="odd"{% endif %}>
<td class="highlight">
<a href="{% url "telemeta-item-detail" item.public_id %}">{{ item }}</a>
{% endblock %}
{% block content %}
+{% with object_list as items %}
<div class="fullpage">
{% include "telemeta/inc/mediaitem_list.html" %}
</div>
+{% endwith %}
{% endblock %}
url(r'^archives/collections_published/$', CollectionPublishedListView.as_view(), name="telemeta-collections-published"),
url(r'^archives/collections_sound/$', CollectionSoundListView.as_view(), name="telemeta-collections-sound"),
- url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/$', collection_view.collection_detail,
- dict(template="telemeta/collection_detail.html"), name="telemeta-collection-detail"),
+ url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/$', CollectionDetailView.as_view(), name="telemeta-collection-detail"),
url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/dc/$', collection_view.collection_detail,
dict(template="telemeta/collection_detail_dc.html"), name="telemeta-collection-dublincore"),
url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/collection_xspf.xml$',
collection_view.collection_playlist,
dict(template="telemeta/collection.m3u", mimetype="audio/mpegurl"),
name="telemeta-collection-m3u"),
- url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/edit/$', collection_view.collection_edit,
- dict(template='telemeta/collection_edit.html'), name="telemeta-collection-edit"),
+ url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/edit/$', CollectionEditView.as_view(), name="telemeta-collection-edit"),
url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/copy/$', collection_view.collection_copy,
dict(template='telemeta/collection_edit.html'), name="telemeta-collection-copy"),
url(r'^archives/collection_new/add/$', collection_view.collection_add,
# Generic resources
url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/$', ResourceListView.as_view(), name="telemeta-resource-list"),
url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/$', ResourceDetailView.as_view(), name="telemeta-resource-detail"),
- url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/edit2/$', ResourceFormSetView.as_view(), name="telemeta-resource-detail2"),
- url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/dc/$', ResourceDetailDCView.as_view(), name="telemeta-resource-dublincore"),
url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/edit/$', ResourceEditView.as_view(), name="telemeta-resource-edit"),
+ url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/dc/$', ResourceDetailDCView.as_view(), name="telemeta-resource-dublincore"),
url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/copy/$', ResourceCopyView.as_view(), name="telemeta-resource-copy"),
url(r'^archives/(?P<type>[A-Za-z0-9._-]+)_add$', ResourceAddView.as_view(), name="telemeta-resource-add"),
url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/delete/$', ResourceDeleteView.as_view(), name="telemeta-resource-delete"),
messages.error(request, title)
return render(request, 'telemeta/messages.html', {'description' : description})
- playlists = get_playlists(request)
+ playlists = get_playlists_names(request)
related_media = MediaCollectionRelated.objects.filter(collection=collection)
check_related_media(related_media)
return super(CollectionPackageView, self).dispatch(*args, **kwargs)
+class CollectionViewMixin(object):
+
+ model = MediaCollection
+
+ def get_object(self):
+ self.pk = self.model.objects.get(code=self.kwargs['public_id']).pk
+ return get_object_or_404(self.model, pk=self.pk)
+
+
class CollectionListView(ListView):
model = MediaCollection
queryset = MediaCollection.objects.sound().order_by('code', 'old_code')
-class CollectionViewMixin(object):
-
- model = MediaCollection
- type = 'collection'
-
-
class CollectionDetailView(CollectionViewMixin, DetailView):
-
- def get_object(self):
- return self.model.objects.get(code=self.kwargs['public_id'])
+ template_name = 'telemeta/collection_detail.html'
def get_context_data(self, **kwargs):
context = super(CollectionDetailView, self).get_context_data(**kwargs)
collection = self.get_object()
items = collection.items.enriched()
- items = items.order_by('code', 'old_code')
+ context['collection'] = collection
+ context['items'] = items.order_by('code', 'old_code')
if collection.public_access == 'none' and not (request.user.is_staff or request.user.is_superuser):
mess = ugettext('Access not allowed')
title = ugettext('Collection') + ' : ' + public_id + ' : ' + mess
description = ugettext('Please login or contact the website administator to get a private access.')
messages.error(request, title)
- return render(request, 'telemeta/messages.html', {'description' : description})
+ return render(self.request, 'telemeta/messages.html', {'description' : description})
- playlists = get_playlists(self.request)
- related_media = MediaCollectionRelated.objects.filter(collection=collection)
- check_related_media(related_media)
- parents = MediaCorpus.objects.filter(children=collection)
+ context['playlists'] = get_playlists_names(self.request)
+ context['related_media'] = MediaCollectionRelated.objects.filter(collection=collection)
+ check_related_media(context['related_media'])
+ context['parents'] = MediaCorpus.objects.filter(children=collection)
revisions = Revision.objects.filter(element_type='collection',
element_id=collection.id).order_by('-time')
if revisions:
- last_revision = revisions[0]
+ context['last_revision'] = revisions[0]
else:
- last_revision = None
+ context['last_revision'] = None
return context
+
+
+class CollectionEditView(CollectionViewMixin, UpdateWithInlinesView):
+
+ template_name = 'telemeta/collection_edit.html'
+ inlines = [CollectionRelatedInline, ]
+
+ def form_valid(self, form):
+ messages.info(self.request, _("You have successfully updated your collection."))
+ return super(CollectionEditView, self).form_valid(form)
+
+ def get_success_url(self):
+ return reverse_lazy('telemeta-collection-detail', kwargs={'public_id':self.kwargs['public_id']})
+
+
template_name = "telemeta/resource_detail_dc.html"
-class ResourceEditView(ResourceSingleMixin, UpdateView):
-
- template_name = 'telemeta/resource_edit.html'
-
- def get_form_class(self):
- self.type = self.kwargs['type']
- self.setup(self.type)
- return self.form
-
- def form_valid(self, form):
- messages.info(self.request, _("You have successfully updated your resource."))
- return super(ResourceEditView, self).form_valid(form)
-
- def get_success_url(self):
- return reverse_lazy('telemeta-resource-detail', kwargs={'type':self.kwargs['type'], 'public_id':self.kwargs['public_id']})
-
-
class ResourceAddView(ResourceMixin, CreateView):
template_name = 'telemeta/resource_add.html'
return reverse_lazy('telemeta-resource-list', kwargs={'type':self.kwargs['type']})
+class ResourceEditView(ResourceSingleMixin, UpdateWithInlinesView):
-class ResourceFormSetView(ResourceSingleMixin, UpdateWithInlinesView):
-
- template_name = 'telemeta/resource_edit2.html'
+ template_name = 'telemeta/resource_edit.html'
def get_success_url(self):
return reverse_lazy('telemeta-resource-detail', kwargs={'type':self.kwargs['type'], 'public_id':self.kwargs['public_id']})