]> git.parisson.com Git - telemeta.git/commitdiff
fix resource edit, add bootstrap pagination and buttons
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 19 Sep 2014 00:16:58 +0000 (02:16 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 19 Sep 2014 00:16:58 +0000 (02:16 +0200)
12 files changed:
telemeta/forms/media.py
telemeta/static/telemeta/css/telemeta.css
telemeta/templates/telemeta/collection_list.html
telemeta/templates/telemeta/inc/collection_list.html
telemeta/templates/telemeta/inc/mediaitem_list.html
telemeta/templates/telemeta/inc/resource_list.html
telemeta/templates/telemeta/mediaitem_list.html
telemeta/templates/telemeta/resource_edit.html
telemeta/templates/telemeta/resource_list.html
telemeta/views/collection.py
telemeta/views/item.py
telemeta/views/resource.py

index 785551bdd9c246dcd73c708e4fd2c5a6183a7411..0711595752b273542cf4935dad89a57c65506cbd 100644 (file)
@@ -41,25 +41,31 @@ from extra_views.generic import GenericInlineFormSet
 
 
 class MediaFondsForm(ModelForm):
-    widget = FilteredSelectMultiple("Verbose name", is_stacked=False)
-    field = forms.ModelMultipleChoiceField(queryset=MediaCorpus.objects.all())
-    children = forms.ModelMultipleChoiceField(widget=widget, queryset=field)
+
+    widget = FilteredSelectMultiple("Corpus", True,)
+    queryset = queryset=MediaCorpus.objects.all()
+    children = forms.ModelMultipleChoiceField(widget=widget, queryset=queryset, label='Corpus')
 
     class Meta:
         model = MediaFonds
         exclude = ['description',]
 
+    class Media:
+        css = {'all': ['/static/admin/css/widgets.css',],}
+        js = ['/admin/django/jsi18n/',]
+
 
 class MediaFondsRelatedForm(ModelForm):
+
     class Meta:
         model = MediaFondsRelated
 
 
 class MediaCorpusForm(ModelForm):
-    # queryset = MediaCollection.objects.all()
-    # widget = FilteredSelectMultiple('children', False)
-    # # # field = forms.ModelMultipleChoiceField(queryset=MediaCorpus.objects.all())
-    # children = forms.ModelMultipleChoiceField(widget=widget, queryset=queryset, required=True)
+
+    queryset = MediaCollection.objects.all()
+    widget = FilteredSelectMultiple('Collections', False)
+    children = forms.ModelMultipleChoiceField(widget=widget, queryset=queryset,label='Collections')
 
     class Meta:
         model = MediaCorpus
@@ -71,23 +77,28 @@ class MediaCorpusForm(ModelForm):
 
 
 class MediaCorpusRelatedForm(ModelForm):
+
     class Meta:
         model = MediaCorpusRelated
 
 
 class MediaCollectionForm(ModelForm):
+
     class Meta:
         model = MediaCollection
+
     def clean_doctype_code(self):
         return self.cleaned_data['doctype_code'] or 0
 
 
 class MediaCollectionRelatedForm(ModelForm):
+
     class Meta:
         model = MediaCollectionRelated
 
 
 class MediaItemForm(ModelForm):
+
     class Meta:
         model = MediaItem
 
@@ -102,16 +113,19 @@ class MediaItemForm(ModelForm):
 
 
 class MediaItemRelatedForm(ModelForm):
+
     class Meta:
         model = MediaItemRelated
 
 
 class MediaItemKeywordForm(ModelForm):
+
     class Meta:
         model = MediaItemKeyword
 
 
 class MediaItemPerformanceForm(ModelForm):
+
     class Meta:
         model = MediaItemPerformance
 
@@ -122,14 +136,17 @@ class MediaItemPerformanceForm(ModelForm):
 
 
 class PlaylistForm(ModelForm):
+
     class Meta:
         model = Playlist
 
 
 class FondsRelatedInline(InlineFormSet):
+
     model = MediaFondsRelated
 
 
 class CorpusRelatedInline(InlineFormSet):
+
     model = MediaCorpusRelated
 
index 3f031ab0a1ccbc196d5f1758538b73c4b9ebad3c..647883f835e895638ae1db9d45294cbc82f5a0d7 100644 (file)
@@ -4,7 +4,7 @@ a {text-decoration: none; color: #969696;}
 a img {border: none;}
 
 body {
-    font: 0.9em/1em verdana, sans-serif;
+    font: 0.8125em/1em verdana, sans-serif;
     line-height: 1.3em;
     color: #333;
     background: #FFF;
@@ -484,7 +484,7 @@ form.login .submit {
     moz-border-radius-topright: 5px 5px;
     border-top-right-radius: 5px 5px;
     font-weight: bold;
-    font-size: 15px;
+    font-size: 14px;
     padding: .5em 1em;
 }
 #menu a:hover, #menu a.active{
@@ -661,7 +661,7 @@ dl.listing dt.group {
 }
 dl.listing dd {
     margin-left: 19.4em;
-    /*font-weight: bold;*/
+    font-weight: bold;
 }
 
 /* dublin core display */
@@ -723,11 +723,12 @@ dl.dublincore dd.caption {
 
 .infos dl, .infos table {
     position: relative;
+    font-size: 105%;
 }
 
 .extraInfos dl, .extraInfos table {
     position: relative;
-
+    font-size: 105%;
 }
 
 .extraInfos div {
@@ -778,19 +779,18 @@ dl.dublincore dd.caption {
 
 /* Pagination */
 .pagination {
-    margin-top: .7em;
-    margin-bottom: .3em;
+    margin-top: 0em;
+    margin-bottom: 0em;
     padding: .3em 0;
-    font-size: 1em;
+    font-size: 0.7em;
     background-color: #fff;
-    border-bottom: 1px solid #aaa;
+    /*border-bottom: 1px solid #aaa;*/
     color: #333;
     font-weight: bold;
 }
 .pagination a {
     background-color: #fff;
     border-bottom: none;
-    font-size: 1em;
     padding: .3em;
 }
 
@@ -1160,7 +1160,7 @@ a.image-link {
     color:#444;
     text-decoration: none;
     margin:0;
-    font: 0.8em/1.2em sans-serif;
+    font: 1em/1.2em Verdana, sans-serif;
 }
 .component + .component, .component + .component_icon, .component_icon + .component ,
 .component_icon + .component_icon{
index 191d45854962e88e5012bf075222ff18c0b4c5e1..79d7cab68e216ff017d17af6164e899399ebf615 100644 (file)
@@ -1,27 +1,44 @@
 {% extends "telemeta/base.html" %}
 {% load telemeta_utils %}
 {% load i18n %}
+{% load bootstrap_pagination %}
 
-{% block head_title %}{% trans "Media Collections" %} - {{ block.super }}{% endblock %}
+{% block head_title %}{% trans "Collections" %} - {{ block.super }}{% endblock %}
 
 {% block title%}
- <img src="{{ STATIC_URL }}telemeta/images/collections_red.png" style="vertical-align:middle" /> {% trans "Media Collections" %}
+<div class='row'>
+<div class="col-md-4">
+ <img src="{{ STATIC_URL }}telemeta/images/collections_red.png" style="vertical-align:middle" /> {% trans "Collections" %} ({{ page_obj.start_index }} - {{ page_obj.end_index }} / {{ count }})
+</div>
+<div class="col-md-8">
+{% bootstrap_paginate page_obj range=10 show_first_last="True" %}
+</div>
+<div class="col-md-0">&nbsp;</div>
+</div>
 {% endblock %}
 
 {% block title_buttons %}
-     <a href="{% url "telemeta-collections" %}" class="component_icon button icon_filter">{% trans "All" %}</a>
-     <a href="{% url "telemeta-collections-unpublished" %}" class="component_icon button icon_filter">{% trans "Unpublished" %}</a>
-     <a href="{% url "telemeta-collections-published" %}" class="component_icon button icon_filter">{% trans "Published" %}</a>
-     <a href="{% url "telemeta-collections-sound" %}" class="component_icon button icon_filter">{% trans "Sounds" %}</a>
-    {% if user.is_authenticated and perms.telemeta.add_mediacollection %}
+
+<!-- Single button -->
+<div class="btn-group">
+  <button type="button" class="btn btn-default dropdown-toggle icon-filter" data-toggle="dropdown">
+    <i class="icon-filter"></i> {% trans "Filters" %} <span class="caret"></span>
+  </button>
+  <ul class="dropdown-menu" role="menu">
+    <li><a href="{% url "telemeta-collections" %}" class="">{% trans "All" %}</a></li>
+    <li><a href="{% url "telemeta-collections-unpublished" %}">{% trans "Unpublished" %}</a></li>
+    <li><a href="{% url "telemeta-collections-published" %}">{% trans "Published" %}</a></li>
+    <li><a href="{% url "telemeta-collections-sound" %}">{% trans "Sounds" %}</a></li>
+  </ul>
+</div>
+
+   {% 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 %}
-{% with object_list as collections %}
 <div class="fullpage">
 {% include "telemeta/inc/collection_list.html" %}
 </div>
-{% endwith %}
 {% endblock %}
index 34744f2bfb2f8ef07e59875fee0606360a623254..64c11409862c3d9dc4904795cb69a2b772cb0870 100644 (file)
@@ -1,9 +1,7 @@
 {% load telemeta_utils %}
 {% load i18n %}
-{% load pagination_tags %}
 
-{% if collections %}
-{% paginate %}
+{% if object_list %}
 
 <table class="listing">
 <tr>
@@ -14,7 +12,7 @@
     <th>{% trans "Recording period" %}</th>
     <th>{% trans "Sound" %}</th>
 </tr>
-{% for collection in collections %}
+{% for collection in object_list %}
 <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>
index f3f8ae974303a70812f23281559e524eafa4c75a..041f86e1c2b198c1133b1284b95434354eee5c21 100644 (file)
@@ -1,9 +1,7 @@
 {% load telemeta_utils %}
 {% load i18n %}
-{% load pagination_tags %}
 
-{% if items %}
-{% paginate %}
+{% if object_list %}
 
 <table class="listing">
 <tr>
@@ -18,7 +16,7 @@
     <th>{% trans "Year of recording" %}</th>
     <th>{% trans "Sound" %}</th>
 </tr>
-{% for item in items %}
+{% for item in object_list %}
 <tr {% if not forloop.counter0|divisibleby:"2" %}class="odd"{% endif %}>
     <td class="highlight">
         <a href="{% url "telemeta-item-detail" item.public_id %}">{{ item }}</a>
index b3d76f46bc62c3011d1e8f88473e20057dd90dc0..3dcec5a4c46ef520a1f1639633e3c5b02c0ee292 100644 (file)
@@ -1,8 +1,7 @@
 {% load telemeta_utils %}
 {% load i18n %}
 
-{% if resources %}
-{% include "pure_pagination/pagination.html" %}
+{% if object_list %}
 
 <table class="listing">
 <tr>
@@ -11,7 +10,7 @@
     <th width="15%">{% trans "Code" %}</th>
     <th width="5%">{% trans "Sound" %}</th>
 </tr>
-{% for resource in resources %}
+{% for resource in object_list %}
 <tr {% if not forloop.counter0|divisibleby:"2" %}class="odd"{% endif %}>
     <td class="highlight">
         <a href="{% url "telemeta-resource-detail" type resource.public_id %}">{{ resource.title }}</a>
@@ -25,6 +24,7 @@
 </tr>
 {% endfor %}
 </table>
+
 {% else %}
     <p>{% trans "No resource" %}</p>
 {% endif %}
index 6abe3237b7c523a79e9d5ec8a9b13597e92b0206..014deda567101ba3f5bbb314166859a774a47f31 100644 (file)
@@ -1,27 +1,43 @@
 {% extends "telemeta/base.html" %}
 {% load i18n %}
 {% load telemeta_utils %}
+{% load bootstrap_pagination %}
 
 {% block head_title %}{% trans "Media Items" %} - {{ block.super }}{% endblock %}
 
 {% block title %}
- <img src="{{ STATIC_URL }}telemeta/images/item.png" alt="item" style="vertical-align:middle" /> {% trans "Media Items" %}
+<div class='row'>
+<div class="col-md-4">
+ <img src="{{ STATIC_URL }}telemeta/images/item.png" alt="item" style="vertical-align:middle" /> {% trans "Items" %} ({{ page_obj.start_index }} - {{ page_obj.end_index }} / {{ count }})
+</div>
+<div class="col-md-8">
+{% bootstrap_paginate page_obj range=10 show_first_last="True" %}
+</div>
+<div class="col-md-0">&nbsp;</div>
+</div>
 {% endblock %}
 
 {% block title_buttons %}
-    <a href="{% url "telemeta-items" %}" class="component_icon button icon_filter">{% trans "All" %}</a>
-    <a href="{% url "telemeta-items-unpublished" %}" class="component_icon button icon_filter">{% trans "Unpublished" %}</a>
-    <a href="{% url "telemeta-items-published" %}" class="component_icon button icon_filter">{% trans "Published" %}</a>
-    <a href="{% url "telemeta-items-sound" %}" class="component_icon button icon_filter">{% trans "Sounds" %}</a>
+
+<div class="btn-group">
+  <button type="button" class="btn btn-default dropdown-toggle icon-filter" data-toggle="dropdown">
+    <i class="icon-filter"></i> {% trans "Filters" %} <span class="caret"></span>
+  </button>
+  <ul class="dropdown-menu" role="menu">
+    <li><a href="{% url "telemeta-items" %}" class="">{% trans "All" %}</a></li>
+    <li><a href="{% url "telemeta-items-unpublished" %}">{% trans "Unpublished" %}</a></li>
+    <li><a href="{% url "telemeta-items-published" %}">{% trans "Published" %}</a></li>
+    <li><a href="{% url "telemeta-items-sound" %}">{% trans "Sounds" %}</a></li>
+  </ul>
+</div>
+
     {% if user.is_authenticated and perms.telemeta.add_mediaitem %}
       <a href="{% url "telemeta-item-add" %}" class="component_icon button icon_add">{% trans "Add" %}</a>
     {% endif %}
 {% endblock %}
 
 {% block content %}
-{% with object_list as items %}
 <div class="fullpage">
 {% include "telemeta/inc/mediaitem_list.html" %}
 </div>
-{% endwith %}
 {% endblock %}
index d3499e8cd7620b574cf8b77939e09bc2247ead61..8e202ed903358d0f38a6b5a15dbc982e8b713a61 100644 (file)
@@ -1,46 +1,66 @@
 {% extends "telemeta/resource_detail.html" %}
 {% load i18n %}
 {% load telemeta_utils %}
+{% load bootstrap3 %}
+
+
 
 {% block title %}
 <img src="{{ STATIC_URL }}telemeta/images/{{ type }}.png" style="vertical-align:middle" /> {{ type }} : {{ resource }}
 {% endblock %}
 {% block title_buttons %}
     <a href="{% url "telemeta-resource-detail" type resource.public_id %}" class="component_icon button icon_cancel">{% trans "Cancel" %}</a>
-    {% if perms.telemeta.add_mediacorpus or perms.telemeta.add_mediafonds %}
-    <a href="#" class="component_icon button icon_save" onclick="document.getElementById('_editForm').submit(); return false;">{% trans "Save" %}</a>
-    {% endif %}
 {% endblock %}
 
 {% block infos %}
-     <div class="infos">
-      <form method="post" id="_editForm" 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>
-            <tr><td class="error">{{ field.errors }}</td></tr>
-            {% if "children" in field.html_name %}
-            <td>{% trans field.label_tag %}:</td><td><div class="vscroll"> {{ field }}</div></td>
-            {% elif not 'description' == field.name %}
-             <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-resource-related_edit" type resource.public_id %}" class="component_icon button icon_edit">{% trans "Edit"%} {% trans "related media"%}</a></td>
-      </tr>
-       </table>
-        <div align="center" style="margin-top:3ex;">
+
+  <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-resource-detail" type resource.public_id %}" class="component_icon button icon_cancel">{% trans "Cancel" %}</a>
-         {% if perms.telemeta.add_mediacorpus or perms.telemeta.add_mediafonds %}
-         <a href="#" class="component_icon button icon_save" onclick="document.getElementById('_editForm').submit(); return false;">{% trans "Save" %}</a>
+         {% if perms.telemeta.change_mediacorpus or perms.telemeta.change_mediafonds %}
+          <input type="submit" value="Enregistrer" class="default" name="_save"/>
          {% endif %}
-        </div>
-      </form>
-     </div>
-{% endblock infos%}
+         {# <a href="#" class="component_icon button icon_save" id="submit_button">{% trans "Save" %}</a> #}
+  </div>
+
+   </form>
+  </div>
+
+
+{% endblock infos %}
+
 
 {% block delete %}
 {% endblock %}
index feda1ae15e8a2da4a89802447f1758edd531aeb4..740350ca428e25f5cbccb3096d1f228689e05615 100644 (file)
@@ -1,23 +1,30 @@
 {% extends "telemeta/base.html" %}
 {% load telemeta_utils %}
 {% load i18n %}
+{% load bootstrap_pagination %}
 
 {% block head_title %}{% trans type %} - {{ block.super }}{% endblock %}
 
 {% block title%}
-<img src="{{ STATIC_URL }}telemeta/images/{{ type }}.png" style="vertical-align:middle" /> {{ type|capitalize }}
+<div class='row'>
+<div class="col-md-4">
+<img src="{{ STATIC_URL }}telemeta/images/{{ type }}.png" style="vertical-align:middle" /> {{ all_resource }} {{ type|capitalize }} ({{ page_obj.start_index }} - {{ page_obj.end_index }} / {{ count }})
+</div>
+<div class="col-md-6">
+{% bootstrap_paginate page_obj range=10 show_first_last="True" %}
+</div>
+<div class="col-md-2">&nbsp;</div>
+</div>
 {% endblock %}
 
 {% block title_buttons %}
-    {% if perms.telemeta.add_mediacorpus or perms.telemeta.add_mediafonds %}
+    {% if perms.telemeta.add_mediacorpus or perms.telemeta.add_mediafonds or user.is_superuser or user.is_staff %}
       <a href="{% url "telemeta-resource-add" type %}" class="component_icon button icon_add">{% trans "Add" %}</a>
     {% endif %}
 {% endblock %}
 
 {% block content %}
-{% with object_list as resources and type as type %}
-<div class="fullpage">
-{% include "telemeta/inc/resource_list.html" %}
-</div>
-{% endwith %}
+       <div class="fullpage">
+               {% include "telemeta/inc/resource_list.html" %}
+       </div>
 {% endblock %}
index 8b0f337d1bf662e2fcd2a07e577004cb16cb61df..74cdf88dec5d193fe3108a3658d3be4742309801 100644 (file)
@@ -225,7 +225,6 @@ class CollectionPackageView(View):
         return super(CollectionPackageView, self).dispatch(*args, **kwargs)
 
 
-
 class CollectionListView(ListView):
 
     model = MediaCollection
@@ -233,6 +232,11 @@ class CollectionListView(ListView):
     paginate_by = 20
     queryset = MediaCollection.objects.enriched()
 
+    def get_context_data(self, **kwargs):
+        context = super(CollectionListView, self).get_context_data(**kwargs)
+        context['count'] = self.object_list.count()
+        return context
+
 
 class CollectionUnpublishedListView(CollectionListView):
 
index ccbbb4499fc34ca0121843d29029d13c23a0ecec..7a95d56151ff06e800269fee20b0f983c838999f 100644 (file)
@@ -618,6 +618,11 @@ class ItemListView(ListView):
     paginate_by = 20
     queryset = MediaItem.objects.enriched().order_by('code', 'old_code')
 
+    def get_context_data(self, **kwargs):
+        context = super(ItemListView, self).get_context_data(**kwargs)
+        context['count'] = self.object_list.count()
+        return context
+
 
 class ItemUnpublishedListView(ItemListView):
 
index 86cdffa272b8c6eb51c528ea1a172430c46a7f6e..cd36723dd395b8b4be4d09c3c9efd97013433873 100644 (file)
@@ -39,7 +39,6 @@ from telemeta.views.core import *
 from django.utils.translation import ugettext_lazy as _
 from django.forms.models import model_to_dict
 from django.views.generic.edit import DeletionMixin, BaseDeleteView
-from pure_pagination.mixins import PaginationMixin
 
 
 class ResourceView(object):
@@ -269,7 +268,7 @@ class ResourceSingleMixin(ResourceMixin):
         return context
 
 
-class ResourceListView(ResourceMixin, PaginationMixin, ListView):
+class ResourceListView(ResourceMixin, ListView):
 
     template_name = "telemeta/resource_list.html"
     paginate_by = 20
@@ -279,6 +278,10 @@ class ResourceListView(ResourceMixin, PaginationMixin, ListView):
         self.setup(self.type)
         return self.model.objects.all().order_by('code')
 
+    def get_context_data(self, **kwargs):
+        context = super(ResourceListView, self).get_context_data(**kwargs)
+        context['count'] = self.object_list.count()
+        return context
 
 class ResourceDetailView(ResourceSingleMixin, DetailView):