Commits

Colin Copeland committed ed812a1

add categories to context; don't print event headers if they don't exist

  • Participants
  • Parent commits 5f3e93c

Comments (0)

Files changed (3)

File events/templates/events/_list_view.html

 {% if perms.events.change_event %}
-    <a class='edit' href='{% url admin:events_event_changelist %}'>(Edit)</a>
+    <a class='admin edit' href='{% url admin:events_event_changelist %}'>(Edit)</a>
 {% endif %}
 {% if current_category %}: {{ current_category }}{% endif %}</h2>
 <ul class='events'>

File events/templates/events/category.html

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

File events/views.py

         models.Event.published.upcoming().order_by('-begin_date')
     previous_events = \
         models.Event.published.previous().order_by('-begin_date')
+    print models.EventCategory.objects.all()
+    for c in models.EventCategory.objects.all():
+        print c
+    
     return render_to_response('events/list.html',  
         {
             'upcoming_events': upcoming_events,
             'previous_events': previous_events,
+            'event_categories': models.EventCategory.objects.all(),
         },
         context_instance=RequestContext(request),
     )