Browse Source

Uprava modelu (rok maturity, timestamp definice)

remotes/origin/feincms
Tomas Gavenciak 10 years ago
parent
commit
0d6d1cb440
  1. 20
      seminar/migrations/0010_alter_rok_maturity.py
  2. 39
      seminar/migrations/0011_alter_timestamp_def.py
  3. 15
      seminar/models.py

20
seminar/migrations/0010_alter_rok_maturity.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('seminar', '0009_rename_imported_IDs'),
]
operations = [
migrations.AlterField(
model_name='resitel',
name='rok_maturity',
field=models.IntegerField(null=True, verbose_name='rok maturity', blank=True),
preserve_default=True,
),
]

39
seminar/migrations/0011_alter_timestamp_def.py

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('seminar', '0010_alter_rok_maturity'),
]
operations = [
migrations.AlterField(
model_name='prilohareseni',
name='timestamp',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='vytvo\u0159eno', editable=False, blank=True),
preserve_default=True,
),
migrations.AlterField(
model_name='problem',
name='import_dakos_id',
field=models.CharField(default=b'', help_text='ID z importu z DAKOSU s prefixem podle p\u016fvodu: "AZAD:xxx (MAMOPER.MM_AZAD), ""DOZ:xxx" (MAMOPER.MM_DOZ), "ZAD:rocnik.cislo.uloha.typ" (MAMOPER.MM_ZADANIA), "ULOHA:xxx" (MAMOPER.MM_ULOHY)', max_length=32, verbose_name='importovan\xe9 ID s typem', blank=True),
preserve_default=True,
),
migrations.AlterField(
model_name='problem',
name='timestamp',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='vytvo\u0159eno', editable=False, blank=True),
preserve_default=True,
),
migrations.AlterField(
model_name='reseni',
name='timestamp',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='vytvo\u0159eno', editable=False, blank=True),
preserve_default=True,
),
]

15
seminar/models.py

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import datetime
import random import random
from django.db import models from django.db import models
@ -130,7 +129,7 @@ class Resitel(SeminarModelBase):
skola = models.ForeignKey(Skola, blank=True, null=True, verbose_name=u'škola') skola = models.ForeignKey(Skola, blank=True, null=True, verbose_name=u'škola')
# Očekávaný rok maturity a vyřazení z aktivních řešitelů # Očekávaný rok maturity a vyřazení z aktivních řešitelů
rok_maturity = models.IntegerField(u'rok maturity') rok_maturity = models.IntegerField(u'rok maturity', blank=True, null=True)
email = models.EmailField(u'e-mail', max_length=256, blank=True, default='') email = models.EmailField(u'e-mail', max_length=256, blank=True, default='')
@ -332,12 +331,12 @@ class Problem(SeminarModelBase):
body = models.IntegerField(u'maximum bodů', blank=True, null=True) body = models.IntegerField(u'maximum bodů', blank=True, null=True)
timestamp = models.DateTimeField(u'vytvořeno', auto_now=True) timestamp = models.DateTimeField(u'vytvořeno', default=timezone.now, blank=True, editable=False)
# Staré (do 2014) ID problému z DAKOSU -- jen u importovaných záznamů # Staré (do 2014) ID problému z DAKOSU -- jen u importovaných záznamů
import_dakos_id = models.CharField(u'importované ID s typem', max_length=32, blank=True, default='', import_dakos_id = models.CharField(u'importované ID s typem', max_length=32, blank=True, default='',
help_text=(u'ID z importu z DAKOSU s prefixem podle původu: "AZAD:xxx (MAMOPER.MM_AZAD), "' + help_text=(u'ID z importu z DAKOSU s prefixem podle původu: "AZAD:xxx (MAMOPER.MM_AZAD), "' +
u'"DOZ:xxx" (MAMOPER.MM_DOZ), "ZAD:rocnik.cislo.uloha.typ" (MAMOPER.MM_ZADANIA)')) u'"DOZ:xxx" (MAMOPER.MM_DOZ), "ZAD:rocnik.cislo.uloha.typ" (MAMOPER.MM_ZADANIA), "ULOHA:xxx" (MAMOPER.MM_ULOHY)'))
def __str__(self): def __str__(self):
return force_unicode(u'%s (%s)' % (self.nazev, self.stav)) return force_unicode(u'%s (%s)' % (self.nazev, self.stav))
@ -378,7 +377,7 @@ class Reseni(SeminarModelBase):
cislo_body = models.ForeignKey(Cislo, verbose_name=u'číslo pro body', related_name='bodovana_reseni', blank=True, null=True) cislo_body = models.ForeignKey(Cislo, verbose_name=u'číslo pro body', related_name='bodovana_reseni', blank=True, null=True)
timestamp = models.DateTimeField(u'vytvořeno', auto_now=True) timestamp = models.DateTimeField(u'vytvořeno', default=timezone.now, blank=True, editable=False)
FORMA_PAPIR = 'papir' FORMA_PAPIR = 'papir'
FORMA_EMAIL = 'email' FORMA_EMAIL = 'email'
@ -400,9 +399,9 @@ class Reseni(SeminarModelBase):
# PrilohaReseni method # PrilohaReseni method
def generate_filename(self, filename): def generate_filename(self, filename):
clean = filename.replace('/','-').replace('\0', '') clean = filename.replace('/','-').replace('\0', '')
datedir = datetime.datetime.now().strftime('%Y-%m') datedir = timezone.now().strftime('%Y-%m')
fname = "%s_%s" % ( fname = "%s_%s" % (
datetime.datetime.now().strftime('%Y-%m-%d-%H:%M'), timezone.now().strftime('%Y-%m-%d-%H:%M'),
clean) clean)
return os.path.join(settings.SEMINAR_RESENI_DIRNAME, datedir, fname) return os.path.join(settings.SEMINAR_RESENI_DIRNAME, datedir, fname)
@ -422,7 +421,7 @@ class PrilohaReseni(SeminarModelBase):
reseni = models.ForeignKey(Reseni, verbose_name=u'řešení', related_name='prilohy') reseni = models.ForeignKey(Reseni, verbose_name=u'řešení', related_name='prilohy')
timestamp = models.DateTimeField(u'vytvořeno', auto_now=True) timestamp = models.DateTimeField(u'vytvořeno', default=timezone.now, blank=True, editable=False)
soubor = models.FileField(u'soubor', upload_to = generate_filename) soubor = models.FileField(u'soubor', upload_to = generate_filename)

Loading…
Cancel
Save