From 60b7cd6ee28fed9a51e5e58d7962fc5c8c4ced7f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Wed, 6 Nov 2013 12:56:20 +0100 Subject: [PATCH 1/1] Link to contact form from submission edit view --- wtem/admin.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/wtem/admin.py b/wtem/admin.py index f4ad1b0..672666b 100644 --- a/wtem/admin.py +++ b/wtem/admin.py @@ -5,6 +5,7 @@ import os from django.contrib import admin from django import forms from django.utils import simplejson +from django.core.urlresolvers import reverse from .models import Submission, Assignment @@ -18,13 +19,13 @@ def get_user_exercises(user): return [e for e in exercises if e['id'] in assignment.exercises] -readonly_fields = ('contact', 'first_name', 'last_name', 'email', 'key', 'key_sent') +readonly_fields = ('submitted_by', 'first_name', 'last_name', 'email', 'key', 'key_sent') class SubmissionFormBase(forms.ModelForm): class Meta: model = Submission - exclude = ('answers', 'marks') + readonly_fields + exclude = ('answers', 'marks', 'contact') + readonly_fields def get_form(request, submission): @@ -58,6 +59,16 @@ class SubmissionAdmin(admin.ModelAdmin): def get_form(self, request, obj, **kwargs): return get_form(request, obj) + def submitted_by(self, instance): + if instance.contact: + return '%s' % ( + reverse('admin:contact_contact_change', args = [instance.contact.id]), + instance.contact.contact + ) + return '-' + submitted_by.allow_tags = True + submitted_by.short_description = "Zgłoszony/a przez" + def save_model(self, request, submission, form, change): for name, value in form.cleaned_data.items(): if name.startswith('markof_'): -- 2.20.1