Permalink
Browse files

Added page to view all contest entries in tabular form

  • Loading branch information...
1 parent 0481459 commit 3a5af9ba0faa524960ac24e7e9861e968a2075d2 Carissa Brittain committed Dec 2, 2011
Showing with 85 additions and 3 deletions.
  1. +14 −0 contest/models.py
  2. +9 −2 contest/views.py
  3. +2 −1 templates/contest/contest_template.html
  4. +59 −0 templates/contest/entry_table.html
  5. +1 −0 urls.py
View
14 contest/models.py
@@ -8,6 +8,14 @@
# Create your models here.
+DATA_STATUS = (
+ ('Released', 'Released'),
+ ('Not Released', 'Not Released'),
+ ('Under Discussion', 'Under Discussion'),
+ ('Cannot Be Released', 'Cannot Be Released'),
+ ('Rejected', 'Rejected')
+)
+
class Contest(models.Model):
title = models.CharField(max_length=255)
start_date = models.DateTimeField()
@@ -68,6 +76,12 @@ def get_image_path(instance, filename):
nominator = models.CharField(max_length=255)
nominator_link = models.CharField(max_length=255)
nominator_image = models.ImageField(upload_to=get_image_path, null=True, blank=True, help_text="Save the entries before adding images.")
+ status = models.CharField(max_length=255, choices=DATA_STATUS, default="Not Released")
+ links = models.CharField(max_length=400, null=True, blank=True)
+ is_visible = models.BooleanField(default=True)
+ data_owner = models.CharField(max_length=255)
+ rejected_reason = models.CharField(max_length=255, null=True, blank=True)
+ comments = models.TextField(null=True, blank=True)
contest = models.ForeignKey(Contest)
vote_count = models.IntegerField(default=0)
View
11 contest/views.py
@@ -9,14 +9,21 @@
def get_entries(request, contest_id=1):
contest = Contest.objects.get(pk=contest_id)
- entries = Entry.objects.filter(contest=contest)
+ entries = Entry.objects.filter(contest=contest, is_visible=True)
if not request.GET.__contains__('sort'):
entries = entries.order_by('-vote_count')
return render_to_response('contest/entries.html', {'contest': contest, 'entries': entries}, context_instance=RequestContext(request))
+def get_entries_table(request, contest_id=1):
+ contest = Contest.objects.get(pk=contest_id)
+ entries = Entry.objects.filter(contest=contest)
+ if not request.GET.__contains__('sort'):
+ entries = entries.order_by('-vote_count')
+ return render_to_response('contest/entry_table.html', {'contest': contest, 'entries': entries}, context_instance=RequestContext(request))
+
def get_winners(request, contest_id=1):
contest = Contest.objects.get(pk=contest_id)
- entries = Entry.objects.filter(contest=contest).order_by('-vote_count')
+ entries = Entry.objects.filter(contest=contest, is_visible=True).order_by('-vote_count')
return render_to_response('contest/winners.html', {'contest': contest, 'entries': entries}, context_instance=RequestContext(request))
def get_rules(request, contest_id=1):
View
3 templates/contest/contest_template.html
@@ -60,7 +60,8 @@
<ul>
{% if contest.has_ended %}<li id="menu_winner" class="contest_menu"><a href="{{SITE_ROOT}}/contest/winners">CONTEST WINNERS</a></li>{% endif %}
<li id="menu_vote" class="contest_menu"><a href="{{SITE_ROOT}}/contest/?sort=vote_count&dir=desc">
- {% if contest.has_ended %}ALL RESULTS{% else %}CAST YOUR VOTE{% endif %}</a></li>
+ {% if contest.has_ended %}VIEW RESULTS{% else %}CAST YOUR VOTE{% endif %}</a></li>
+ <li id="menu_table" class="contest_menu"><a href="{{SITE_ROOT}}/contest/entries/">ALL ENTRIES</a></li>
<li id="menu_rules" class="contest_menu"><a href="{{SITE_ROOT}}/contest/rules/">RULES</a></li>
<li id="menu_odp" class="contest_menu"><a href="{{SITE_ROOT}}/">OpenDataCatalog</a></li>
</ul>
View
59 templates/contest/entry_table.html
@@ -0,0 +1,59 @@
+{% extends "contest/contest_template.html" %}
+
+{% load sorting_tags %}
+{% load humanize %}
+
+{% block body_id %}id="contest"{% endblock %}
+
+{% block js_ready %}
+ <script>
+ $(document).ready(function () {
+ odp.setupSortLinks();
+
+ $(".contest_menu").removeClass('selected');
+ $("#menu_table").addClass('selected');
+ });
+ </script>
+{% endblock %}
+
+{% block header_description %}
+
+ <div>{{contest.title}} is a contest to do some things and win something.
+ Here's where the entries came from and why we think you should vote. </div>
+
+{% endblock %}
+
+{% block center_container %}
+
+
+
+
+{% autosort entries %}
+<div id="contest_entries_wrapper">
+ <table id="entry_list_table">
+ <tr>
+ <th>{% anchor is_visible "Included" %}</th>
+ <th>{% anchor vote_count "Votes" %}</th>
+ <th>{% anchor data_owner "Agency" %}</th>
+ <th>{% anchor nominator "Nominated By" %}</th>
+ <th>{% anchor title "Data Set" %}</th>
+ <th>{% anchor status "Remarks" %}</th>
+ </tr>
+ {% for entry in entries %}
+ <tr>
+ <td width="7%">{{ entry.is_visible|yesno:"<div id='included'>Yes</div>,<div id='not_included'>No</div>"|safe }}</td>
+ <td width="5%">{{ entry.vote_count }}</td>
+ <td width="15%">{{ entry.data_owner }}</td>
+ <td width="15%">{{ entry.nominator }}</td>
+ <td width="20%"><a href="{{SITE_ROOT}}/contest/entry/{{entry.id}}/">{{ entry.title }}</a></td>
+ <td width="38%">{{ entry.status }}
+ {% if not entry.is_visible %}, {{ entry.rejected_reason }}{% endif %}
+ {{entry.links|urlize}} {{entry.comments}}</td>
+ </tr>
+ {% endfor %}
+ </table>
+</div>
+
+
+
+{% endblock %}
View
1 urls.py
@@ -47,6 +47,7 @@
(r'^contest/add/$', 'contest.views.add_entry'),
(r'^contest/entry/(?P<entry_id>\d+)/$', 'contest.views.get_entry'),
(r'^contest/entry/(?P<entry_id>\d+)/vote/$', 'contest.views.add_vote'),
+ (r'^contest/entries/$', 'contest.views.get_entries_table'),
(r'^contest/winners/$', 'contest.views.get_winners'),
(r'^feeds/$', 'opendata.views.feed_list'),

0 comments on commit 3a5af9b

Please sign in to comment.