From ee1d5fdd18a7ae26ab314b512552fed951b809b4 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Sun, 2 Oct 2016 11:17:32 +0200 Subject: [PATCH] korektury | pridan zodpovedny org k pdf zodpovednemu orgovy budou chodit e-maily o vsech zmenach --- korektury/admin.py | 21 +++++++++-------- korektury/migrations/0014_add_org_to_pdf.py | 25 +++++++++++++++++++++ korektury/models.py | 8 ++++++- korektury/views.py | 9 +++++++- 4 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 korektury/migrations/0014_add_org_to_pdf.py diff --git a/korektury/admin.py b/korektury/admin.py index 58e460d3..6c9e7cad 100644 --- a/korektury/admin.py +++ b/korektury/admin.py @@ -2,15 +2,18 @@ from django.contrib import admin from reversion.admin import VersionAdmin from korektury.models import KorekturovanePDF + # Register your models here. class KorekturovanePDFAdmin(VersionAdmin): - readonly_fields = ['cas', 'stran'] - fieldsets = [ - (None, {'fields': ['pdf', 'cas', 'stran', 'nazev', 'komentar']}), -# (u'PDF', {'fields': ['pdf']}), - ] - list_display = ['nazev', 'cas', 'stran'] - list_filter = [] - search_fields = [] - + readonly_fields = ['cas', 'stran'] + fieldsets = [ + (None, + {'fields': + ['pdf', 'cas', 'org', 'stran', 'nazev', 'komentar']}), + # (u'PDF', {'fields': ['pdf']}), + ] + list_display = ['nazev', 'cas', 'stran'] + list_filter = [] + search_fields = [] + admin.site.register(KorekturovanePDF, KorekturovanePDFAdmin) diff --git a/korektury/migrations/0014_add_org_to_pdf.py b/korektury/migrations/0014_add_org_to_pdf.py new file mode 100644 index 00000000..9c1292e4 --- /dev/null +++ b/korektury/migrations/0014_add_org_to_pdf.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0041_konfery'), + ('korektury', '0013_rename_autor_org'), + ] + + operations = [ + migrations.AddField( + model_name='korekturovanepdf', + name='org', + field=models.ForeignKey(default=None, + blank=True, + to='seminar.Organizator', + help_text=b'Zodpov\xc4\x9bdn\xc3\xbd\ + organiz\xc3\xa1tor za obsah', + null=True), + ), + ] diff --git a/korektury/models.py b/korektury/models.py index a07c6945..70d57e08 100644 --- a/korektury/models.py +++ b/korektury/models.py @@ -48,7 +48,13 @@ class KorekturovanePDF(models.Model): pdf = models.FileField(u'PDF', upload_to = generate_filename) - stran = models.IntegerField(u'počet stran', help_text = 'Počet stran PDF', default = 0) + org = models.ForeignKey(Organizator, blank=True, + help_text='Zodpovědný organizátor za obsah', + null=True, + default=None) + + stran = models.IntegerField(u'počet stran', help_text='Počet stran PDF', + default=0) STATUS_PRIDAVANI = 'pridavani' STATUS_ZANASENI = 'zanaseni' STATUS_ZASTARALE = 'zastarale' diff --git a/korektury/views.py b/korektury/views.py index 49cd480c..ccc224f4 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -52,6 +52,7 @@ class KorekturyView(generic.TemplateView): op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf) op.save() + self.send_email_notification_komentar(op, autor, text) elif (action == u'del'): id = int(q.get('id')) op = Oprava.objects.get(id=id) @@ -135,13 +136,19 @@ class KorekturyView(generic.TemplateView): # Prijemci e-mailu emails = set() email = oprava.autor.user.email + # e-mail autora opravy (TODO odstranit z prijemcu) if email: emails.add(email) + # nalezeni e-mailu na organizatory komentaru for komentar in oprava.komentar_set.all(): email = komentar.autor.user.email if email: emails.add(email) - + # zodpovedny org + email_zobpovedny = oprava.pdf.org.user.email + if email_zobpovedny: + emails.add(email_zobpovedny) + send_mail(subject, text, from_email, list(emails)) def get_context_data(self, **kwargs):