- submissions = Submission.objects.all()
- submissions = sorted(submissions, key = lambda s: -s.final_result)
- return render(request, 'wtem/admin_report.csv', dict(
- submissionsSet = SubmissionsSet(submissions),
- exercise_ids = map(str, range(1,len(exercises)+1))
- ))
+ submissions = sorted(Submission.objects.all(), key=lambda s: -s.final_result)
+ toret = render_to_string('wtem/admin_report.csv', {
+ 'submissionsSet': SubmissionsSet(submissions),
+ 'exercise_ids': [str(e['id']) for e in exercises]})
+ response = HttpResponse(toret, content_type='text/csv')
+ response['Content-Disposition'] = 'attachment; filename="wyniki.csv"'
+ return response
+
+
+class ConfirmationAdmin(admin.ModelAdmin):
+ list_display = ('email', 'first_name', 'last_name', 'readable_contact', 'school_phone', 'readable_age', 'confirmed')
+ readonly_fields = ('contact', 'readable_contact', 'readable_age', 'school_phone', 'key', 'confirmed')
+ list_filter = ('confirmed',)
+ list_select_related = ('contact',)
+ search_fields = ('last_name', 'email', 'contact__contact')
+
+ def resend_mail(self, request, queryset):
+ for confirmation in queryset:
+ confirmation.send_mail()
+ resend_mail.short_description = "Wyślij kod ponownie"
+
+ actions = [resend_mail]