]> git.parisson.com Git - mezzo.git/commitdiff
mergin
authorEmilie <zawadzki@ircam.fr>
Thu, 13 Oct 2016 09:35:56 +0000 (11:35 +0200)
committerEmilie <zawadzki@ircam.fr>
Thu, 13 Oct 2016 09:35:56 +0000 (11:35 +0200)
12 files changed:
app/local_settings.py
app/organization/agenda/models.py
app/organization/core/views.py
app/organization/magazine/models.py
app/organization/media/models.py
app/organization/media/urls.py
app/organization/media/views.py
app/organization/network/models.py
app/organization/pages/models.py
app/organization/projects/models.py
app/templates/search_results.html
lib/mezzanine-agenda

index 285a237e1652e71350101311cb348bfaf22cdb37..1f1545349de2e78036fceb9badb895aa1738b148 100644 (file)
@@ -128,8 +128,14 @@ DASHBOARD_TAGS = ( ("mezzanine_tags.app_list",), (), ("mezzanine_tags.recent_act
 
 GRAPPELLI_ADMIN_TITLE = 'IRCAM Admin'
 
-SEARCH_MODEL_CHOICES = None # all objects
-SEARCH_MODEL_CHOICES = ('pages.Page',)
+SEARCH_MODEL_CHOICES = ('organization-pages.CustomPage',
+                        'organization-network.DepartmentPage',
+                        'organization-network.TeamPage',
+                        'organization-projects.ProjectTopicPage',
+                        'pages.Page',
+                        'organization-media.Audio',
+                        'organization-media.Video',
+                        'mezzanine_agenda.Event')
 SEARCH_PER_PAGE = 10
 MAX_PAGING_LINKS = 10
 
index 4972904e3476b74de06514e445acf934c4d7147c..5bcc9fa66ca6d7207325b6d94df3d2b46971a128 100644 (file)
@@ -62,8 +62,8 @@ class EventAudio(Audio):
     event = models.ForeignKey(Event, verbose_name=_('event'), related_name='audios', blank=True, null=True, on_delete=models.SET_NULL)
 
     class Meta:
-        verbose_name = _("audio")
-        verbose_name_plural = _("audios")
+        verbose_name = Audio._meta.verbose_name
+        verbose_name_plural = Audio._meta.verbose_name_plural
         order_with_respect_to = "event"
 
 
@@ -72,8 +72,8 @@ class EventVideo(Video):
     event = models.ForeignKey(Event, verbose_name=_('event'), related_name='videos', blank=True, null=True, on_delete=models.SET_NULL)
 
     class Meta:
-        verbose_name = _("video")
-        verbose_name_plural = _("videos")
+        verbose_name = Video._meta.verbose_name
+        verbose_name_plural = Video._meta.verbose_name_plural
         order_with_respect_to = "event"
 
 
index 8719a1656eec5a99c1162249621c8d4600091d1a..1371806772bda9bc3b54009829a10e8532b028e5 100644 (file)
@@ -49,29 +49,39 @@ class CustomSearchView(TemplateView):
             search_type = search_model._meta.verbose_name_plural.capitalize()
 
         results = search_model.objects.search(query, for_user=request.user)
-
+        print("----------------------------")
+        print(results)
+        print("----------------------------")
         # count objects
         filter_dict = dict()
         for result in results:
-            print('---------------------------')
-            parent_class = result._meta.get_parent_list()[0]
-            print(parent_class)
-            print(parent_class.__name__)
-            # print(parent_class == "<class 'mezzanine.pages.models.Page'>")
-            print('---------------------------')
-
-            if result._meta.get_parent_list() == 'mezzanine.pages.models.Page':
-                classname = 'Page'
-            else :
-                classname = result.__class__.__name__
+
+            classname = result.__class__.__name__
+            app_label = result._meta.app_label
+
+            # aggregate all Page types : CustomPage, TeamPage, Topic etc...
+            if result._meta.get_parent_list() :
+                parent_class = result._meta.get_parent_list()[0]
+
+                if parent_class.__name__ == 'Page':
+                    classname = parent_class.__name__
+                    app_label = parent_class._meta.app_label
+                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
 
             if classname in filter_dict:
                 filter_dict[classname]['count'] += 1
             else:
                 filter_dict[classname] = {'count' : 1}
-                filter_dict[classname].update({'app_label' : result._meta.app_label})
+                filter_dict[classname].update({'verbose_name' : classname})
+                filter_dict[classname].update({'app_label' : app_label})
+
+
 
-        print(filter_dict)
         # get url param
         current_query = QueryDict(mutable=True)
         current_query = request.GET.copy()
index 90dba92259bc2cee24456366fca496af67961062..1f2ce07fc1098730937b0b49479bf1632bdc46c7 100644 (file)
@@ -44,13 +44,21 @@ class ArticleAudio(Audio):
 
     article = models.ForeignKey(Article, verbose_name=_('article'), related_name='audios', blank=True, null=True, on_delete=models.SET_NULL)
 
+    class Meta:
+        verbose_name = Audio._meta.verbose_name
+        verbose_name_plural = Audio._meta.verbose_name_plural
+
 
 class ArticleVideo(Video):
 
     article = models.ForeignKey(Article, verbose_name=_('article'), related_name='videos', blank=True, null=True, on_delete=models.SET_NULL)
 
+    class Meta:
+        verbose_name = Video._meta.verbose_name
+        verbose_name_plural = Video._meta.verbose_name_plural
+
 
-class Brief(Displayable, RichText): #Orderable
+class Brief(Displayable, RichText):
 
     text_button = models.CharField(blank=True, max_length=150, null=False, verbose_name=_('text button'))
     external_content = models.URLField(blank=True, max_length=1000, null=False, verbose_name=_('external content'))
index 35fcda665e701578916743a629ab7f80c8e91506..496a7412a31c7d9fb3247ed029455de4c8230bee 100644 (file)
@@ -26,7 +26,7 @@ class Media(Displayable):
     created_at = models.DateTimeField(auto_now=True)
 
     # objects = SearchableManager()
-    search_fields = ("title",)
+    search_fields = ("title",)
 
     class Meta:
         abstract = True
@@ -65,11 +65,12 @@ class Audio(Media):
     category = models.ForeignKey('MediaCategory', verbose_name=_('category'), related_name='audios', blank=True, null=True, on_delete=models.SET_NULL)
 
     class Meta:
-        verbose_name = _('audio')
+        verbose_name = _('Audio')
+        verbose_name_plural = _('Audios')
         ordering = ('-created_at',)
 
     def get_absolute_url(self):
-        return reverse("festival-audio-detail", kwargs={"slug": self.slug})
+        return reverse("audio-detail", kwargs={"slug": self.slug})
 
 
 class Video(Media):
@@ -80,11 +81,12 @@ class Video(Media):
     category = models.ForeignKey('MediaCategory', verbose_name=_('category'), related_name='videos', blank=True, null=True, on_delete=models.SET_NULL)
 
     class Meta:
-        verbose_name = _('video')
+        verbose_name = _('Video')
+        verbose_name_plural = _('Videos')
         ordering = ('-created_at',)
 
     def get_absolute_url(self):
-        return reverse("festival-video-detail", kwargs={"slug": self.slug})
+        return reverse("video-detail", kwargs={"slug": self.slug})
 
 
 class MediaCategory(Slugged, Description):
index 2e5763d538c524520b37c29d83fae2dfd891e50e..a090a860959b82f608541b244cc308a29d03a1d0 100644 (file)
@@ -13,9 +13,7 @@ from organization.media.views import *
 urlpatterns = [
     url(r'^media-list/$', MediaListView.as_view(), name="media-list"),
     url(r'^videos/$', VideoListView.as_view(), name="festival-video-list"),
-    url(r'^videos/detail/(?P<slug>.*)/$', VideoDetailView.as_view(), name="festival-video-detail"),
-    url(r'^videos/category/(?P<slug>.*)/$', VideoListCategoryView.as_view(), name="festival-video-list-category"),
-    url(r'^audios/detail/(?P<slug>.*)/$', AudioDetailView.as_view(), name="festival-audio-detail"),
-    url(r'^audios/category/(?P<slug>.*)/$', AudioListCategoryView.as_view(), name="festival-audio-list-category"),
-
+    url(r'^audios/detail/(?P<slug>.*)/$', AudioDetailView.as_view(), name="audio-detail"),
+    url(r'^videos/detail/(?P<slug>.*)/$', VideoDetailView.as_view(), name="video-detail"),
+    url(r'^videos/category/(?P<slug>.*)/$', VideoListCategoryView.as_view(), name="video-list-category"),
 ]
index 4ea5af32d8b765a0a433211f8998e3eac9e7ce34..ff1697e7f4c85c130091b89dac7736e725421c10 100644 (file)
@@ -9,6 +9,17 @@ from organization.agenda.models import EventVideo
 from organization.magazine.models import Article, Topic, Brief, ArticleVideo
 
 
+class AudioDetailView(SlugMixin, DetailView):
+
+    model = Audio
+    template_name='festival/audio_detail.html'
+    context_object_name = 'audio'
+
+    def get_context_data(self, **kwargs):
+        context = super(AudioDetailView, self).get_context_data(**kwargs)
+        return context
+
+
 class VideoListView(ListView):
 
     model = Video
index b7028907a4767cb276c4c69da54fe27f9aa5a5e4..5a5b7d7d620180076c40e616efa355b39fdb4b00 100644 (file)
@@ -129,11 +129,19 @@ class OrganizationAudio(Audio):
 
     organization = models.ForeignKey(Organization, verbose_name=_('organization'), related_name='audios', blank=True, null=True, on_delete=models.SET_NULL)
 
+    class Meta:
+        verbose_name = Audio._meta.verbose_name
+        verbose_name_plural = Audio._meta.verbose_name_plural
+
 
 class OrganizationVideo(Video):
 
     organization = models.ForeignKey(Organization, verbose_name=_('organization'), related_name='videos', blank=True, null=True, on_delete=models.SET_NULL)
 
+    class Meta:
+        verbose_name = Video._meta.verbose_name
+        verbose_name_plural = Video._meta.verbose_name_plural
+
 
 class OrganizationLink(Link):
 
@@ -277,11 +285,19 @@ class PersonAudio(Audio):
 
     person = models.ForeignKey(Person, verbose_name=_('person'), related_name='audios', blank=True, null=True, on_delete=models.SET_NULL)
 
+    class Meta:
+        verbose_name = Audio._meta.verbose_name
+        verbose_name_plural = Audio._meta.verbose_name_plural
+
 
 class PersonVideo(Video):
 
     person = models.ForeignKey(Person, verbose_name=_('person'), related_name='videos', blank=True, null=True, on_delete=models.SET_NULL)
 
+    class Meta:
+        verbose_name = Video._meta.verbose_name
+        verbose_name_plural = Video._meta.verbose_name_plural
+
 
 class PersonLink(Link):
 
index 02047b1928df026ea6d1a50ffebaba5f3a2fd8d9..387f92a6da49cd3977fad0dbdba83c3982492b58 100644 (file)
@@ -38,8 +38,8 @@ class PageAudio(Audio):
     page = models.ForeignKey(Page, verbose_name=_('page'), related_name='audios', blank=True, null=True, on_delete=models.SET_NULL)
 
     class Meta:
-        verbose_name = _("audio")
-        verbose_name_plural = _("audios")
+        verbose_name = Audio._meta.verbose_name
+        verbose_name_plural = Audio._meta.verbose_name_plural
         order_with_respect_to = "page"
 
 
@@ -48,8 +48,8 @@ class PageVideo(Video):
     page = models.ForeignKey(Page, verbose_name=_('page'), related_name='videos', blank=True, null=True, on_delete=models.SET_NULL)
 
     class Meta:
-        verbose_name = _("video")
-        verbose_name_plural = _("videos")
+        verbose_name = Video._meta.verbose_name
+        verbose_name_plural = Video._meta.verbose_name_plural
         order_with_respect_to = "page"
 
 
index 5666539b0c3e58b6664f09c65788c9309b1190d9..90ae33d74a6d2e98e96afa132475490d27925ee8 100644 (file)
@@ -83,11 +83,19 @@ class ProjectAudio(Audio):
 
     project = models.ForeignKey(Project, verbose_name=_('project'), related_name='audios', blank=True, null=True, on_delete=models.SET_NULL)
 
+    class Meta:
+        verbose_name = Audio._meta.verbose_name
+        verbose_name_plural = Audio._meta.verbose_name_plural
+        
 
 class ProjectVideo(Video):
 
     project = models.ForeignKey(Project, verbose_name=_('project'), related_name='videos', blank=True, null=True, on_delete=models.SET_NULL)
 
+    class Meta:
+        verbose_name = Video._meta.verbose_name
+        verbose_name_plural = Video._meta.verbose_name_plural
+
 
 class ProjectLink(Link):
 
index cf6843a5e7787eba08fc642a3eab2d5606bcdbb1..a6c1167348367a8df3da3da1a6071f2516f935f8 100644 (file)
@@ -40,7 +40,7 @@
         <p>
             <h4>Filter:</h4>
             {% for key,value in filter_dict.items %}
-                <a href="{{ value.url }}" title="{{ key }}">{{ key }} {{ value.count }}</a><br>
+                <a href="{{ value.url }}" title="{{ value.verbose_name }}">{{ value.verbose_name }} {{ value.count }}</a><br>
             {% endfor %}
             {% if cancel_filter_url %}
                 <a href="{{ cancel_filter_url }}" title="">Cancel filter</a>
         </p>
         {% for result in results.object_list %}
         {% with result.get_absolute_url as result_url %}
-
+            {{ result.periods.date_from }}{{ result.periods.date_to }}
             <h5>
-                {{ forloop.counter0|add:results.start_index }})
-                 - {{ result|classname }} -
                 {% if result_url %}
                     <a href="{{ result_url }}">{{ result }}</a>
                 {% else %}
@@ -59,7 +57,7 @@
                 {% endif %}
             </h5>
             {% if result.description != result|stringformat:"s" %}
-                <p>{{ result.description|truncatewords_html:20|safe }}</p>
+                <p>{{ result.description|truncatewords_html:200|safe }}</p>
             {% endif %}
             {% if result_url %}
                 <a href="{{ result_url }}">{% trans "read more" %}</a>
index 04b66f1604f971ce3b58dfa656bdadc2e57a8620..5a92509d2d9b0e5b964faa5a74328ee977c44cc7 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 04b66f1604f971ce3b58dfa656bdadc2e57a8620
+Subproject commit 5a92509d2d9b0e5b964faa5a74328ee977c44cc7