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.
37 lines
920 B
37 lines
920 B
![]()
5 years ago
|
# -*- 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),
|
||
|
]
|