Skip to content
This repository has been archived by the owner on Apr 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #156 from mozilla/dev
Browse files Browse the repository at this point in the history
Merge dev branch
  • Loading branch information
alfredo committed May 28, 2014
2 parents cbc095f + 22ee234 commit 148f5da
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/challenges/urls.py
Expand Up @@ -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'),
Expand Down
31 changes: 31 additions & 0 deletions apps/challenges/views.py
Expand Up @@ -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)
35 changes: 35 additions & 0 deletions 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>
4 changes: 3 additions & 1 deletion urls_ignite.py
Expand Up @@ -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(
Expand Down

0 comments on commit 148f5da

Please sign in to comment.