cleanup templates, reuse more blocks
This commit is contained in:
parent
068d9f4201
commit
f25482a3e1
19
content/templates/content.html
Normal file
19
content/templates/content.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% include "edit.html" %}
|
||||
<div class="large-8 medium-8 columns special-column">
|
||||
{% if content.image %}
|
||||
<img src="{{ content.image_url }}">
|
||||
{% endif %}
|
||||
<div class="index-text">
|
||||
<h4><a href="{{ content.get_absolute_url }}" class="big-title">{{content.title}}</a></h4>
|
||||
<p> {{content.formatted_header|safe}} </p>
|
||||
<p> {{content.formatted_body|safe}} </p>
|
||||
{% include "opt.html" %}
|
||||
{% include "links.html" %}
|
||||
{% include "gallery.html" with gallery=content.gallery %}
|
||||
</div>
|
||||
</div>
|
||||
{% include "latest_content.html" %}
|
||||
{% endblock %}
|
|
@ -1,54 +1,19 @@
|
|||
|
||||
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% include "edit.html" with content=events %}
|
||||
|
||||
<div class="large-8 medium-8 columns special-column">
|
||||
{% if events.image %}
|
||||
<img src="{{events.image_url}}">
|
||||
{% endif %}
|
||||
<div class="index-text">
|
||||
<h4><a href="{{ events.get_absolute_url }}/" class="big-title">{{events.title}} </a></h4>
|
||||
<p> {{events.formatted_header|safe}} </p>
|
||||
<p> {{events.formatted_body|safe}} </p>
|
||||
{% include "opt.html" with content=events %}
|
||||
{% include "links.html" with content=events %}
|
||||
{% include "gallery.html" with gallery=gallery %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="large-4 medium-4 columns">
|
||||
{% include "related.html" with related=events.children.all %}
|
||||
<h4 class="sidebar-h4">Events </h4>
|
||||
<div class="row">
|
||||
|
||||
{% for events in latest_content_list %}
|
||||
|
||||
<div class="row right-items">
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ events.get_absolute_url }}/"> <img src="{{ events.image_url }}"> </a>
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ events.get_absolute_url }}/" class="sidebar-title" >{{ events.title }}</a>
|
||||
<h6 class="sidebar-date">
|
||||
<font color="#ef4e5c">
|
||||
<b> {{ events.datestart }} {% if events.dateend %} - {{events.dateend}} {% endif %} </b>
|
||||
</font>
|
||||
{% if events.place %}<br/>{{events.place}}{% endif%}
|
||||
</h6>
|
||||
<p> {{ events.formatted_teaser }} </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% endfor %}
|
||||
<a href="{% url 'events_list' %}">more</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="large-8 medium-8 columns special-column">
|
||||
{% if events.image %}
|
||||
<img src="{{events.image_url}}">
|
||||
{% endif %}
|
||||
<div class="index-text">
|
||||
<h4><a href="{{ events.get_absolute_url }}/" class="big-title">{{events.title}} </a></h4>
|
||||
<p> {{events.formatted_header|safe}} </p>
|
||||
<p> {{events.formatted_body|safe}} </p>
|
||||
{% include "opt.html" with content=events %}
|
||||
{% include "links.html" with content=events %}
|
||||
{% include "gallery.html" with gallery=gallery %}
|
||||
</div>
|
||||
</div>
|
||||
{% include "latest_content.html" with content=events %}
|
||||
{% endblock %}
|
||||
|
|
18
content/templates/latest_content.html
Normal file
18
content/templates/latest_content.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
{% if latest_content_list %}
|
||||
<div class="large-4 medium-4 columns">
|
||||
{% include "related.html" with related=content.children.all %}
|
||||
<h4 class="sidebar-h4">{{section}}</h4>
|
||||
<div class="row">
|
||||
{% for content in latest_content_list %}
|
||||
{% include "preview.html" with content=content %}
|
||||
{% endfor %}
|
||||
{% with section|lower|add:'_list' as section_list %}
|
||||
{% if has_more_content %}
|
||||
<a href="{% url section_list %}">more</a>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>No content.</p>
|
||||
{% endif %}
|
|
@ -1,21 +1,19 @@
|
|||
<div class="row">
|
||||
<div class="row right-items">
|
||||
<div class="small-6 columns">
|
||||
{% if content.image_url %}
|
||||
<a href="{{ content.get_absolute_url }}"><img src="{{ content.image_url }}"></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ content.get_absolute_url }}" class="sidebar-title"> {{content.title}} </a>
|
||||
{% if content.type.name == 'events' %}
|
||||
<h6 class="sidebar-date">
|
||||
<font color="#ef4e5c">
|
||||
<b> {{ content.datestart }} {% if content.dateend %} - {{content.dateend}} {% endif %} </b>
|
||||
</font>
|
||||
{% if content.place %}<br/>{{content.place}}{% endif%}
|
||||
</h6>
|
||||
{% endif %}
|
||||
<p> {{ content.formatted_teaser }} </p>
|
||||
</div>
|
||||
<div class="row right-items">
|
||||
<div class="small-6 columns">
|
||||
{% if content.image_url %}
|
||||
<a href="{{ content.get_absolute_url }}"><img src="{{ content.image_url }}"></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ content.get_absolute_url }}" class="sidebar-title"> {{content.title}} </a>
|
||||
{% if content.type.name == 'events' %}
|
||||
<h6 class="sidebar-date">
|
||||
<font color="#ef4e5c">
|
||||
<b> {{ content.datestart }} {% if content.dateend %} - {{content.dateend}} {% endif %} </b>
|
||||
</font>
|
||||
{% if content.place %}<br/>{{content.place}}{% endif%}
|
||||
</h6>
|
||||
{% endif %}
|
||||
<p> {{ content.formatted_teaser }} </p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,47 +1,19 @@
|
|||
|
||||
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% include "edit.html" with content=projects %}
|
||||
|
||||
<div class="large-8 medium-8 columns special-column">
|
||||
{% if projects.image %}
|
||||
<img src="{{ projects.image_url }}">
|
||||
{% endif %}
|
||||
<div class="index-text">
|
||||
<h4><a href="{{ projects.get_absolute_url }}/" class="big-title">{{projects.title}} </a></h4>
|
||||
<p> {{projects.formatted_header|safe}} </p>
|
||||
<p> {{projects.formatted_body|safe}} </p>
|
||||
{% include "opt.html" with content=projects %}
|
||||
{% include "links.html" with content=projects %}
|
||||
{% include "gallery.html" with gallery=gallery %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if latest_content_list %}
|
||||
|
||||
<div class="large-4 medium-4 columns">
|
||||
{% include "related.html" with related=projects.children.all %}
|
||||
<h4 class="sidebar-h4">Projects </h4>
|
||||
<div class="row">
|
||||
|
||||
{% for projects in latest_content_list %}
|
||||
<div class="row right-items">
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ projects.get_absolute_url }}"> <img src="{{ projects.image_url }}"> </a>
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ projects.get_absolute_url }}" class="sidebar-title">{{ projects.title }}</a>
|
||||
<p> {{projects.formatted_teaser}} </p>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>No projects.</p>
|
||||
<div class="large-8 medium-8 columns special-column">
|
||||
{% if projects.image %}
|
||||
<img src="{{ projects.image_url }}">
|
||||
{% endif %}
|
||||
<a href="{% url 'projects_list' %}">more</a>
|
||||
<div class="index-text">
|
||||
<h4><a href="{{ projects.get_absolute_url }}/" class="big-title">{{projects.title}} </a></h4>
|
||||
<p> {{projects.formatted_header|safe}} </p>
|
||||
<p> {{projects.formatted_body|safe}} </p>
|
||||
{% include "opt.html" with content=projects %}
|
||||
{% include "links.html" with content=projects %}
|
||||
{% include "gallery.html" with gallery=gallery %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "latest_content.html" with content=texts %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{% if related %}
|
||||
<h4 class="sidebar-h4"> Related </h4>
|
||||
{% for content in related %}
|
||||
{% include "preview.html" %}
|
||||
<div class="row">
|
||||
{% include "preview.html" %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<br>
|
||||
<br>
|
||||
|
|
|
@ -22,69 +22,24 @@
|
|||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
{% elif row.type.name == 'events' %}
|
||||
<div class="row results">
|
||||
<div class="small-4 small-offset-2 columns">
|
||||
{% if row.image_url %}
|
||||
<a href="{{ row.get_absolute_url }}"> <img src="{{ row.image_url }}"> </a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="small-4 end columns">
|
||||
<a href="{{ row.get_absolute_url }}" class="sidebar-title">{{ row.title }}</a>
|
||||
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ row.datestart }} {% if row.dateend %} - {{row.dateend}} {% endif %} </b></font>
|
||||
{% if row.place %}<br/> {{row.place}} {% endif%}</h6>
|
||||
<p> {{row.formatted_teaser}} </p>
|
||||
<a href="{{ row.get_absolute_url }}">read more</a> </p>
|
||||
</div>
|
||||
</div>
|
||||
{% elif row.type.name == 'projects' %}
|
||||
<div class="row results">
|
||||
<div class="small-4 small-offset-2 columns">
|
||||
{% if row.image_url %}
|
||||
<a href="{{ row.get_absolute_url }}"> <img src="{{ row.image_url }}"> </a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="small-4 end columns">
|
||||
<a href="{{ row.get_absolute_url }}" class="sidebar-title">{{ row.title }}</a>
|
||||
<p> {{row.formatted_teaser}} </p>
|
||||
<a href="{{ row.get_absolute_url }}">read more</a> </p>
|
||||
</div>
|
||||
</div>
|
||||
{% elif row.type.name == 'works' %}
|
||||
<div class="row results">
|
||||
<div class="small-4 small-offset-2 columns">
|
||||
{% if row.image_url %}
|
||||
<a href="{{ row.get_absolute_url }}"> <img src="{{ row.image_url }}"> </a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="small-4 end columns">
|
||||
<a href="{{ row.get_absolute_url }}" class="sidebar-title">{{ row.title }}</a>
|
||||
<p> {{row.formatted_teaser}} </p>
|
||||
<a href="{{ row.get_absolute_url }}">read more</a> </p>
|
||||
</div>
|
||||
</div>
|
||||
{% elif row.type.name == 'texts' %}
|
||||
<div class="row results">
|
||||
<div class="small-4 small-offset-2 columns">
|
||||
{% if row.image_url %}
|
||||
<a href="{{ row.get_absolute_url }}"> <img src="{{ row.image_url }}"> </a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="small-4 end columns">
|
||||
<a href="{{ row.get_absolute_url }}" class="sidebar-title">{{ row.title }}</a>
|
||||
<p> {{row.formatted_teaser}} </p>
|
||||
<a href="{{ row.get_absolute_url }}">read more</a> </p>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
{% if request.user.is_staff %}
|
||||
<div class="row">
|
||||
<div class="row results">
|
||||
<div class="small-4 small-offset-2 columns">
|
||||
Add view for content type: {{row.type}}
|
||||
{% if row.image_url %}
|
||||
<a href="{{ row.get_absolute_url }}"> <img src="{{ row.image_url }}"> </a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="small-4 end columns">
|
||||
<a href="{{ row.get_absolute_url }}" class="sidebar-title">{{ row.title }}</a>
|
||||
{% if row.type.name == 'events' %}
|
||||
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ row.datestart }} {% if row.dateend %} - {{row.dateend}} {% endif %} </b></font>
|
||||
{% if row.place %}<br/> {{row.place}} {% endif%}</h6>
|
||||
{% endif %}
|
||||
<p> {{row.formatted_teaser}} </p>
|
||||
<a href="{{ row.get_absolute_url }}">read more</a> </p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<br>
|
||||
<br>
|
||||
|
|
|
@ -5,20 +5,20 @@
|
|||
|
||||
<div class="large-4 medium-4 columns">
|
||||
<h4 class="sidebar-h4"> {{ section }} </h4>
|
||||
<div class="row">
|
||||
{% for content in content %}
|
||||
<div class="row right-items">
|
||||
<div class="row">
|
||||
{% for content in content %}
|
||||
<div class="row right-items">
|
||||
{% if content.image_url %}
|
||||
<div class="small-6 columns">
|
||||
<img src="{{ content.image_url }}">
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
<img src="{{ content.image_url }}">
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ content.get_absolute_url }}/" class="sidebar-title">{{ content.title }}</a>
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ content.get_absolute_url }}/" class="sidebar-title">{{ content.title }}</a>
|
||||
<p> {{content.formatted_teaser}} </p>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<a href="index/">more</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,58 +2,16 @@
|
|||
|
||||
{% block content %}
|
||||
{% include "edit.html" with content=texts %}
|
||||
|
||||
<div class="large-8 medium-8 columns special-column">
|
||||
{% if texts.image %}
|
||||
<img src="{{ texts.image_url }}">
|
||||
{% endif %}
|
||||
<div class="index-text">
|
||||
<h4><a href="{{ texts.get_absolute_url }}/" class="big-title">{{texts.title}} </a></h4>
|
||||
<p> {{texts.formatted_header|safe}} </p>
|
||||
<p> {{texts.formatted_body|safe}} </p>
|
||||
{% include "opt.html" with content=texts %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if latest_content_list %}
|
||||
|
||||
<div class="large-4 medium-4 columns">
|
||||
{% if texts.children.all %}
|
||||
<h4 class="sidebar-h4"> Related </h4>
|
||||
{% for child in texts.children.all %}
|
||||
<div class="row related-row">
|
||||
{% if child.image %}
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ child.get_absolute_url }}"> <img src="{{ child.image_url }}"> </a>
|
||||
</div>
|
||||
<div class="large-8 medium-8 columns special-column">
|
||||
{% if texts.image %}
|
||||
<img src="{{ texts.image_url }}">
|
||||
{% endif %}
|
||||
<div class="small-6 columns">
|
||||
<h6><a href="{{ child.get_absolute_url }}" class="sidebar-title"> {{child}} </a> </h6>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<h4 class="sidebar-h4"> Texts </h4>
|
||||
<div class="row">
|
||||
|
||||
{% for texts in latest_content_list %}
|
||||
<div class="row right-items">
|
||||
{% if texts.image %}
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ texts.get_absolute_url }}"> <img src="{{ texts.image_url }}"></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ texts.get_absolute_url }}" class="sidebar-title">{{ texts.title }}</a>
|
||||
<p> {{ texts.formatted_teaser }} </p>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>No texts.</p>
|
||||
{% endif %}
|
||||
<a href="{% url 'texts_list' %}">more</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="index-text">
|
||||
<h4><a href="{{ texts.get_absolute_url }}/" class="big-title">{{texts.title}} </a></h4>
|
||||
<p> {{texts.formatted_header|safe}} </p>
|
||||
<p> {{texts.formatted_body|safe}} </p>
|
||||
{% include "opt.html" with content=texts %}
|
||||
</div>
|
||||
</div>
|
||||
{% include "latest_content.html" with content=texts %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,53 +1,19 @@
|
|||
|
||||
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="large-8 medium-8 columns special-column">
|
||||
<img src="{{ works.image_url }}">
|
||||
<div class="index-text">
|
||||
<h4><a href="{{ works.get_absolute_url }}" class="big-title">{{works.title}} </a></h4>
|
||||
<p> {{works.formatted_header|safe}} </p>
|
||||
<p> {{works.formatted_body|safe}} </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if latest_content_list %}
|
||||
|
||||
<div class="large-4 medium-4 columns">
|
||||
{% if works.children.all %}
|
||||
<h4 class="sidebar-h4"> Related </h4>
|
||||
{% for child in works.children.all %}
|
||||
<div class="row related-row">
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ child.get_absolute_url }}"> <img src="{{ child.image_url }}"> </a>
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
<h6><a href="{{ child.get_absolute_url }}" class="sidebar-title"> {{child}} </a> </h6>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<h4 class="sidebar-h4"> Works </h4>
|
||||
<div class="row">
|
||||
|
||||
{% for works in latest_content_list %}
|
||||
<div class="row right-items">
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ works.get_absolute_url }}"> <img src="{{ works.image_url }}"></a>
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ works.get_absolute_url }}" class="sidebar-title">{{ works.title }}</a>
|
||||
<p> {{ works.formatted_teaser }} </p>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>No works.</p>
|
||||
{% endif %}
|
||||
<a href="{% url 'works_list' %}">more</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "edit.html" with content=works %}
|
||||
<div class="large-8 medium-8 columns special-column">
|
||||
{% if works.image %}
|
||||
<img src="{{ works.image_url }}">
|
||||
{% endif %}
|
||||
<div class="index-text">
|
||||
<h4><a href="{{ works.get_absolute_url }}" class="big-title">{{works.title}} </a></h4>
|
||||
<p> {{works.formatted_header|safe}} </p>
|
||||
<p> {{works.formatted_body|safe}} </p>
|
||||
{% include "opt.html" with content=works %}
|
||||
{% include "links.html" with content=projects %}
|
||||
{% include "gallery.html" with gallery=gallery %}
|
||||
</div>
|
||||
</div>
|
||||
{% include "latest_content.html" with content=works %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -25,7 +25,7 @@ def index(request):
|
|||
base = base.filter(published=True)
|
||||
upcoming_events = base.filter(datestart__gt=now)[:12]
|
||||
ongoing_events = base.filter(datestart__lt=now, dateend__gte=now)[:12]
|
||||
past_events = base.filter(Q(dateend__lt=now)|Q(dateend=None, datestart__lt=now))[:12]
|
||||
past_events = base.filter(Q(dateend__lt=now) | Q(dateend=None, datestart__lt=now))[:12]
|
||||
|
||||
homepage = Content.objects.filter(type__name='homepage').order_by('-datestart')[:1]
|
||||
context = {
|
||||
|
@ -84,9 +84,9 @@ def section_list(request, section):
|
|||
|
||||
return render(request, 'results.html', {
|
||||
'base_query': base_query,
|
||||
'section': section,
|
||||
'content': content,
|
||||
'query': q
|
||||
'query': q,
|
||||
'section': section,
|
||||
})
|
||||
|
||||
def event(request):
|
||||
|
@ -107,71 +107,53 @@ def event(request):
|
|||
'ongoing_events': ongoing_events,
|
||||
'past_events': past_events,
|
||||
'featured': featured,
|
||||
'section': 'Events',
|
||||
}
|
||||
return render(request, 'event.html', context)
|
||||
|
||||
|
||||
def events(request, shortname=None):
|
||||
def get_related_content(types, current=None, max_length=10):
|
||||
latest_content_list = Content.objects.filter(type__name__in=types).order_by('-datestart')
|
||||
if current:
|
||||
latest_content_list = latest_content_list.exclude(pk=current.pk)
|
||||
latest_content_list = latest_content_list.filter(published=True)
|
||||
more = latest_content_list.count > max_length
|
||||
latest_content_list = latest_content_list[:max_length]
|
||||
return latest_content_list, more
|
||||
|
||||
|
||||
def render_content(request, shortname, section, template, types):
|
||||
if not shortname:
|
||||
return event(request)
|
||||
events = get_object_or_404(Content, shortname=shortname, type__name__in=['news', 'events'])
|
||||
if not events.published and not request.user.is_staff:
|
||||
if section == 'Events':
|
||||
return event(request)
|
||||
else:
|
||||
return section_index(request, section)
|
||||
content = get_object_or_404(Content, shortname=shortname, type__name__in=types)
|
||||
if not content.published and not request.user.is_staff:
|
||||
raise Http404
|
||||
gallery = get_or_none(Gallery, slug=shortname)
|
||||
latest_content_list = Content.objects.filter(type__name__in=['events', 'news']).order_by('-datestart')
|
||||
latest_content_list = latest_content_list.exclude(pk=events.pk)
|
||||
latest_content_list = latest_content_list[:10]
|
||||
return render(request, 'events.html', {
|
||||
'events': events,
|
||||
latest_content_list, more = get_related_content(types, content)
|
||||
return render(request, template, {
|
||||
'content': content,
|
||||
'latest_content_list': latest_content_list,
|
||||
'gallery': gallery
|
||||
'has_more_content': more,
|
||||
'section': section,
|
||||
})
|
||||
|
||||
|
||||
def events(request, shortname=None):
|
||||
return render_content(request, shortname, 'Events', 'content.html', ['events', 'news'])
|
||||
|
||||
|
||||
def projects(request, shortname=None):
|
||||
if not shortname:
|
||||
return section_index(request, 'Projects')
|
||||
projects = get_object_or_404(Content, shortname=shortname, type__name='projects')
|
||||
if not projects.published and not request.user.is_staff:
|
||||
raise Http404
|
||||
gallery = get_or_none(Gallery, slug=shortname)
|
||||
latest_content_list = Content.objects.filter(type__name='projects').order_by('-datestart')
|
||||
latest_content_list = latest_content_list.exclude(pk=projects.pk)
|
||||
latest_content_list = latest_content_list[:10]
|
||||
return render(request, 'projects.html', {
|
||||
'projects': projects,
|
||||
'latest_content_list': latest_content_list,
|
||||
'gallery': gallery
|
||||
})
|
||||
return render_content(request, shortname, 'Projects', 'content.html', ['projects'])
|
||||
|
||||
|
||||
def works(request, shortname=None):
|
||||
if not shortname:
|
||||
return section_index(request, 'Works')
|
||||
works = get_object_or_404(Content, shortname=shortname, type__name='works')
|
||||
if not works.published and not request.user.is_staff:
|
||||
raise Http404
|
||||
gallery = get_or_none(Gallery, slug=shortname)
|
||||
latest_content_list = Content.objects.filter(type__name='works')
|
||||
latest_content_list = latest_content_list.exclude(pk=works.pk)
|
||||
latest_content_list = latest_content_list[:10]
|
||||
return render(request, 'works.html', {
|
||||
'works': works,
|
||||
'latest_content_list': latest_content_list,
|
||||
'gallery': gallery
|
||||
})
|
||||
return render_content(request, shortname, 'Works', 'content.html', ['works'])
|
||||
|
||||
|
||||
def texts(request, shortname=None):
|
||||
if not shortname:
|
||||
return section_index(request, 'Texts')
|
||||
texts = get_object_or_404(Content, shortname=shortname, type__name='texts')
|
||||
gallery = get_or_none(Gallery, slug=shortname)
|
||||
latest_content_list = Content.objects.filter(type__name='texts')
|
||||
latest_content_list = latest_content_list.exclude(pk=texts.pk)
|
||||
latest_content_list = latest_content_list[:10]
|
||||
return render(request, 'texts.html', {
|
||||
'texts': texts,
|
||||
'latest_content_list': latest_content_list,
|
||||
'gallery': gallery
|
||||
})
|
||||
return render_content(requests, shortname, 'Texts', 'content.html', ['texts'])
|
||||
|
||||
|
||||
def page(request, shortname):
|
||||
|
@ -186,6 +168,7 @@ def limit_content(content, q):
|
|||
content = content.filter(Q(body__icontains=q) | Q(title__icontains=q) | Q(header__icontains=q)).distinct()
|
||||
return content
|
||||
|
||||
|
||||
def search(request):
|
||||
content = Content.objects.filter(published=True).order_by('-datestart')
|
||||
content = content.exclude(type__name__in=['page', 'homepage'])
|
||||
|
|
Loading…
Reference in New Issue
Block a user