Browse Source

Opraveno organizuje od a organizuje do

export_seznamu_prednasek
parent
commit
f054d9785a
  1. 2
      seminar/migrations/0049_auto_20190430_2354.py
  2. 36
      seminar/migrations/0053_organizator_organizuje_od_do.py
  3. 2
      seminar/models.py

2
seminar/migrations/0049_auto_20190430_2354.py

@ -219,7 +219,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='organizator', model_name='organizator',
name='organizuje_od', name='organizuje_od',
field=models.DateTimeField(default='1900-01-01T00:00:00', verbose_name='Organizuje od'), field=models.DateTimeField(null=True,blank=True, verbose_name='Organizuje od'),
), ),
migrations.AddField( migrations.AddField(
model_name='organizator', model_name='organizator',

36
seminar/migrations/0053_organizator_organizuje_od_do.py

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-05-16 21:26
from __future__ import unicode_literals
import datetime as dt
from django.db import migrations
def rok_to_datetime(apps,schema_editor):
Organizator = apps.get_model('seminar','Organizator')
for o in Organizator.objects.all():
rok = o.organizuje_od_roku
if rok:
o.organizuje_od = dt.datetime(rok,1,1)
rok = o.organizuje_do_roku
if rok:
o.organizuje_do = dt.datetime(rok,12,31)
o.save()
def datetime_to_rok(apps,schema_editor):
Organizator = apps.get_model('seminar','Organizator')
for o in Organizator.objects.all():
o.organizuje_od_roku = o.organizuje_od.year
o.organizuje_do_roku = o.organizuje_do.year
o.save()
class Migration(migrations.Migration):
dependencies = [
('seminar', '0052_user_to_organizator'),
]
operations = [
migrations.RunPython(rok_to_datetime, datetime_to_rok),
]

2
seminar/models.py

@ -467,7 +467,7 @@ class Organizator(SeminarModelBase):
editable=False editable=False
) )
organizuje_od = models.DateTimeField('Organizuje od', blank=False, null=False, default="1900-01-01T00:00:00") organizuje_od = models.DateTimeField('Organizuje od', blank=True, null=True)
organizuje_do = models.DateTimeField('Organizuje do', blank=True, null=True) organizuje_do = models.DateTimeField('Organizuje do', blank=True, null=True)

Loading…
Cancel
Save