changeset 567:0a8e6a9ccf53

Tweaks to the contests application: show the winners on the list page. Minor presentation changes on the detail template.
author Brian Neal <bgneal@gmail.com>
date Wed, 07 Mar 2012 18:12:02 -0600 (2012-03-08)
parents 4b9970ad0edb
children 7cec8d6f9581
files gpp/contests/models.py gpp/contests/urls.py gpp/templates/contests/contest_detail.html gpp/templates/contests/contest_list.html static/icons/rosette.png
diffstat 5 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/gpp/contests/models.py	Sun Mar 04 14:52:24 2012 -0600
+++ b/gpp/contests/models.py	Wed Mar 07 18:12:02 2012 -0600
@@ -87,7 +87,7 @@
         """
         return {
             'og:title': self.title,
-            'og:type': 'game',
+            'og:type': 'article',
             'og:url': self.get_absolute_url(),
             'og:description': self.meta_description,
         }
--- a/gpp/contests/urls.py	Sun Mar 04 14:52:24 2012 -0600
+++ b/gpp/contests/urls.py	Wed Mar 07 18:12:02 2012 -0600
@@ -12,7 +12,7 @@
    url(r'^$',
        ListView.as_view(
            context_object_name='contests',
-           queryset=Contest.public_objects.all()),
+           queryset=Contest.public_objects.select_related('winner')),
        name='contests-index'),
 
    url(r'^enter/$',
--- a/gpp/templates/contests/contest_detail.html	Sun Mar 04 14:52:24 2012 -0600
+++ b/gpp/templates/contests/contest_detail.html	Wed Mar 07 18:12:02 2012 -0600
@@ -33,9 +33,10 @@
 {% endif %}
 </p>
 
+{% if contest.can_enter %}
 <h4>Contest Entry</h4>
 <p id="contest-entry">
-{% if contest.can_enter and user.is_authenticated %}
+{% if user.is_authenticated %}
    {% if user in contest.contestants.all %}
       You are currently entered into this contest.<br />
       <button id="contest-button">Withdraw from this contest</button>
@@ -44,20 +45,17 @@
       <button id="contest-button">Please enter me into this contest!</button>
    {% endif %}
 {% else %}
-   {% if contest.can_enter %}
-      Please <a href="{% url 'accounts-login' %}?next={{ contest.get_absolute_url }}">login</a>
-      to enter this contest.
-   {% else %}
-      Sorry, we are no longer accepting entries to this contest.
-   {% endif %}
+   Please <a href="{% url 'accounts-login' %}?next={{ contest.get_absolute_url }}">login</a>
+   to enter this contest.
 {% endif %}
 </p>
+{% endif %}
 
 <h4>Contest Winner</h4>
 <p>
 {% if contest.winner %}
 The winner of this contest, selected on {{ contest.win_date|date:"l, F d, Y" }}, is 
-{% profile_link contest.winner.username %}. Congratulations to <strong>{{ contest.winner.username }}</strong>!
+{% profile_link contest.winner.username '.' %} Congratulations to <strong>{{ contest.winner.username }}</strong>!
 {% else %}
 A contest winner will be determined sometime on or after {{ contest.end_date|date:"l, F d, Y" }}.
 Please check back later.
--- a/gpp/templates/contests/contest_list.html	Sun Mar 04 14:52:24 2012 -0600
+++ b/gpp/templates/contests/contest_list.html	Wed Mar 07 18:12:02 2012 -0600
@@ -1,4 +1,5 @@
 {% extends 'base.html' %}
+{% load bio_tags %}
 {% block title %}Contests{% endblock %}
 {% block content %}
 <h2>Contests</h2>
@@ -9,7 +10,15 @@
    {% for contest in contests %}
    <li><a href="{{ contest.get_absolute_url }}">{{ contest.title }}</a> -
    {{ contest.creation_date|date:"F d, Y" }} to {{ contest.end_date|date:"F d, Y" }}
-   {% if contest.is_active %}<img src="{{ STATIC_URL }}icons/new.png" alt="New" />{% else %}<img src="{{ STATIC_URL }}icons/lock.png" alt="Old" />{% endif %}
+   {% if contest.is_active %}
+      <img src="{{ STATIC_URL }}icons/new.png" alt="New" />
+   {% else %}
+      {% if contest.winner %}
+         <img src="{{ STATIC_URL }}icons/rosette.png" alt="Winner" /> {% profile_link contest.winner.username %}
+      {% else %}
+         <img src="{{ STATIC_URL }}icons/lock.png" alt="Old" />
+      {% endif %}
+   {% endif %}
    </li>
    {% endfor %}
 </ul>
Binary file static/icons/rosette.png has changed