class ConfirmationAdmin(admin.ModelAdmin):
- list_display = ('email', 'first_name', 'last_name', 'confirmed')
- readonly_fields = ('contact', 'readable_contact', 'key', 'confirmed')
+ list_display = ('email', 'first_name', 'last_name', 'readable_contact', 'readable_age', 'confirmed')
+ readonly_fields = ('contact', 'readable_contact', 'readable_age', 'key', 'confirmed')
def resend_mail(self, request, queryset):
for confirmation in queryset:
from django.core.mail import send_mail
from django.core.urlresolvers import reverse
from django.template.loader import render_to_string
+from django.utils import timezone
from django.utils.translation import ugettext as _
from jsonfield import JSONField
def readable_contact(self):
return '%s <%s>' % (self.contact.body.get('przewodniczacy'), self.contact.contact)
+ def age(self):
+ return timezone.now() - self.contact.created_at
+
+ def readable_age(self):
+ td = self.age()
+ return '%s dni, %s godzin' % (td.days, td.seconds/3600)
+
def send_mail(self):
mail_subject = render_to_string('contact/olimpiada/student_mail_subject.html').strip()
mail_body = render_to_string(