Commits

Colin Copeland  committed 5f3e93c

clean up templates

  • Participants
  • Parent commits 314a916

Comments (0)

Files changed (8)

File events/models.py

 class EventCategory(models.Model):
     name = models.CharField(max_length=255, unique=True)
     slug = models.SlugField(max_length=255, unique=True)
+    description = models.TextField(blank=True)
 
     class Meta:
         verbose_name_plural = 'Categories'

File events/templates/events/_list_view.html

+{% if perms.events.change_event %}
+    <a class='edit' href='{% url admin:events_event_changelist %}'>(Edit)</a>
+{% endif %}
+{% if current_category %}: {{ current_category }}{% endif %}</h2>
+<ul class='events'>
+    {% for event in events %}
+        <li>
+            <h2><a href='{% url view_event event.begin_date.year,event.begin_date.month,event.slug %}'>{{ event }}</a></h2>
+                <p class='date'>
+                    {{ event.display_date }}{% if event.show_date %}.{% endif %}
+                </p>
+            <div class='description'>{{ event.description|safe|truncatewords_html:40 }}</div>
+        </li>
+    {% endfor %}
+</ul>

File events/templates/events/base.html

+{% extends "base.html" %}

File events/templates/events/category.html

+{% extends 'events/base.html' %}
+
+{% block content %}
+<h1>{{ category }}</h1>
+{% if category.description %}
+    {{ category.description|safe }}
+{% endif %}
+
+<h2>Events</h2>
+
+{% with upcoming_events as events %}
+    {% include 'events/_list_view.html' %}
+{% endwith %}
+
+{% with previous_events as events %}
+    {% include 'events/_list_view.html' %}
+{% endwith %}
+{% endblock %}

File events/templates/events/list.html

-{% extends "base.html" %}
+{% extends "events/base.html" %}
+
 {% block title %}Events{% endblock %}
-{% block content %}    
+
+{% block content %}
     {% if upcoming_events %}
-        <h2 class='no-bottom'>Upcoming {{ current_category }} Events and Meetings
-        {% if perms.events.change_event %}
-            <a class='edit' href='{% url admin:events_event_changelist %}'>(Edit)</a>
-        {% endif %}
-        {% if current_category %}: {{ current_category }}{% endif %}</h2>
-        <ul class='events'>
-            {% for event in upcoming_events %}
-                <li>
-                    <h2 class='no-bottom'><a href='{% url view_event event.begin_date.year,event.begin_date.month,event.slug %}'>{{ event }}</a></h2>
-                        <p class='date'>
-                            {{ event.display_date }}{% if event.show_date %}.{% endif %}
-                        </p>
-                    <div class='description'>{{ event.description|safe|truncatewords_html:40 }}</div>
-                </li>
-            {% endfor %}
-        </ul>
+        <h2>Upcoming {{ category }} Events</h2>
+        {% with upcoming_events as events %}
+            {% include 'events/_list_view.html' %}
+        {% endwith %}
     {% endif %}
     
     {% if previous_events %}
-        <h2 class='no-bottom'>Previous {{ current_category }} Events and Meetings
-        {% if perms.events.change_event %}
-            <a class='edit' href='{% url admin:events_event_changelist %}'>(Edit)</a>
-        {% endif %}
-        {% if current_category %}: {{ current_category }}{% endif %}</h2>
-        <ul class='events'>
-            {% for event in previous_events %}
-                <li>
-                    <h2 class='no-bottom'><a href='{% url view_event event.begin_date.year,event.begin_date.month,event.slug %}'>{{ event }}</a></h2>
-                        <p class='date'>
-                            {{ event.display_date }}{% if event.show_date %}.{% endif %}
-                        </p>
-                    <div class='description'>{{ event.description|safe|truncatewords_html:40 }}</div>
-                </li>
-            {% endfor %}
-        </ul>
+        <h2>Past {{ category }} Events</h2>
+        {% with previous_events as events %}
+            {% include 'events/_list_view.html' %}
+        {% endwith %}
     {% endif %}
 {% endblock %}

File events/templates/events/view.html

-{% extends 'base.html' %}
+{% extends 'events/base.html' %}
+
 {% block title %}Event: {{ event.name }}{% endblock %}
+
 {% block content %}
     
     {% if not event.is_upcoming %}

File events/urls.py

 
 
 urlpatterns = patterns('events.views',
-    url(r'^category/(?P<category_slug>[\w-]+)/$',
+    url(r'^(?P<category_slug>[\w-]+)/$',
             'list_events_for_category', 
             name='list_events_for_category'
         ),

File events/views.py

     previous_events = previous_events.filter(categories=current_category)
     previous_events = previous_events.order_by('-begin_date')
     
-    return render_to_response('events/list.html',
+    return render_to_response('events/category.html',
         {
             'upcoming_events': upcoming_events,
             'previous_events': previous_events,
-            'current_category': current_category,
+            'category': current_category,
             'categories' : categories,
         },
         context_instance=RequestContext(request),