Pridan model pro konfery.
This commit is contained in:
parent
bfa4f81310
commit
80bb6bd0b6
2 changed files with 146 additions and 64 deletions
70
seminar/migrations/0041_konfery.py
Normal file
70
seminar/migrations/0041_konfery.py
Normal file
|
@ -0,0 +1,70 @@
|
|||
# -*- 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', '0040_pohadka_nepovinny_autor'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Konfera',
|
||||
fields=[
|
||||
('id', models.AutoField(serialize=False, primary_key=True)),
|
||||
('nazev', models.CharField(help_text='N\xe1zev konfery', max_length=40, verbose_name='n\xe1zev konfery')),
|
||||
('popis', models.TextField(help_text='Popis konfery k zobrazen\xed na webu', verbose_name='popis konfery', blank=True)),
|
||||
('abstrakt', models.TextField(help_text='Abstrakt konfery tak, jak byl uveden ve sborn\xedku', verbose_name='abstrakt', blank=True)),
|
||||
('org_poznamka', models.TextField(help_text='Neve\u0159ejn\xe1 pozn\xe1mka ke konfe\u0159e(plain text)', verbose_name='neve\u0159ejn\xe1 pozn\xe1mka', blank=True)),
|
||||
('typ_prezentace', models.CharField(default=b'veletrh', max_length=16, verbose_name='typ prezentace', choices=[(b'veletrh', 'Veletrh (postery)'), (b'prezentace', 'Prezentace (p\u0159edn\xe1\u0161ka)')])),
|
||||
('prezentace', models.FileField(help_text='Prezentace nebo fotka posteru', upload_to=seminar.models.generate_filename_konfera, verbose_name='prezentace')),
|
||||
('materialy', 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')),
|
||||
('organizator', models.ForeignKey(related_name='konfery', on_delete=django.db.models.deletion.SET_NULL, verbose_name='organiz\xe1tor', to='seminar.Organizator', null=True)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'seminar_konfera',
|
||||
'verbose_name': 'Konfera',
|
||||
'verbose_name_plural': 'Konfery',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Konfery_Ucastnici',
|
||||
fields=[
|
||||
('id', models.AutoField(serialize=False, primary_key=True)),
|
||||
('poznamka', models.TextField(help_text='Neve\u0159ejn\xe1 pozn\xe1mka k \xfa\u010dasti (plain text)', verbose_name='neve\u0159ejn\xe1 pozn\xe1mka', blank=True)),
|
||||
('konfera', models.ForeignKey(verbose_name='konfera', to='seminar.Konfera')),
|
||||
('resitel', models.ForeignKey(verbose_name='\u0159e\u0161itel', to='seminar.Resitel')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['konfera', 'resitel'],
|
||||
'db_table': 'seminar_konfery_ucastnici',
|
||||
'verbose_name': '\xda\u010dast na konfe\u0159e',
|
||||
'verbose_name_plural': '\xda\u010dasti na konfe\u0159e',
|
||||
},
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='problem',
|
||||
name='typ',
|
||||
field=models.CharField(default=b'uloha', max_length=32, verbose_name='typ probl\xe9mu', choices=[(b'uloha', '\xdaloha'), (b'tema', 'T\xe9ma'), (b'serial', 'Seri\xe1l'), (b'konfera', 'Konfera'), (b'org-clanek', 'Organiz\xe1torsk\xfd \u010dl\xe1nek'), (b'res-clanek', '\u0158e\u0161itelsk\xfd \u010dl\xe1nek')]),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='konfera',
|
||||
name='prispevek',
|
||||
field=models.ForeignKey(related_name='konfery', on_delete=django.db.models.deletion.SET_NULL, verbose_name='p\u0159\xedsp\u011bvek do \u010d\xedsla', to='seminar.Problem', help_text='\xda\u010dastnick\xfd p\u0159\xedp\u011bvek o konfe\u0159e', null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='konfera',
|
||||
name='soustredeni',
|
||||
field=models.ForeignKey(related_name='konfery', on_delete=django.db.models.deletion.SET_NULL, verbose_name='soust\u0159ed\u011bn\xed', to='seminar.Soustredeni', null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='konfera',
|
||||
name='ucastnici',
|
||||
field=models.ManyToManyField(help_text='Seznam \xfa\u010dastn\xedk\u016f konfery', to='seminar.Resitel', verbose_name='\xfa\u010dastn\xedci konfery', through='seminar.Konfery_Ucastnici'),
|
||||
),
|
||||
]
|
|
@ -16,7 +16,7 @@ from imagekit.processors import ResizeToFit, Transpose
|
|||
|
||||
from PIL import Image
|
||||
import os
|
||||
from functools import partial
|
||||
#from functools import partial
|
||||
from cStringIO import StringIO
|
||||
from django.core.files.base import ContentFile
|
||||
|
||||
|
@ -402,12 +402,14 @@ class Problem(SeminarModelBase):
|
|||
TYP_ULOHA = 'uloha'
|
||||
TYP_TEMA = 'tema'
|
||||
TYP_SERIAL = 'serial'
|
||||
TYP_KONFERA = 'konfera'
|
||||
TYP_ORG_CLANEK = 'org-clanek'
|
||||
TYP_RES_CLANEK = 'res-clanek'
|
||||
TYP_CHOICES = [
|
||||
(TYP_ULOHA, u'Úloha'),
|
||||
(TYP_TEMA, u'Téma'),
|
||||
(TYP_SERIAL, u'Seriál'),
|
||||
(TYP_KONFERA, u'Konfera'),
|
||||
(TYP_ORG_CLANEK, u'Organizátorský článek'),
|
||||
(TYP_RES_CLANEK, u'Řešitelský článek'),
|
||||
]
|
||||
|
@ -547,6 +549,7 @@ class Reseni(SeminarModelBase):
|
|||
# PrilohaReseni method
|
||||
# TODO vyresit partial, tak aby slo migrovat
|
||||
#def generate_filename(self, filename, directory):
|
||||
# Django 1.9 podporuje partial
|
||||
def generate_filename(self, filename):
|
||||
clean = filename.replace('/','-').replace('\0', '')
|
||||
datedir = timezone.now().strftime('%Y-%m')
|
||||
|
@ -554,10 +557,18 @@ def generate_filename(self, filename):
|
|||
timezone.now().strftime('%Y-%m-%d-%H:%M'),
|
||||
clean)
|
||||
return os.path.join(settings.SEMINAR_RESENI_DIR, datedir, fname)
|
||||
def generate_filename_konfera(self, filename):
|
||||
clean = filename.replace('/','-').replace('\0', '')
|
||||
datedir = timezone.now().strftime('%Y-%m')
|
||||
fname = "%s_%s" % (
|
||||
timezone.now().strftime('%Y-%m-%d-%H:%M'),
|
||||
clean)
|
||||
return os.path.join(settings.SEMINAR_KONFERY_DIR, datedir, fname)
|
||||
# TODO vyresit partial tak, aby slo migrovat
|
||||
# return os.path.join(directory, datedir, fname)
|
||||
|
||||
|
||||
|
||||
@reversion.register(ignore_duplicate_revisions=True)
|
||||
@python_2_unicode_compatible
|
||||
class PrilohaReseni(SeminarModelBase):
|
||||
|
@ -811,69 +822,70 @@ class Soustredeni_Organizatori(models.Model):
|
|||
|
||||
|
||||
|
||||
#@reversion.register(ignore_duplicate_revisions=True)
|
||||
#@python_2_unicode_compatible
|
||||
#class Konfera(models.Model):
|
||||
# class Meta:
|
||||
# db_table = 'seminar_konfera'
|
||||
# verbose_name = u'Konfera'
|
||||
# verbose_name_plural = u'Konfery'
|
||||
# # Interní ID
|
||||
# id = models.AutoField(primary_key = True)
|
||||
# nazev = models.CharField(u'název konfery', max_length=40, help_text = u'Název konfery')
|
||||
# popis = models.TextField(u'popis konfery', blank=True,
|
||||
# help_text=u'Popis konfery k zobrazení na webu')
|
||||
# abstrakt = models.TextField(u'abstrakt', blank=True,
|
||||
# help_text=u'Abstrakt konfery tak, jak byl uveden ve sborníku')
|
||||
# organizator = models.ForeignKey(Organizator, verbose_name=u'organizátor', related_name='konfery',
|
||||
# on_delete = models.SET_NULL, null=True)
|
||||
# ucastnici = models.ManyToManyField(Resitel, verbose_name=u'účastníci konfery',
|
||||
# help_text=u'Seznam účastníků konfery', through='Konfery_Ucastnici')
|
||||
# soustredeni = models.ForeignKey(Soustredeni, verbose_name=u'soustředění', related_name='konfery',
|
||||
# on_delete = models.SET_NULL, null=True)
|
||||
# org_poznamka = models.TextField(u'neveřejná poznámka', blank=True,
|
||||
# help_text=u'Neveřejná poznámka ke konfeře(plain text)')
|
||||
# #prispevek #TODO
|
||||
# TYP_VELETRH = 'veletrh'
|
||||
# TYP_PREZENTACE = 'prezentace'
|
||||
# TYP_CHOICES = [
|
||||
# (TYP_VELETRH, u'Veletrh (postery)'),
|
||||
# (TYP_PREZENTACE, u'Prezentace (přednáška)'),
|
||||
# ]
|
||||
# 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 = partial(generate_filename,directory=settings.SEMINAR_KONFERY_DIR))
|
||||
# materialy = models.FileField(u'materialy',help_text = u'Další materiály ke konfeře zabalené do jednoho souboru',
|
||||
# upload_to = partial(generate_filename,directory=settings.SEMINAR_KONFERY_DIR))
|
||||
#
|
||||
# def __str__(self):
|
||||
# return force_unicode(u"%s: (%s)" % (self.nazev, self.soustredeni))
|
||||
#
|
||||
#
|
||||
#
|
||||
#@reversion.register(ignore_duplicate_revisions=True)
|
||||
#@python_2_unicode_compatible
|
||||
#class Konfery_Ucastnici(models.Model):
|
||||
#
|
||||
# class Meta:
|
||||
# db_table = 'seminar_konfery_ucastnici'
|
||||
# verbose_name = u'Účast na konfeře'
|
||||
# verbose_name_plural = u'Účasti na konfeře'
|
||||
# ordering = ['konfera', 'resitel']
|
||||
#
|
||||
# # Interní ID
|
||||
# id = models.AutoField(primary_key = True)
|
||||
#
|
||||
# resitel = models.ForeignKey(Resitel, verbose_name=u'řešitel')
|
||||
#
|
||||
# konfera = models.ForeignKey(Konfera, verbose_name=u'konfera')
|
||||
#
|
||||
# poznamka = models.TextField(u'neveřejná poznámka', blank=True,
|
||||
# help_text=u'Neveřejná poznámka k účasti (plain text)')
|
||||
#
|
||||
# def __str__(self):
|
||||
# return force_unicode(u'%s na %s' % (self.resitel, self.konfera, ))
|
||||
# # NOTE: Poteciální DB HOG bez select_related
|
||||
@reversion.register(ignore_duplicate_revisions=True)
|
||||
@python_2_unicode_compatible
|
||||
class Konfera(models.Model):
|
||||
class Meta:
|
||||
db_table = 'seminar_konfera'
|
||||
verbose_name = u'Konfera'
|
||||
verbose_name_plural = u'Konfery'
|
||||
# Interní ID
|
||||
id = models.AutoField(primary_key = True)
|
||||
nazev = models.CharField(u'název konfery', max_length=40, help_text = u'Název konfery')
|
||||
popis = models.TextField(u'popis konfery', blank=True,
|
||||
help_text=u'Popis konfery k zobrazení na webu')
|
||||
abstrakt = models.TextField(u'abstrakt', blank=True,
|
||||
help_text=u'Abstrakt konfery tak, jak byl uveden ve sborníku')
|
||||
organizator = models.ForeignKey(Organizator, verbose_name=u'organizátor', related_name='konfery',
|
||||
on_delete = models.SET_NULL, null=True)
|
||||
ucastnici = models.ManyToManyField(Resitel, verbose_name=u'účastníci konfery',
|
||||
help_text=u'Seznam účastníků konfery', through='Konfery_Ucastnici')
|
||||
soustredeni = models.ForeignKey(Soustredeni, verbose_name=u'soustředění', related_name='konfery',
|
||||
on_delete = models.SET_NULL, null=True)
|
||||
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)
|
||||
TYP_VELETRH = 'veletrh'
|
||||
TYP_PREZENTACE = 'prezentace'
|
||||
TYP_CHOICES = [
|
||||
(TYP_VELETRH, u'Veletrh (postery)'),
|
||||
(TYP_PREZENTACE, u'Prezentace (přednáška)'),
|
||||
]
|
||||
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)
|
||||
materialy = models.FileField(u'materialy',help_text = u'Další materiály ke konfeře zabalené do jednoho souboru',
|
||||
upload_to = generate_filename_konfera)
|
||||
|
||||
def __str__(self):
|
||||
return force_unicode(u"%s: (%s)" % (self.nazev, self.soustredeni))
|
||||
|
||||
|
||||
|
||||
@reversion.register(ignore_duplicate_revisions=True)
|
||||
@python_2_unicode_compatible
|
||||
class Konfery_Ucastnici(models.Model):
|
||||
|
||||
class Meta:
|
||||
db_table = 'seminar_konfery_ucastnici'
|
||||
verbose_name = u'Účast na konfeře'
|
||||
verbose_name_plural = u'Účasti na konfeře'
|
||||
ordering = ['konfera', 'resitel']
|
||||
|
||||
# Interní ID
|
||||
id = models.AutoField(primary_key = True)
|
||||
|
||||
resitel = models.ForeignKey(Resitel, verbose_name=u'řešitel')
|
||||
|
||||
konfera = models.ForeignKey(Konfera, verbose_name=u'konfera')
|
||||
|
||||
poznamka = models.TextField(u'neveřejná poznámka', blank=True,
|
||||
help_text=u'Neveřejná poznámka k účasti (plain text)')
|
||||
|
||||
def __str__(self):
|
||||
return force_unicode(u'%s na %s' % (self.resitel, self.konfera, ))
|
||||
# NOTE: Poteciální DB HOG bez select_related
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
|
|
Loading…
Reference in a new issue