2016-07-08 00:18:58 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import migrations, models
|
|
|
|
from django.utils import timezone
|
|
|
|
|
2016-07-13 10:46:46 +02:00
|
|
|
|
2016-07-08 00:18:58 +02:00
|
|
|
def forwards_func(apps, schema_editor):
|
|
|
|
Tirage = apps.get_model("bda", "Tirage")
|
|
|
|
db_alias = schema_editor.connection.alias
|
2016-07-13 10:46:46 +02:00
|
|
|
for tirage in Tirage.objects.using(db_alias).all():
|
|
|
|
if tirage.tokens:
|
2018-10-06 12:35:49 +02:00
|
|
|
tirage.tokens = 'Before %s\n"""%s"""\n' % (
|
|
|
|
timezone.now().strftime("%y-%m-%d %H:%M:%S"),
|
|
|
|
tirage.tokens,
|
|
|
|
)
|
2016-07-13 10:46:46 +02:00
|
|
|
tirage.save()
|
|
|
|
|
2016-07-08 00:18:58 +02:00
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
2018-10-06 12:35:49 +02:00
|
|
|
dependencies = [("bda", "0005_encoding")]
|
2016-07-08 00:18:58 +02:00
|
|
|
|
|
|
|
operations = [
|
2018-10-06 12:35:49 +02:00
|
|
|
migrations.RenameField("tirage", "token", "tokens"),
|
2016-07-08 00:18:58 +02:00
|
|
|
migrations.AddField(
|
2018-10-06 12:35:49 +02:00
|
|
|
model_name="tirage",
|
|
|
|
name="enable_do_tirage",
|
2016-07-29 19:03:36 +02:00
|
|
|
field=models.BooleanField(
|
2018-10-06 12:35:49 +02:00
|
|
|
default=False, verbose_name=b"Le tirage peut \xc3\xaatre lanc\xc3\xa9"
|
|
|
|
),
|
2016-07-08 00:18:58 +02:00
|
|
|
),
|
|
|
|
migrations.RunPython(forwards_func, migrations.RunPython.noop),
|
|
|
|
]
|