From 72af7c174a66cd293fe4f1ae495c93cdcc98756d Mon Sep 17 00:00:00 2001 From: Emilie Date: Fri, 23 Sep 2016 11:33:32 +0200 Subject: [PATCH] Home : Add events --- app/organization/pages/forms.py | 4 +++- app/organization/pages/views.py | 15 +++++++-------- app/templates/home/inc/generic_card.html | 15 +++++++++++++-- app/templates/home/inc/slider.html | 18 +++++++++++++++++- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/app/organization/pages/forms.py b/app/organization/pages/forms.py index 77816724..69247ffb 100644 --- a/app/organization/pages/forms.py +++ b/app/organization/pages/forms.py @@ -10,7 +10,7 @@ from mezzanine.core.models import Orderable from organization.magazine.models import Article, Topic, Brief from organization.pages.models import CustomPage from organization.pages.models import DynamicContentHomeSlider, DynamicContentHomeBody - +from organization.agenda.models import Event class DynamicContentHomeSliderForm(autocomplete.FutureModelForm): @@ -18,6 +18,7 @@ class DynamicContentHomeSliderForm(autocomplete.FutureModelForm): queryset=autocomplete.QuerySetSequence( Article.objects.all(), CustomPage.objects.all(), + Event.objects.all() ), required=False, widget=dal_select2_queryset_sequence.widgets.QuerySetSequenceSelect2('dynamic-content-home-slider'), @@ -35,6 +36,7 @@ class DynamicContentHomeBodyForm(autocomplete.FutureModelForm): Article.objects.all(), CustomPage.objects.all(), Brief.objects.all(), + Event.objects.all() ), required=False, widget=dal_select2_queryset_sequence.widgets.QuerySetSequenceSelect2('dynamic-content-home-body'), diff --git a/app/organization/pages/views.py b/app/organization/pages/views.py index eb14813d..feb8c47e 100644 --- a/app/organization/pages/views.py +++ b/app/organization/pages/views.py @@ -6,12 +6,11 @@ from dal import autocomplete from dal_select2_queryset_sequence.views import Select2QuerySetSequenceView from django.core.urlresolvers import reverse, reverse_lazy from django.utils.translation import ugettext_lazy as _ -# from mezzanine_agenda.models import Event from organization.pages.models import CustomPage from organization.core.views import SlugMixin from organization.magazine.models import Article, Topic, Brief from organization.pages.models import Home - +from organization.agenda.models import Event class HomeView(SlugMixin, ListView): @@ -38,14 +37,14 @@ class DynamicContentHomeSliderView(Select2QuerySetSequenceView): articles = Article.objects.all() custompage = CustomPage.objects.all() - # events = Event.objects.all() + events = Event.objects.all() if self.q: articles = articles.filter(title__icontains=self.q) custompage = custompage.filter(title__icontains=self.q) - # events = events.filter(title__icontains=self.q) + events = events.filter(title__icontains=self.q) - qs = autocomplete.QuerySetSequence(articles, custompage ) #, events + qs = autocomplete.QuerySetSequence(articles, custompage, events) if self.q: # This would apply the filter on all the querysets @@ -64,16 +63,16 @@ class DynamicContentHomeBodyView(Select2QuerySetSequenceView): articles = Article.objects.all() custompage = CustomPage.objects.all() - # events = Event.objects.all() + events = Event.objects.all() briefs = Brief.objects.all() if self.q: articles = articles.filter(title__icontains=self.q) custompage = custompage.filter(title__icontains=self.q) - # events = events.filter(title__icontains=self.q) + events = events.filter(title__icontains=self.q) briefs = briefs.filter(title__icontains=self.q) - qs = autocomplete.QuerySetSequence(articles, custompage, briefs) #, events + qs = autocomplete.QuerySetSequence(articles, custompage, briefs, events) if self.q: # This would apply the filter on all the querysets diff --git a/app/templates/home/inc/generic_card.html b/app/templates/home/inc/generic_card.html index 3594b48f..7a03c0b7 100644 --- a/app/templates/home/inc/generic_card.html +++ b/app/templates/home/inc/generic_card.html @@ -21,7 +21,7 @@ {% endif %} {% elif body.content_type.model == 'event' %} - + {% trans 'Event' %} {% endif %} @@ -36,7 +36,18 @@ {{ category }} {% endfor %} {% elif body.content_type.model == 'event' %} - + {% if body.content_object.start %} + {% if body.content_object.end %} + {% trans "From" %} + {% endif %} + {{ body.content_object.start }} + {% if body.content_object.end %} + {% trans "to" %} {{ body.content_object.end }} + {% endif %} + {% endif %} + {% if body.content_object.location %} + {{ body.content_object.location }} + {% endif %} {% endif %}
diff --git a/app/templates/home/inc/slider.html b/app/templates/home/inc/slider.html index 4383b0fa..3460f5d8 100644 --- a/app/templates/home/inc/slider.html +++ b/app/templates/home/inc/slider.html @@ -1,5 +1,4 @@ {% load i18n pages_tags mezzanine_tags media_tags organization_tags %} -
    {% for slider in home.dynamiccontenthomeslider_set.all %} @@ -17,15 +16,32 @@ {{ slider.content_object.department.name }}
{% endif %} + {% if slider.content_type.model == 'article' %}
{% trans 'News' %}
+ {% elif slider.content_type.model == 'event' %} +
+ {% trans 'Event' %} +
+ {% endif %}

{{ slider.content_object.title }}

{{ slider.content_object.sub_title }}
+
+ {% if slider.content_object.start %} + {% if slider.content_object.end %} + {% trans "From" %} + {% endif %} + {{ slider.content_object.start }} + {% if slider.content_object.end %} + {% trans "to" %} {{ slider.content_object.end }} + {% endif %} + {% endif %} +
{{ slider.content_object.description|richtext_filters|safe|truncatechars_html:200 }}
-- 2.39.5