def get_mezzanine_menu_name(menu_id):
return settings.PAGE_MENU_TEMPLATES[int(menu_id)-1][1]
#return getattr(settings, 'PAGE_MENU_TEMPLATES', menu_id)
+
+@register.filter
+def get_type(objects, type):
+ objs = objects.filter(type=type)
+ if objs:
+ return objs[0]
+ return None
+
+@register.filter
+def in_category(objects, category):
+ return objects.filter(category=type)
from organization.magazine.models import Article, Topic, Brief
from organization.pages.models import Home
+
class HomeView(SlugMixin, ListView):
model = Home
context_object_name = 'home'
def get_queryset(self, **kwargs):
- return self.model.objects.published().latest("publish_date")
+ homes = self.model.objects.published()
+ if homes:
+ return homes.latest("publish_date")
+ return None
def get_context_data(self, **kwargs):
context = super(HomeView, self).get_context_data(**kwargs)
+{% load organization_tags i18n %}
<h2>{{ body.content_object.title }}<h2><br/>
<p>{{ body.content_object.description|slice:":500" }}</p>
-{% if body.content_object.featured_image %}
-<img src="{{ MEDIA_URL }}{{ body.content_object.featured_image }}" title="" /><br/>
-{% endif %}
+{% with body.content_object.images.all|get_type:'card' as image %}
+ {% if image %}
+ <img src="{{ MEDIA_URL }}{{ image.file }}" title="" /><br/>
+ {% endif %}
+{% endwith %}
<a href="{{ body.content_object.get_absolute_url }}" title="{{ body.content_object.title }}">{{ body.content_object.title }}</a><br/>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br/>
+{% load organization_tags i18n %}
<hr/>
<h1>Slider</h1>
<br/>
{% for slider in home.dynamiccontenthomeslider_set.all %}
- {% if slider.content_object.photo_slider %}
- <h2>{{ slider.content_object.title }}<h2><br/>
- <img src="{{ MEDIA_URL }}{{ slider.content_object.photo_slider }}" title="{{ slider.content_object.photo_slider_credits }}" /><br/>
- {{ slider.content_object.photo_slider_credits }}<br/>
- <a href="{{ slider.content_object.get_absolute_url }}" title="{{ slider.content_object.title }}">{{ slider.content_object.title }}</a><br/>
- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br/>
- {% endif %}
+ {% with slider.content_object.images.all|get_type:'slider' as image %}
+ {% if image %}
+ <h2>{{ slider.content_object.title }}<h2><br/>
+ <img src="{{ MEDIA_URL }}{{ image.file }}" title="{{ image.credits }}" /><br/>
+ {{ image.credits }}<br/>
+ <a href="{{ slider.content_object.get_absolute_url }}" title="{{ slider.content_object.title }}">{{ slider.content_object.title }}</a><br/>
+ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br/>
+ {% endif %}
+ {% endwith %}
{% endfor %}
<br/>
<hr/>