Browse Source

korektury | pridan zodpovedny org k pdf

zodpovednemu orgovy budou chodit e-maily o vsech zmenach
remotes/origin/posli-mail-autorovi-korektury
Bc. Petr Pecha 8 years ago
parent
commit
ee1d5fdd18
  1. 5
      korektury/admin.py
  2. 25
      korektury/migrations/0014_add_org_to_pdf.py
  3. 8
      korektury/models.py
  4. 7
      korektury/views.py

5
korektury/admin.py

@ -2,11 +2,14 @@ from django.contrib import admin
from reversion.admin import VersionAdmin from reversion.admin import VersionAdmin
from korektury.models import KorekturovanePDF from korektury.models import KorekturovanePDF
# Register your models here. # Register your models here.
class KorekturovanePDFAdmin(VersionAdmin): class KorekturovanePDFAdmin(VersionAdmin):
readonly_fields = ['cas', 'stran'] readonly_fields = ['cas', 'stran']
fieldsets = [ fieldsets = [
(None, {'fields': ['pdf', 'cas', 'stran', 'nazev', 'komentar']}), (None,
{'fields':
['pdf', 'cas', 'org', 'stran', 'nazev', 'komentar']}),
# (u'PDF', {'fields': ['pdf']}), # (u'PDF', {'fields': ['pdf']}),
] ]
list_display = ['nazev', 'cas', 'stran'] list_display = ['nazev', 'cas', 'stran']

25
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),
),
]

8
korektury/models.py

@ -48,7 +48,13 @@ class KorekturovanePDF(models.Model):
pdf = models.FileField(u'PDF', upload_to = generate_filename) 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_PRIDAVANI = 'pridavani'
STATUS_ZANASENI = 'zanaseni' STATUS_ZANASENI = 'zanaseni'
STATUS_ZASTARALE = 'zastarale' STATUS_ZASTARALE = 'zastarale'

7
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 = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf)
op.save() op.save()
self.send_email_notification_komentar(op, autor, text)
elif (action == u'del'): elif (action == u'del'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.get(id=id) op = Oprava.objects.get(id=id)
@ -135,12 +136,18 @@ class KorekturyView(generic.TemplateView):
# Prijemci e-mailu # Prijemci e-mailu
emails = set() emails = set()
email = oprava.autor.user.email email = oprava.autor.user.email
# e-mail autora opravy (TODO odstranit z prijemcu)
if email: if email:
emails.add(email) emails.add(email)
# nalezeni e-mailu na organizatory komentaru
for komentar in oprava.komentar_set.all(): for komentar in oprava.komentar_set.all():
email = komentar.autor.user.email email = komentar.autor.user.email
if email: if email:
emails.add(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)) send_mail(subject, text, from_email, list(emails))

Loading…
Cancel
Save