prednasky | model + admin + migrace
This commit is contained in:
parent
4dd5ca6e9f
commit
126b4b9cfc
10 changed files with 183 additions and 66 deletions
|
@ -121,6 +121,7 @@ INSTALLED_APPS = (
|
|||
'seminar',
|
||||
'galerie',
|
||||
'korektury',
|
||||
'prednasky',
|
||||
|
||||
# Admin upravy:
|
||||
|
||||
|
|
0
prednasky/__init__.py
Normal file
0
prednasky/__init__.py
Normal file
7
prednasky/admin.py
Normal file
7
prednasky/admin.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from models import Prednaska, Seznam, Hlasovani
|
||||
|
||||
admin.site.register(Seznam)
|
||||
admin.site.register(Prednaska)
|
||||
admin.site.register(Hlasovani)
|
45
prednasky/migrations/0001_initial.py
Normal file
45
prednasky/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('seminar', '0036_add_org_to_soustredeni'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Hlasovani',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('body', models.IntegerField(default=0, verbose_name=b'Body', choices=[(0, b'0'), (1, b'1'), (-1, b'-1')])),
|
||||
('ucastnik', models.CharField(max_length=100, verbose_name=b'\xc3\x9a\xc4\x8dastn\xc3\xadk')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Prednaska',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('nazev', models.CharField(max_length=300, verbose_name=b'N\xc3\xa1zev')),
|
||||
('anotace', models.TextField(verbose_name=b'Anotace')),
|
||||
('obtiznost', models.IntegerField(verbose_name=b'Obt\xc3\xad\xc5\xbenost', choices=[(1, b'Lehk\xc3\xa1'), (2, b'St\xc5\x99edn\xc3\xad'), (3, b'T\xc4\x9b\xc5\xbek\xc3\xa1')])),
|
||||
('obor', models.CharField(max_length=5, verbose_name=b'Obor')),
|
||||
('klicova', models.CharField(max_length=200, null=True, verbose_name=b'Kl\xc3\xad\xc4\x8dov\xc3\xa1 slova', blank=True)),
|
||||
('org', models.ForeignKey(to='seminar.Organizator')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Seznam',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='hlasovani',
|
||||
name='prednaska',
|
||||
field=models.ForeignKey(to='prednasky.Prednaska'),
|
||||
),
|
||||
]
|
24
prednasky/migrations/0002_auto_20160417_2347.py
Normal file
24
prednasky/migrations/0002_auto_20160417_2347.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', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='prednaska',
|
||||
name='seznam',
|
||||
field=models.ForeignKey(default=None, blank=True, to='prednasky.Seznam'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='hlasovani',
|
||||
name='body',
|
||||
field=models.IntegerField(default=0, verbose_name=b'Body', choices=[(-1, b'-1'), (0, b'0'), (1, b'1')]),
|
||||
),
|
||||
]
|
0
prednasky/migrations/__init__.py
Normal file
0
prednasky/migrations/__init__.py
Normal file
34
prednasky/models.py
Normal file
34
prednasky/models.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.db import models
|
||||
from seminar.models import Organizator
|
||||
|
||||
class Seznam(models.Model):
|
||||
pass
|
||||
|
||||
CHOICES_OBTIZNOST = (
|
||||
(1, 'Lehká'),
|
||||
(2, 'Střední'),
|
||||
(3, 'Těžká'),
|
||||
)
|
||||
|
||||
CHOICES_BODY = (
|
||||
(-1, '-1'),
|
||||
(0, '0'),
|
||||
(1, '1'),
|
||||
)
|
||||
|
||||
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 Hlasovani(models.Model):
|
||||
prednaska = models.ForeignKey(Prednaska)
|
||||
body = models.IntegerField('Body', default = 0, choices = CHOICES_BODY)
|
||||
ucastnik = models.CharField('Účastník', max_length = 100)
|
||||
|
3
prednasky/tests.py
Normal file
3
prednasky/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
prednasky/views.py
Normal file
3
prednasky/views.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
|
@ -545,13 +545,13 @@ class Reseni(SeminarModelBase):
|
|||
|
||||
|
||||
# PrilohaReseni method
|
||||
def generate_filename(self, filename, directory):
|
||||
def generate_filename(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(directory, datedir, fname)
|
||||
return os.path.join(settings.SEMINAR_RESENI_DIR, datedir, fname)
|
||||
|
||||
|
||||
@reversion.register(ignore_duplicate_revisions=True)
|
||||
|
@ -571,7 +571,7 @@ class PrilohaReseni(SeminarModelBase):
|
|||
|
||||
timestamp = models.DateTimeField(u'vytvořeno', default=timezone.now, blank=True, editable=False)
|
||||
|
||||
soubor = models.FileField(u'soubor', upload_to = partial(generate_filename,directory=settings.SEMINAR_RESENI_DIR))
|
||||
soubor = models.FileField(u'soubor', upload_to = generate_filename)
|
||||
|
||||
poznamka = models.TextField(u'neveřejná poznámka', blank=True,
|
||||
help_text=u'Neveřejná poznámka k příloze řešení (plain text), např. o původu')
|
||||
|
@ -736,69 +736,69 @@ 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 #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
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
|
|
Loading…
Reference in a new issue