Actually implement a way to look at older events (events archive)
authorMagnus Hagander <magnus@hagander.net>
Wed, 30 Jan 2013 13:28:16 +0000 (14:28 +0100)
committerMagnus Hagander <magnus@hagander.net>
Wed, 30 Jan 2013 13:28:16 +0000 (14:28 +0100)
This also changes the main URL to look at events to be /about/events/
instead of /about/eventsarchive/, and reuses /about/eventsarchive/ to
be the actual achive. Also separates out the training archive to it's
own page at /about/eventsarchive/training/, for easier browsing.

pgweb/events/models.py
pgweb/events/views.py
pgweb/urls.py
pgweb/util/contexts.py
templates/events/archive.html
templates/index.html

index d1b4daa6e1d663322a1cd90a788d5f1b61142f4d..3c09697bf5181ad74a5e674b01116ee6d5cf8f86 100644 (file)
@@ -27,7 +27,7 @@ class Event(PgModel, models.Model):
        
        def purge_urls(self):
                yield '/about/event/%s/' % self.pk
-               yield '/about/eventarchive/'
+               yield '/about/events/'
                yield '/events.rss'
                # FIXME: when to expire the front page?
                yield '/$'
index 02edabc4d080739f8cae72948a89bcd1139e6792..10be0b3890b3b2c1803cc66704cb093d9314d232 100644 (file)
@@ -12,16 +12,34 @@ from pgweb.util.helpers import simple_form
 from models import Event
 from forms import EventForm
 
-def archive(request, paging=None):
+def main(request):
        events = Event.objects.select_related('country').filter(approved=True).filter(training=False, enddate__gt=date.today).order_by('enddate', 'startdate',)
        training = Event.objects.select_related('country').filter(approved=True).filter(training=True, enddate__gt=date.today).order_by('enddate', 'startdate',)
        return render_to_response('events/archive.html', {
+               'title': 'Current events',
                'eventblocks': (
-                       { 'name': 'Events', 'events': events, },
-                       { 'name': 'Training', 'events': training, },
+                       { 'name': 'Events', 'events': events, 'link': '',},
+                       { 'name': 'Training', 'events': training, 'link': 'training/',},
                ),
        }, NavContext(request, 'about'))
 
+def _eventarchive(request, training, title):
+       # Hardcode to the latest 100 events. Do we need paging too?
+       events = Event.objects.select_related('country').filter(approved=True).filter(training=training, enddate__lte=date.today).order_by('-enddate', '-startdate',)[:100]
+       return render_to_response('events/archive.html', {
+                       'title': '%s Archive' % title,
+                       'archive': True,
+                       'eventblocks': (
+                               {'name': title, 'events': events, },
+                               ),
+       }, NavContext(request, 'about'))
+
+def archive(request):
+       return _eventarchive(request, False, 'Event')
+
+def trainingarchive(request):
+       return _eventarchive(request, True, 'Training')
+
 def item(request, itemid, throwaway=None):
        event = get_object_or_404(Event, pk=itemid)
        if not event.approved:
index 2bdd00857725cf0e23aa9245ad3fe314843d2cfc..0d7f8770b810638ba573ded39c7c0e7ec6f1fc57 100644 (file)
@@ -27,7 +27,9 @@ urlpatterns = patterns('',
 
     (r'^about/newsarchive/$', 'news.views.archive'),
     (r'^about/news/(\d+)(-.*)?/$', 'news.views.item'),
+    (r'^about/events/$', 'events.views.main'),
     (r'^about/eventarchive/$', 'events.views.archive'),
+    (r'^about/eventarchive/training/$', 'events.views.trainingarchive'),
     (r'^about/event/(\d+)(-.*)?/$', 'events.views.item'),
     (r'^about/featurematrix/$', 'featurematrix.views.root'),
     (r'^about/featurematrix/detail/(\d+)/$', 'featurematrix.views.detail'),
index e83ddacaaa44aae267c16c5b36c1ab921473fd54..a106f9d53425bcfe3b9858e751fcd7d5931cd1d2 100644 (file)
@@ -17,7 +17,7 @@ sitenav = {
                        {'title': 'Servers',    'link': '/about/servers/'},
                ]},
                {'title': 'Latest news',        'link':'/about/newsarchive/'},
-               {'title': 'Upcoming events',    'link':'/about/eventarchive/'},
+               {'title': 'Upcoming events',    'link':'/about/events/'},
                {'title': 'Press',              'link':'/about/press/'},
                {'title': 'Licence',            'link':'/about/licence/'},
        ],
index 96873f60f28112a2a2c412c40267604c1c213ca1..289a93e280c983a5f1a9cfd4a42d918d5497e995 100644 (file)
@@ -1,10 +1,11 @@
 {%extends "base/page.html"%}
 {%load markup%}
-{%block title%}Event archive{%endblock%}
+{%block title%}{{title}}{%endblock%}
 {%block contents%}
 
+<h1>{{title}}</h1>
 {%for eventblock in eventblocks%}
-<h1><a name="{{eventblock.name}}">{{eventblock.name}}</a></h1>
+{%if eventblocks|length > 1%}<h2><a name="{{eventblock.name}}">{{eventblock.name}}</a></h2>{%endif%}
 <p>
 <i><b>Note:</b> The PostgreSQL Global Development Group does not endorse any
 events run by third parties. No guarantee of the quality of events is offered
@@ -18,8 +19,13 @@ whatsoever.</i>
 {{event.summary|markdown:"safe"}}
 </p>
 {%endfor%}
+{%if not archive%}
+<p><a href="/about/eventarchive/{{eventblock.link}}">Older {{eventblock.name}}</a></p>
+{%endif%}
 {%endfor%}
 
+{%if not archive%}
 <p><a href="/account/events/new/">Submit event</a></p>
+{%endif%}
 {%endblock%}
 
index 4be59e1c3cfd11974b46f5e6001f8a0a6576e339..150f30d9781589f013b623bb7482b3d3e40d52ac 100644 (file)
@@ -140,7 +140,7 @@ of bugs in previous releases.,
            </div> <!-- pgFrontPlanetWrap -->
          </div> <!-- pgFrontPlanet -->
          <div id="pgFrontEvents" class="txtNewsEvent">
-           <a href="/about/eventarchive">
+           <a href="/about/events/">
            <img src="/media/img/hdr/hdr_upcomingevents.png" width="123" height="10" alt="Upcoming Events" />
            </a>
            <div class="pgNewsEventsWrap">
@@ -151,7 +151,7 @@ of bugs in previous releases.,
             </p>
            {% endfor %}
            </div>
-           <a href="/about/eventarchive">
+           <a href="/about/events/">
            <img src="/media/img/hdr/hdr_upcomingtraining.png" width="140" height="10" alt="Upcoming training" />
            </a>
            <div class="pgNewsEventsWrap">
@@ -166,7 +166,7 @@ of bugs in previous releases.,
                {{trainingcompanies|slice:":2"|join:", "}} and others.
                {%endif%}
               {%endif%}
-              <p>Take a look at our <a href="/about/eventarchive/#Training">schedule</a> to find the training that you want.</p>
+              <p>Take a look at our <a href="/about/events/#Training">schedule</a> to find the training that you want.</p>
              {%else%}
               There are no training events currently scheduled.
              {%endif%}
@@ -175,7 +175,7 @@ of bugs in previous releases.,
                <img class="pgArrowImage" src="/media/img/layout/blt_blu_arrow.png" width="6" height="5" alt="" />
                <ul class="pgRSSBottomList">
                  <li>
-                   <a href="/about/eventarchive" title="More Events">More</a>
+                   <a href="/about/events/" title="More Events">More</a>
                  </li>
                  <li>
                   <a href="/account/events/new/">Submit Event</a>