Browse Source

Merge branch 'master' into stable

remotes/origin/posli-mail-autorovi-korektury
Bc. Petr Pecha 8 years ago
parent
commit
23780af908
  1. 7
      korektury/admin.py
  2. 25
      korektury/migrations/0014_add_org_to_pdf.py
  3. 8
      korektury/models.py
  4. 7
      korektury/views.py

7
korektury/admin.py

@ -2,12 +2,15 @@ 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']}),
(None,
{'fields':
['pdf', 'cas', 'org', 'stran', 'nazev', 'komentar']}),
# (u'PDF', {'fields': ['pdf']}),
]
list_display = ['nazev', 'cas', 'stran']
list_filter = []

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)
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'

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.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,12 +136,18 @@ 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))

Loading…
Cancel
Save