X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/1de527b403042ae29020e328ff24e4a26b575189..8fa5ac7024f21f7e57b8ce0a26152e578e6128b6:/wtem/admin.py?ds=sidebyside diff --git a/wtem/admin.py b/wtem/admin.py index 3608628..fe4e692 100644 --- a/wtem/admin.py +++ b/wtem/admin.py @@ -10,6 +10,7 @@ from django.http import HttpResponse from django.template.loader import render_to_string from django.utils.safestring import mark_safe +from wtem.models import Confirmation, CompetitionState, TeacherConfirmation from .middleware import get_current_request from .models import Submission, Assignment, Attachment, exercises @@ -206,7 +207,6 @@ class SubmissionAdmin(admin.ModelAdmin): return qs def get_urls(self): - urls = super(SubmissionAdmin, self).get_urls() return patterns( '', url(r'^report/$', self.admin_site.admin_view(report_view), name='wtem_admin_report') @@ -224,8 +224,9 @@ class SubmissionsSet: examiners = self.examiners_by_exercise.setdefault(exercise_id, []) if user not in examiners: examiners.append(user) - contact_body = submission.contact.body - submission.school = '%s %s' % (contact_body['institution'], contact_body['institution_address']) + if submission.contact: + contact_body = submission.contact.body + submission.school = '%s %s' % (contact_body.get('school'), contact_body.get('school_address')) def report_view(request): @@ -237,5 +238,32 @@ def report_view(request): 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] + + +class TeacherConfirmationAdmin(admin.ModelAdmin): + list_display = ('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 = ('contact__contact',) + + admin.site.register(Submission, SubmissionAdmin) admin.site.register(Assignment) +admin.site.register(Confirmation, ConfirmationAdmin) +admin.site.register(TeacherConfirmation, TeacherConfirmationAdmin) +admin.site.register(CompetitionState)