]> git.parisson.com Git - mezzo.git/commitdiff
Search : adapt to playlist
authorEmilie <zawadzki@ircam.fr>
Fri, 14 Oct 2016 15:59:27 +0000 (17:59 +0200)
committerEmilie <zawadzki@ircam.fr>
Fri, 14 Oct 2016 15:59:27 +0000 (17:59 +0200)
app/local_settings.py
app/organization/core/views.py
app/templates/media/inc/playlist_search.html [new file with mode: 0644]
app/templates/search_results.html

index b1390f8bce9e09395751bac45a42a68099c9a31f..466df4458f26b450d4d7fa0c2c4d9b9fd768c66b 100644 (file)
@@ -132,7 +132,7 @@ SEARCH_MODEL_CHOICES = ('organization-pages.CustomPage',
                         'organization-network.TeamPage',
                         'organization-projects.ProjectTopicPage',
                         'pages.Page',
-                        'organization-media.Media',
+                        'organization-media.Playlist',
                         'mezzanine_agenda.Event')
 
 
index 2b7bda422805d36233ef64e3de02cf3023cc74a9..08084b292dec8d5bb972c6228613ebf06e5ecc1b 100644 (file)
@@ -56,17 +56,12 @@ class CustomSearchView(TemplateView):
             # aggregate all Page types : CustomPage, TeamPage, Topic etc...
             if result._meta.get_parent_list() :
                 parent_class = result._meta.get_parent_list()[0]
-
                 if full_classname in settings.PAGES_MODELS:
                     classname = "CustomPage"
                     verbose_name = "Page"
                     app_label = "organization-pages"
-                elif "Video" in parent_class.__name__:
-                    classname = "Video"
-                    app_label = parent_class._meta.app_label
-                elif "Audio" in parent_class.__name__:
-                    classname = "Audio"
-                    app_label = parent_class._meta.app_label
+            elif classname == "Playlist":
+                verbose_name = "Media"
 
             if classname in filter_dict:
                 filter_dict[classname]['count'] += 1
diff --git a/app/templates/media/inc/playlist_search.html b/app/templates/media/inc/playlist_search.html
new file mode 100644 (file)
index 0000000..0ab4d8f
--- /dev/null
@@ -0,0 +1,26 @@
+{% load i18n mezzanine_tags organization_tags %}
+{% with playlist.get_absolute_url as playlist_url %}
+    {% if playlist.medias.first.media.poster_url %}
+        <!-- url of the media is distant. We can't generate back side thumbnail. Do it with css pliz -->
+        <img src="{{playlist.medias.first.media.poster_urlĀ }}" width="200" height="150">
+    {% else %}
+        <!--placeholder picture-->
+    {% endif %}
+
+    {{ playlist.type }}
+
+    <h5>
+        {% if playlist_url %}
+            <a href="{{ playlist_url }}">{{ playlist.title }}</a>
+        {% else %}
+            {{ playlist }}
+        {% endif %}
+    </h5>
+    {% if playlist.description != playlist|stringformat:"s" %}
+        <p>{{ playlist.description|truncatewords_html:200|safe }}</p>
+    {% endif %}
+    {% if playlist_url %}
+        <a href="{{ playlist_url }}">{% trans "read more" %}</a>
+    {% endif %}
+    <br>
+{% endwith %}
index b211c49048b465f86db7b3100e8d2a361c4f6832..8603cf683a048bc075bd2a1c74e20a26359da6df 100644 (file)
             {% endif %}
         </p>
         {% for result in results.object_list %}
+            {{ result|classname }}
             {% if result|classname == 'Event' %}
                 {% with result as event %}
                     {% include 'agenda/includes/event_search.html' %}
                 {% endwith %}
-            {% elif result|classname == 'Audio' %}
-                {% with result as audio %}
-                    {% include 'media/audio/inc/audio_search.html' %}
-                {% endwith %}
-            {% elif result|classname == 'Video' %}
-                {% with result as video %}
-                    {% include 'media/video/inc/video_search.html' %}
+            {% elif result|classname == 'Playlist' %}
+                {% with result as playlist %}
+                    {% include 'media/inc/playlist_search.html' %}
                 {% endwith %}
             {% else %}
                 {% with result as page %}