Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #157 from mozilla/dev

Merge dev branch
  • Loading branch information...
commit a3682dde7eace9f4e4bb4454a936eed55790ab04 2 parents a4b70de + 22ee234
@alfredo alfredo authored
View
3  apps/challenges/urls.py
@@ -2,7 +2,8 @@
PATH_PREFIX = r'^(?P<project>[\w-]+)/challenges/(?P<slug>[\w-]+)/'
-urlpatterns = patterns('challenges.views',
+urlpatterns = patterns(
+ 'challenges.views',
url(PATH_PREFIX + r'$', 'show', name='challenge_show'),
url(PATH_PREFIX + r'entries/$', 'entries_all', name='entries_all'),
url(PATH_PREFIX + r'entries/add/$', 'create_entry', name='entry_create'),
View
31 apps/challenges/views.py
@@ -613,3 +613,34 @@ def entry_help_list(request, project, challenge):
context = {'page': paginated_query}
return jingo.render(request, 'challenges/submission_help_list.html',
context)
+
+
+def _get_submission_score(submission):
+ judgement_list = submission.judgement_set.all()
+ answer_list = []
+ if judgement_list:
+ for judgement in judgement_list:
+ for answer in judgement.answers.all():
+ answer_list.append(answer)
+ return answer_list
+
+
+@login_required
+def export_challenges(request):
+ if not request.user.is_superuser:
+ raise Http404
+ context = {'object_list': []}
+ for phase in Phase.objects.all():
+ data = {
+ 'phase': phase,
+ 'submission_list': []
+ }
+ submission_list = phase.submission_set.all()
+ for submission in submission_list:
+ submission_data = {
+ 'submission': submission,
+ 'score': _get_submission_score(submission)
+ }
+ data['submission_list'].append(submission_data)
+ context['object_list'].append(data)
+ return jingo.render(request, 'challenges/export.html', context)
View
35 templates_ignite/challenges/export.html
@@ -0,0 +1,35 @@
+<html>
+ <head>
+ <title>Challenge export</title>
+ </head>
+ <body>
+ <h1>Challenge export</h1>
+ {% for object in object_list %}
+ <h2>{{ object.phase.name }}</h2>
+ <table border="1">
+ {% for submission in object.submission_list %}
+ {# Only submissions that have been scored #}
+ {% if submission.score %}
+ <tr>
+ <td colspan="4">Title: {{ submission.submission.title }}</td>
+ </tr>
+ <tr>
+ <th>Question</th>
+ <th>Score</th>
+ <th>Judge</th>
+ <th>Notes</th>
+ </tr>
+ {% for answer in submission.score %}
+ <tr>
+ <td>{{ answer.criterion.question }}</td>
+ <td>{{ answer.rating }}</td>
+ <td>{{ answer.judgement.judge }}</td>
+ <td>{{ answer.judgement.notes }}</td>
+ </tr>
+ {% endfor %}
+ {% endif %}
+ {% endfor%}
+ </table>
+ {% endfor%}
+ </body>
+</html>
View
4 urls_ignite.py
@@ -73,7 +73,9 @@
kwargs=_ignite_kwargs, name='entries_assigned'),
url(r'^submissions/green-lit/$', 'entries_winning',
kwargs=_ignite_kwargs, name='entries_winning'),
- )
+ url(r'^challenges/export/$', 'export_challenges',
+ name='export_challenges'),
+)
urlpatterns += patterns(
Please sign in to comment.
Something went wrong with that request. Please try again.