</script>
{% endblock %}
-{% if object %}
+{% if collection %}
{% block title %}
<img src="{{ STATIC_URL }}telemeta/images/collections_red.png" style="vertical-align:middle" />
- Collection : {{ object.title }}
+ Collection : {{ collection.title }}
{% endblock %}
{% block title_buttons %}
from telemeta.views.core import *
+
class CollectionView(object):
"""Provide Collections web UI methods"""
pass
else:
obj = obj[0]
- self.pk = obj.pk
- return get_object_or_404(self.model, pk=self.pk)
+ return obj
class CollectionListView(ListView):
form_class = MediaItemForm
template_name = 'telemeta/mediaitem_add.html'
+ def get_initial(self):
+ obj = MediaItem()
+ # new item for a specific collection
+ if 'public_id' in self.kwargs:
+ public_id = self.kwargs['public_id']
+ collections = MediaCollection.objects.filter(code=public_id)
+ if collections:
+ collection = collections[0]
+ obj.collection = collection
+ return model_to_dict(obj)
+
def get_success_url(self):
return reverse_lazy('telemeta-items')