Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

Commit

Permalink
Fix ordering of templates in event pages. Closes #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
daisylb committed May 3, 2013
1 parent 04aff02 commit 71b90d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.mdown
Expand Up @@ -33,6 +33,8 @@ Create an Event Container page in the Mezzanine admin (naming it something like

## Creating Templates

In addition to the documentation here, take a look at how the default templates in the `mezzanine_events/templates` directory are written.

### Event pages

The template for an Event page is `templates/pages/event.html`.
Expand Down Expand Up @@ -60,7 +62,7 @@ Event pages default to being not visible in navigation, unless "show events in n

The template for an Event Container page is `templates/pages/eventcontainer.html`.

Iterate over `page.children.all` to get at the events inside the container. You can then use all of the properties and template tags listed above on these objects.
Iterate over `page.eventcontainer.events` to get at the events inside the container. You can then use all of the properties and template tags listed above on these objects.

The template filter `{{ page.eventcontainer|icalendar_url:"webcal" }}` can be used to produce a webcal URL. When a link containing this URL is clicked, the user's default calendaring app will subscribe to events in this eventcontainer.

Expand Down
6 changes: 5 additions & 1 deletion mezzanine_events/models.py
Expand Up @@ -71,11 +71,15 @@ def save(self, *args, **kwargs):
self.in_menus = ""

super(Event, self).save(*args, **kwargs)

class Meta:
verbose_name = "Event"

class EventContainer (Page):
hide_children = models.BooleanField(default=True, verbose_name="Hide events in this container from navigation")
class Meta:
verbose_name = "Event Container"

def events(self):
"""Convenience method for getting at all events in a container, in the right order, from a template."""
return self.children.published().order_by('_order')
10 changes: 5 additions & 5 deletions mezzanine_events/templates/pages/eventcontainer.html
Expand Up @@ -10,10 +10,10 @@
</a>
</div>

{% for child in page.children.published %}
<h3><a href="{{child.get_absolute_url}}">{{child.title}}</a> <small>{{child.event.date}} from {{child.event.start_time}} to {{child.event.end_time}}</small></h3>
{{child.event.content|richtext_filter|truncatewords_html:40|safe}}
<a href="{{child.get_absolute_url}}" class="btn">More info &rarr;</a>
{% for event in page.eventcontainer.events %}
<h3><a href="{{event.get_absolute_url}}">{{event.title}}</a> <small>{{event.event.date}} from {{event.event.start_time}} to {{event.event.end_time}}</small></h3>
{{event.event.content|richtext_filter|truncatewords_html:40|safe}}
<a href="{{event.get_absolute_url}}" class="btn">More info &rarr;</a>
{% endfor %}

{% endblock %}
{% endblock %}

0 comments on commit 71b90d4

Please sign in to comment.