Merge branch 'master' of atrey.karlin.mff.cuni.cz:/akce/MaM/MaMweb/mamweb
This commit is contained in:
commit
289fc7f6b4
25 changed files with 638 additions and 42 deletions
|
@ -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)
|
||||
|
|
25
korektury/migrations/0014_add_org_to_pdf.py
Normal file
25
korektury/migrations/0014_add_org_to_pdf.py
Normal file
|
@ -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),
|
||||
),
|
||||
]
|
19
korektury/migrations/0015_auto_20161004_2005.py
Normal file
19
korektury/migrations/0015_auto_20161004_2005.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('korektury', '0014_add_org_to_pdf'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
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),
|
||||
),
|
||||
]
|
|
@ -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'
|
||||
|
|
|
@ -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,20 @@ class KorekturyView(generic.TemplateView):
|
|||
# Prijemci e-mailu
|
||||
emails = set()
|
||||
email = oprava.autor.user.email
|
||||
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
|
||||
if oprava.pdf.org:
|
||||
email_zobpovedny = oprava.pdf.org.user.email
|
||||
if email_zobpovedny:
|
||||
emails.add(email_zobpovedny)
|
||||
# odstran e-mail autora opravy
|
||||
if email:
|
||||
emails.discard(email)
|
||||
|
||||
send_mail(subject, text, from_email, list(emails))
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
|
|
@ -18,6 +18,9 @@ urlpatterns = [
|
|||
|
||||
# Korekturovaci aplikace (ma vlastni podadresare)
|
||||
url(r'^', include('korektury.urls')),
|
||||
|
||||
# Prednaskova aplikace (ma vlastni podadresare)
|
||||
url(r'^', include('prednasky.urls')),
|
||||
|
||||
# Comments (interni i verejne)
|
||||
url(r'^comments_dj/', include('django_comments.urls')),
|
||||
|
|
|
@ -1,7 +1,59 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.contrib import admin
|
||||
from django.contrib import messages
|
||||
from django import forms
|
||||
from reversion.admin import VersionAdmin
|
||||
from autocomplete_light import shortcuts as autocomplete_light
|
||||
from django.db import models
|
||||
|
||||
from models import Prednaska, Seznam, Hlasovani
|
||||
from models import Prednaska, Seznam, STAV_NAVRH
|
||||
from seminar.models import Soustredeni
|
||||
|
||||
admin.site.register(Seznam)
|
||||
admin.site.register(Prednaska)
|
||||
admin.site.register(Hlasovani)
|
||||
class Seznam_PrednaskaInline(admin.TabularInline):
|
||||
# form = autocomplete_light.modelform_factory(Prednaska, autocomplete_fields=['nazev'], fields=['nazev'])
|
||||
model = Prednaska.seznamy.through
|
||||
# fields = ['nazev', 'org', 'obor' ]
|
||||
# extra = 0
|
||||
# formfield_overrides = {
|
||||
# models.TextField: {'widget': forms.TextInput},
|
||||
# }
|
||||
|
||||
# def get_queryset(self, request):
|
||||
# qs = super(Seznam_PrednaskaInline, self).get_queryset(request)
|
||||
# return qs.select_related('seznam', 'prednaska')
|
||||
|
||||
class SeznamAdmin(VersionAdmin):
|
||||
list_display = ['soustredeni','stav']
|
||||
inlines = [Seznam_PrednaskaInline]
|
||||
|
||||
admin.site.register(Seznam,SeznamAdmin)
|
||||
|
||||
|
||||
class PrednaskaAdmin(VersionAdmin):
|
||||
list_display = ['nazev', 'org', 'obor']
|
||||
list_filter = ['org','obor']
|
||||
search_fields = []
|
||||
|
||||
actions = ['move_to_soustredeni']
|
||||
|
||||
def move_to_soustredeni(self,request,queryset):
|
||||
sous = Soustredeni.objects.first()
|
||||
seznam = Seznam.objects.filter(soustredeni=sous,stav=STAV_NAVRH)
|
||||
if len(seznam) == 0:
|
||||
self.message_user(request,u"Není definován seznam pro aktuální soustředění, nic se neprovedlo",messages.ERROR)
|
||||
return
|
||||
seznam = seznam[0]
|
||||
for prednaska in queryset:
|
||||
prednaska.seznamy.add(seznam)
|
||||
prednaska.save()
|
||||
|
||||
self.message_user(request,u"Vybrané přednášky ({}) přidány jako návrhy na nejbližší soustředění".format(len(queryset)))
|
||||
|
||||
move_to_soustredeni.short_description=u"Přidat přednášky do návrhu na nejbližší soustředění"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
admin.site.register(Prednaska,PrednaskaAdmin)
|
||||
|
|
64
prednasky/migrations/0003_auto_20160929_0117.py
Normal file
64
prednasky/migrations/0003_auto_20160929_0117.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('prednasky', '0002_auto_20160417_2347'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='Seznam',
|
||||
new_name='Seznam_old',
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='hlasovani',
|
||||
options={'ordering': ['ucastnik', 'prednaska'], 'verbose_name': 'Hlasov\xe1n\xed', 'verbose_name_plural': 'Hlasov\xe1n\xed'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='prednaska',
|
||||
options={'ordering': ['org', 'nazev'], 'verbose_name': 'P\u0159edn\xe1\u0161ka', 'verbose_name_plural': 'P\u0159edn\xe1\u0161ky'},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='prednaska',
|
||||
name='popis',
|
||||
field=models.TextField(help_text=b'Neve\xc5\x99ejn\xc3\xbd popis pro ostatn\xc3\xad orgy', null=True, verbose_name=b'Popis pro orgy'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='hlasovani',
|
||||
name='id',
|
||||
field=models.AutoField(serialize=False, primary_key=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='anotace',
|
||||
field=models.TextField(help_text=b'Ve\xc5\x99ejn\xc3\xa1 anotace v hlasov\xc3\xa1n\xc3\xad', null=True, verbose_name=b'Anotace'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='id',
|
||||
field=models.AutoField(serialize=False, primary_key=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='obor',
|
||||
field=models.CharField(help_text=b'Podmno\xc5\xbeina MFIOB', max_length=5, verbose_name=b'Obor'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='seznam',
|
||||
field=models.ForeignKey(to='prednasky.Seznam_old'),
|
||||
),
|
||||
migrations.AlterModelTable(
|
||||
name='hlasovani',
|
||||
table='prednasky_hlasovani',
|
||||
),
|
||||
migrations.AlterModelTable(
|
||||
name='prednaska',
|
||||
table='prednasky_prednaska',
|
||||
),
|
||||
]
|
18
prednasky/migrations/0004_remove_prednaska_seznam.py
Normal file
18
prednasky/migrations/0004_remove_prednaska_seznam.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('prednasky', '0003_auto_20160929_0117'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='prednaska',
|
||||
name='seznam',
|
||||
),
|
||||
]
|
49
prednasky/migrations/0005_auto_20160929_0153.py
Normal file
49
prednasky/migrations/0005_auto_20160929_0153.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('seminar', '0041_konfery'),
|
||||
('prednasky', '0004_remove_prednaska_seznam'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Prednaska_Seznam',
|
||||
fields=[
|
||||
('id', models.AutoField(serialize=False, primary_key=True)),
|
||||
('prednaska', models.ForeignKey(to='prednasky.Prednaska')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'prednasky_prednaska_seznam',
|
||||
'verbose_name': 'P\u0159edn\xe1\u0161ka v seznamu',
|
||||
'verbose_name_plural': 'P\u0159edn\xe1\u0161ky v seznamech',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Seznam',
|
||||
fields=[
|
||||
('id', models.AutoField(serialize=False, primary_key=True)),
|
||||
('stav', models.IntegerField(default=2, verbose_name=b'Stav', choices=[(1, b'N\xc3\xa1vrh'), (2, b'Bude')])),
|
||||
('soustredeni', models.ForeignKey(default=None, to='seminar.Soustredeni', null=True)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['soustredeni', 'stav'],
|
||||
'db_table': 'prednasky_seznam',
|
||||
'verbose_name': 'Seznam p\u0159edn\xe1\u0161ek',
|
||||
'verbose_name_plural': 'Seznamy p\u0159edn\xe1\u0161ek',
|
||||
},
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='Seznam_old',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='prednaska_seznam',
|
||||
name='seznam',
|
||||
field=models.ForeignKey(to='prednasky.Seznam'),
|
||||
),
|
||||
]
|
20
prednasky/migrations/0006_hlasovani_seznam.py
Normal file
20
prednasky/migrations/0006_hlasovani_seznam.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('prednasky', '0005_auto_20160929_0153'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='hlasovani',
|
||||
name='seznam',
|
||||
field=models.ForeignKey(default=1, to='prednasky.Seznam'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
19
prednasky/migrations/0007_prednaska_seznamy.py
Normal file
19
prednasky/migrations/0007_prednaska_seznamy.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('prednasky', '0006_hlasovani_seznam'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='prednaska',
|
||||
name='seznamy',
|
||||
field=models.ManyToManyField(to='prednasky.Seznam'),
|
||||
),
|
||||
]
|
25
prednasky/migrations/0008_auto_20160929_0225.py
Normal file
25
prednasky/migrations/0008_auto_20160929_0225.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('prednasky', '0007_prednaska_seznamy'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='prednaska_seznam',
|
||||
name='prednaska',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='prednaska_seznam',
|
||||
name='seznam',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='Prednaska_Seznam',
|
||||
),
|
||||
]
|
49
prednasky/migrations/0009_auto_20160929_0354.py
Normal file
49
prednasky/migrations/0009_auto_20160929_0354.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('prednasky', '0008_auto_20160929_0225'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='anotace',
|
||||
field=models.TextField(help_text='Ve\u0159ejn\xe1 anotace v hlasov\xe1n\xed', null=True, verbose_name=b'Anotace'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='klicova',
|
||||
field=models.CharField(max_length=200, null=True, verbose_name='Kl\xed\u010dov\xe1 slova', blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='nazev',
|
||||
field=models.CharField(max_length=300, verbose_name='N\xe1zev'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='obor',
|
||||
field=models.CharField(help_text='Podmno\u017eina MFIOB', max_length=5, verbose_name='Obor'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='obtiznost',
|
||||
field=models.IntegerField(verbose_name='Obt\xed\u017enost', choices=[(1, b'Lehk\xc3\xa1'), (2, b'St\xc5\x99edn\xc3\xad'), (3, b'T\xc4\x9b\xc5\xbek\xc3\xa1')]),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='popis',
|
||||
field=models.TextField(help_text='Neve\u0159ejn\xfd popis pro ostatn\xed orgy', null=True, verbose_name='Popis pro orgy'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='seznam',
|
||||
name='stav',
|
||||
field=models.IntegerField(default=1, verbose_name=b'Stav', choices=[(1, b'N\xc3\xa1vrh'), (2, b'Bude')]),
|
||||
),
|
||||
]
|
24
prednasky/migrations/0010_auto_20160929_0508.py
Normal file
24
prednasky/migrations/0010_auto_20160929_0508.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('prednasky', '0009_auto_20160929_0354'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='anotace',
|
||||
field=models.TextField(help_text='Ve\u0159ejn\xe1 anotace v hlasov\xe1n\xed', null=True, verbose_name=b'Anotace', blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='prednaska',
|
||||
name='popis',
|
||||
field=models.TextField(help_text='Neve\u0159ejn\xfd popis pro ostatn\xed orgy', null=True, verbose_name='Popis pro orgy', blank=True),
|
||||
),
|
||||
]
|
|
@ -1,10 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.db import models
|
||||
from seminar.models import Organizator
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.encoding import force_unicode
|
||||
|
||||
from seminar.models import Organizator,Soustredeni
|
||||
|
||||
STAV_NAVRH = 1
|
||||
STAV_BUDE = 2
|
||||
|
||||
|
||||
STAV_CHOICES = (
|
||||
(STAV_NAVRH, 'Návrh'),
|
||||
(STAV_BUDE, 'Bude')
|
||||
)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Seznam(models.Model):
|
||||
pass
|
||||
class Meta:
|
||||
db_table = 'prednasky_seznam'
|
||||
verbose_name = u'Seznam přednášek'
|
||||
verbose_name_plural = u'Seznamy přednášek'
|
||||
ordering = ['soustredeni', 'stav']
|
||||
|
||||
id = models.AutoField(primary_key = True)
|
||||
soustredeni = models.ForeignKey(Soustredeni,null = True, default = None)
|
||||
stav = models.IntegerField('Stav',choices=STAV_CHOICES,default = STAV_NAVRH)
|
||||
|
||||
def __str__(self):
|
||||
return force_unicode(u"Seznam {}přednášek na {}".format(u"návrhů " if self.stav == STAV_NAVRH else "",self.soustredeni))
|
||||
|
||||
|
||||
CHOICES_OBTIZNOST = (
|
||||
(1, 'Lehká'),
|
||||
|
@ -18,17 +44,41 @@ CHOICES_BODY = (
|
|||
(1, '1'),
|
||||
)
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Prednaska(models.Model):
|
||||
nazev = models.CharField('Název', max_length = 300)
|
||||
org = models.ForeignKey(Organizator)
|
||||
anotace = models.TextField('Anotace')
|
||||
obtiznost = models.IntegerField('Obtížnost', choices=CHOICES_OBTIZNOST)
|
||||
obor = models.CharField('Obor', max_length = 5)
|
||||
klicova = models.CharField('Klíčová slova', max_length = 200, null = True, blank = True)
|
||||
seznam = models.ForeignKey(Seznam, blank = True, default = None)
|
||||
class Meta:
|
||||
db_table = 'prednasky_prednaska'
|
||||
verbose_name = u'Přednáška'
|
||||
verbose_name_plural = u'Přednášky'
|
||||
ordering = ['org', 'nazev']
|
||||
|
||||
id = models.AutoField(primary_key = True)
|
||||
nazev = models.CharField(u'Název', max_length = 300)
|
||||
org = models.ForeignKey(Organizator)
|
||||
popis = models.TextField(u'Popis pro orgy',null = True, blank = True,help_text = u'Neveřejný popis pro ostatní orgy')
|
||||
anotace = models.TextField('Anotace',null = True, blank = True, help_text = u'Veřejná anotace v hlasování')
|
||||
obtiznost = models.IntegerField(u'Obtížnost', choices=CHOICES_OBTIZNOST)
|
||||
obor = models.CharField(u'Obor', max_length = 5, help_text = u'Podmnožina MFIOB')
|
||||
klicova = models.CharField(u'Klíčová slova', max_length = 200, null = True, blank = True)
|
||||
seznamy = models.ManyToManyField(Seznam)
|
||||
|
||||
def __str__(self):
|
||||
return force_unicode(u"{} ({})".format(self.nazev,self.org))
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Hlasovani(models.Model):
|
||||
class Meta:
|
||||
db_table = 'prednasky_hlasovani'
|
||||
verbose_name = u'Hlasování'
|
||||
verbose_name_plural = u'Hlasování'
|
||||
ordering = ['ucastnik', 'prednaska']
|
||||
id = models.AutoField(primary_key = True)
|
||||
prednaska = models.ForeignKey(Prednaska)
|
||||
body = models.IntegerField('Body', default = 0, choices = CHOICES_BODY)
|
||||
ucastnik = models.CharField('Účastník', max_length = 100)
|
||||
seznam = models.ForeignKey(Seznam)
|
||||
|
||||
def __str__(self):
|
||||
return force_unicode(u"{} dal {} bodů {} v seznamu {}".format(self.ucastnik, self.body, self.prednaska,self.seznam))
|
||||
|
||||
|
|
26
prednasky/templates/prednasky/metaseznam_prednasek.html
Normal file
26
prednasky/templates/prednasky/metaseznam_prednasek.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
{% extends "prednasky/Base.html" %}
|
||||
|
||||
|
||||
{% block header %}hlasovani{% endblock %}
|
||||
|
||||
{% block nadpis1a %}{% block nadpis1b %}
|
||||
Hlasování o přednáškách
|
||||
{% endblock %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{# Projdi vsechny seznamy #}
|
||||
<div class="mam-org-only">
|
||||
<ul>
|
||||
{% for seznam in object_list %}
|
||||
<li>
|
||||
{% if seznam.stav == 1 %} {# STAV_NAHRH = 1 #}
|
||||
<a href="/prednasky/seznam_prednasek/{{seznam.id}}">Návrh přednášek na soustředění {{seznam.soustredeni.misto}} </a>
|
||||
{% else %}
|
||||
<a href="/prednasky/seznam_prednasek/{{seznam.id}}">Seznam přednášek na soustředění {{seznam.soustredeni.misto}} </a>
|
||||
{% endif %}
|
||||
<a href="/prednasky/seznam_prednasek/{{seznam.id}}/export">Export</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
|
21
prednasky/templates/prednasky/seznam_prednasek.html
Normal file
21
prednasky/templates/prednasky/seznam_prednasek.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
{% extends "prednasky/Base.html" %}
|
||||
|
||||
|
||||
{% block header %}seznam_prednasek{% endblock %}
|
||||
|
||||
{% block nadpis1a %}{% block nadpis1b %}
|
||||
Seznam přednášek
|
||||
{% endblock %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="mam-org-only">
|
||||
<ul>
|
||||
{# Projdi vsechny prednasky #}
|
||||
{% for prednaska in object_list %}
|
||||
<li>
|
||||
<strong>{{prednaska.nazev}}</strong> (<i>{{prednaska.obor}},{{prednaska.obtiznost}}</i>) - {{prednaska.org}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
|
21
prednasky/templates/prednasky/seznam_prednasek_export.txt
Normal file
21
prednasky/templates/prednasky/seznam_prednasek_export.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
{% block content %}
|
||||
{% spaceless %}
|
||||
{% for hlas in hlasovani %}
|
||||
hlas({{hlas.ucastnik}},{{hlas.prednaska.id}},{{hlas.body}})
|
||||
{% endfor %}
|
||||
{% for prednaska in prednasky %}
|
||||
prednaska({{prednaska.id}},{{prednaska.org.id}},{{prednaska.obtiznost}},{{prednaska.obor}})
|
||||
{% endfor %}
|
||||
{% for org in orgove %}
|
||||
org({{org.id}},4,0,15)
|
||||
{% endfor %}
|
||||
{% for org in orgove %}
|
||||
{{org.id}};{{org}}
|
||||
{% endfor %}
|
||||
{% for prednaska in prednasky %}
|
||||
{{prednaska.id}};{{prednaska.nazev}};{{prednaska.org.id}}
|
||||
{{prednaska.body}}
|
||||
{% endfor %}
|
||||
{% endspaceless %}
|
||||
{% endblock %}
|
||||
|
15
prednasky/urls.py
Normal file
15
prednasky/urls.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from django.conf.urls import * # NOQA
|
||||
from django.conf.urls import patterns, url
|
||||
from django.contrib.auth.decorators import user_passes_test
|
||||
from . import views
|
||||
|
||||
staff_member_required = user_passes_test(lambda u: u.is_staff)
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^prednasky/$', views.newPrednaska),
|
||||
url(r'^prednasky/hotovo$', views.Prednaska_hotovo),
|
||||
url(r'^prednasky/metaseznam_prednasek$', staff_member_required(views.MetaSeznamListView.as_view()), name='metaseznam-list'),
|
||||
url(r'^prednasky/seznam_prednasek/(?P<seznam>\d+)/$', staff_member_required(views.SeznamListView.as_view()), name='seznam-list'),
|
||||
url(r'^prednasky/seznam_prednasek/(?P<seznam>\d+)/export$', staff_member_required(views.SeznamExportView), name='seznam-export'),
|
||||
# url(r'^korektury/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'),
|
||||
]
|
|
@ -1,12 +1,19 @@
|
|||
from django.shortcuts import render
|
||||
from django.shortcuts import render,get_object_or_404
|
||||
from django.views import generic
|
||||
from prednasky.forms import NewPrednaskyForm
|
||||
from prednasky.models import Seznam, Hlasovani, Prednaska
|
||||
from django.shortcuts import HttpResponseRedirect
|
||||
|
||||
|
||||
from models import Prednaska, Seznam, STAV_NAVRH
|
||||
from seminar.models import Soustredeni
|
||||
|
||||
def newPrednaska(request):
|
||||
# zjistime k jakemu soustredeni se vaze nove vytvarena galerie
|
||||
prednasky = Seznam.objects.first()
|
||||
# obsluha formulare umoznujiciho multiple nahravani fotek
|
||||
# hlasovani se vztahuje k nejnovejsimu soustredeni
|
||||
sous = Soustredeni.objects.first()
|
||||
seznam = Seznam.objects.filter(soustredeni = sous, stav = STAV_NAVRH).first()
|
||||
print seznam
|
||||
# obsluha formulare
|
||||
if request.method == 'POST':
|
||||
form = NewPrednaskyForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
|
@ -18,6 +25,7 @@ def newPrednaska(request):
|
|||
hlasovani.prednaska = Prednaska.objects.filter(pk = int(i[1:]))[0]
|
||||
hlasovani.body = int(request.POST[i])
|
||||
hlasovani.ucastnik = jmeno
|
||||
hlasovani.seznam = seznam
|
||||
hlasovani.save()
|
||||
|
||||
# presmerovani na prave vzniklou galerii
|
||||
|
@ -28,11 +36,41 @@ def newPrednaska(request):
|
|||
|
||||
return render(request, 'prednasky/Base.html',
|
||||
{ 'form' : form,
|
||||
'prednasky' : prednasky,
|
||||
'prednasky' : seznam,
|
||||
})
|
||||
|
||||
def Prednaska_hotovo(request):
|
||||
return render(request, 'prednasky/hotovo.html')
|
||||
|
||||
|
||||
# Create your views here.
|
||||
class MetaSeznamListView(generic.ListView):
|
||||
model = Seznam
|
||||
template_name = 'prednasky/metaseznam_prednasek.html'
|
||||
|
||||
class SeznamListView(generic.ListView):
|
||||
template_name = 'prednasky/seznam_prednasek.html'
|
||||
def get_queryset(self):
|
||||
print self.kwargs
|
||||
self.seznam = get_object_or_404(Seznam,id=self.kwargs["seznam"])
|
||||
return Prednaska.objects.filter(seznamy = self.seznam)
|
||||
|
||||
|
||||
def SeznamExportView(request,seznam):
|
||||
seznam_obj = Seznam.objects.get(id=seznam)
|
||||
hlasovani = Hlasovani.objects.filter(seznam=seznam)
|
||||
prednasky = Prednaska.objects.filter(seznamy=seznam)
|
||||
orgove = set(map(lambda x:x.org,prednasky))
|
||||
ucastnici = list(set(map(lambda x:x.ucastnik,hlasovani)))
|
||||
|
||||
for p in prednasky:
|
||||
p.body = []
|
||||
for u in ucastnici:
|
||||
p.body.append(hlasovani.get(ucastnik=u,prednaska=p).body)
|
||||
|
||||
for h in hlasovani:
|
||||
h.ucastnik = hash(h.ucastnik)
|
||||
|
||||
return render(request, 'prednasky/seznam_prednasek_export.txt',
|
||||
{"hlasovani":hlasovani,"prednasky":prednasky,"orgove":orgove},
|
||||
content_type="text/plain")
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from django.db import models
|
|||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Novinky, Organizator, Prispevek, Pohadka
|
||||
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Novinky, Organizator, Prispevek, Pohadka, Konfera
|
||||
from autocomplete_light import shortcuts as autocomplete_light
|
||||
|
||||
|
||||
|
@ -181,6 +181,7 @@ class Soustredeni_UcastniciInline(admin.TabularInline):
|
|||
qs = super(Soustredeni_UcastniciInline, self).get_queryset(request)
|
||||
return qs.select_related('resitel', 'soustredeni')
|
||||
|
||||
|
||||
class Soustredeni_OrganizatoriInline(admin.TabularInline):
|
||||
form = autocomplete_light.modelform_factory(Soustredeni_Organizatori, autocomplete_fields=['organizator'], fields=['organizator'],)
|
||||
model = Soustredeni_Organizatori
|
||||
|
@ -468,6 +469,20 @@ class SoustredeniAdmin(VersionAdmin):
|
|||
|
||||
admin.site.register(Soustredeni, SoustredeniAdmin)
|
||||
|
||||
### Konfery
|
||||
class KonferaAdminForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model=Konfera
|
||||
exclude = []
|
||||
|
||||
class KonferaAdmin(VersionAdmin):
|
||||
form = KonferaAdminForm
|
||||
list_filter = ['soustredeni']
|
||||
list_display = ['nazev','soustredeni','organizator','typ_prezentace']
|
||||
# inlines = [Konfera_UcastniciInline]
|
||||
|
||||
admin.site.register(Konfera,KonferaAdmin)
|
||||
|
||||
### Novinky
|
||||
|
||||
class NovinkyAdminForm(forms.ModelForm):
|
||||
|
|
31
seminar/migrations/0042_auto_20161005_0847.py
Normal file
31
seminar/migrations/0042_auto_20161005_0847.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import seminar.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('seminar', '0041_konfery'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='konfera',
|
||||
name='materialy',
|
||||
field=models.FileField(help_text='Dal\u0161\xed materi\xe1ly ke konfe\u0159e zabalen\xe9 do jednoho souboru', upload_to=seminar.models.generate_filename_konfera, verbose_name='materialy', blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='konfera',
|
||||
name='prezentace',
|
||||
field=models.FileField(help_text='Prezentace nebo fotka posteru', upload_to=seminar.models.generate_filename_konfera, verbose_name='prezentace', blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='konfera',
|
||||
name='prispevek',
|
||||
field=models.ForeignKey(related_name='konfery', on_delete=django.db.models.deletion.SET_NULL, blank=True, to='seminar.Problem', help_text='\xda\u010dastnick\xfd p\u0159\xedp\u011bvek o konfe\u0159e', null=True, verbose_name='p\u0159\xedsp\u011bvek do \u010d\xedsla'),
|
||||
),
|
||||
]
|
|
@ -859,7 +859,7 @@ class Konfera(models.Model):
|
|||
org_poznamka = models.TextField(u'neveřejná poznámka', blank=True,
|
||||
help_text=u'Neveřejná poznámka ke konfeře(plain text)')
|
||||
prispevek = models.ForeignKey(Problem, verbose_name=u'příspěvek do čísla', related_name='konfery',
|
||||
help_text=u'Účastnický přípěvek o konfeře',on_delete = models.SET_NULL, null=True)
|
||||
help_text=u'Účastnický přípěvek o konfeře',on_delete = models.SET_NULL, null=True, blank=True)
|
||||
TYP_VELETRH = 'veletrh'
|
||||
TYP_PREZENTACE = 'prezentace'
|
||||
TYP_CHOICES = [
|
||||
|
@ -868,9 +868,9 @@ class Konfera(models.Model):
|
|||
]
|
||||
typ_prezentace = models.CharField(u'typ prezentace', max_length=16, choices=TYP_CHOICES, blank=False, default=TYP_VELETRH)
|
||||
prezentace = models.FileField(u'prezentace',help_text = u'Prezentace nebo fotka posteru',
|
||||
upload_to = generate_filename_konfera)
|
||||
upload_to = generate_filename_konfera, blank=True)
|
||||
materialy = models.FileField(u'materialy',help_text = u'Další materiály ke konfeře zabalené do jednoho souboru',
|
||||
upload_to = generate_filename_konfera)
|
||||
upload_to = generate_filename_konfera, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return force_unicode(u"%s: (%s)" % (self.nazev, self.soustredeni))
|
||||
|
|
|
@ -3,16 +3,11 @@ from django.conf.urls import patterns, url
|
|||
from django.contrib.auth.decorators import user_passes_test
|
||||
from . import views, export
|
||||
from utils import staff_member_required
|
||||
from prednasky.views import newPrednaska, Prednaska_hotovo
|
||||
from django.views.generic.base import RedirectView
|
||||
|
||||
staff_member_required = user_passes_test(lambda u: u.is_staff)
|
||||
|
||||
urlpatterns = [
|
||||
# prednasky
|
||||
#url(r'^prednasky/$', newPrednaska),
|
||||
#url(r'^prednasky/hotovo$', Prednaska_hotovo),
|
||||
|
||||
# REDIRECTy
|
||||
url(r'^jak-resit/$', RedirectView.as_view(url='/co-je-MaM/jak-resit/')),
|
||||
|
||||
|
|
Loading…
Reference in a new issue