Web M&M
https://mam.matfyz.cz
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.5 KiB
82 lines
2.5 KiB
|
|
from django.db import models
|
|
from django.utils.encoding import force_text
|
|
|
|
from seminar.models import Organizator, Soustredeni
|
|
|
|
STAV_NAVRH = 1
|
|
STAV_BUDE = 2
|
|
|
|
|
|
STAV_CHOICES = (
|
|
(STAV_NAVRH, 'Návrh'),
|
|
(STAV_BUDE, 'Bude')
|
|
)
|
|
|
|
|
|
class Seznam(models.Model):
|
|
class Meta:
|
|
db_table = 'prednasky_seznam'
|
|
verbose_name = 'Seznam přednášek'
|
|
verbose_name_plural = 'Seznamy přednášek'
|
|
ordering = ['soustredeni', 'stav']
|
|
|
|
id = models.AutoField(primary_key = True)
|
|
soustredeni = models.ForeignKey(Soustredeni,null = True, default = None,
|
|
on_delete=models.PROTECT)
|
|
stav = models.IntegerField('Stav',choices=STAV_CHOICES,default = STAV_NAVRH)
|
|
|
|
def __str__(self):
|
|
return "Seznam {}přednášek na {}".format("návrhů "
|
|
if self.stav == STAV_NAVRH else "", self.soustredeni)
|
|
|
|
|
|
CHOICES_OBTIZNOST = (
|
|
(1, 'Lehká'),
|
|
(2, 'Střední'),
|
|
(3, 'Těžká'),
|
|
)
|
|
|
|
CHOICES_BODY = (
|
|
(-1, '-1'),
|
|
(0, '0'),
|
|
(1, '1'),
|
|
)
|
|
|
|
class Prednaska(models.Model):
|
|
class Meta:
|
|
db_table = 'prednasky_prednaska'
|
|
verbose_name = 'Přednáška'
|
|
verbose_name_plural = 'Přednášky'
|
|
ordering = ['org', 'nazev']
|
|
|
|
id = models.AutoField(primary_key = True)
|
|
nazev = models.CharField('Název', max_length = 300)
|
|
org = models.ForeignKey(Organizator, on_delete=models.PROTECT)
|
|
popis = models.TextField('Popis pro orgy',null = True, blank = True,help_text = 'Neveřejný popis pro ostatní orgy')
|
|
anotace = models.TextField('Anotace',null = True, blank = True, help_text = 'Veřejná anotace v hlasování')
|
|
obtiznost = models.IntegerField('Obtížnost', choices=CHOICES_OBTIZNOST)
|
|
obor = models.CharField('Obor', max_length = 5, help_text = 'Podmnožina MFIOB')
|
|
klicova = models.CharField('Klíčová slova', max_length = 200, null = True, blank = True)
|
|
seznamy = models.ManyToManyField(Seznam)
|
|
|
|
def __str__(self):
|
|
return "{} ({})".format(self.nazev, self.org)
|
|
|
|
|
|
class Hlasovani(models.Model):
|
|
class Meta:
|
|
db_table = 'prednasky_hlasovani'
|
|
verbose_name = 'Hlasování'
|
|
verbose_name_plural = 'Hlasování'
|
|
ordering = ['ucastnik', 'prednaska']
|
|
id = models.AutoField(primary_key = True)
|
|
prednaska = models.ForeignKey(Prednaska, on_delete=models.CASCADE)
|
|
body = models.IntegerField('Body', default = 0, choices = CHOICES_BODY)
|
|
ucastnik = models.CharField('Účastník', max_length = 100)
|
|
seznam = models.ForeignKey(Seznam,null=True,on_delete=models.SET_NULL)
|
|
|
|
def __str__(self):
|
|
return "{} dal {} bodů {} v seznamu {}".format(self.ucastnik,
|
|
self.body, self.prednaska, self.seznam)
|
|
|
|
|