forked from DGNum/gestioCOF
9e50a825e0
Le switch permet d'autoriser/interdire le lancement d'un tirage. Il s'agit d'une sécurité face aux erreurs d'inattention. Le champ `token` du modèle `Tirage` devient `tokens` et stocke les graines des tirages déjà lancés si le tirage est lancé plusieurs fois.
30 lines
987 B
Python
30 lines
987 B
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import unicode_literals
|
|
|
|
from django.db import migrations, models
|
|
from django.utils import timezone
|
|
|
|
def forwards_func(apps, schema_editor):
|
|
Tirage = apps.get_model("bda", "Tirage")
|
|
db_alias = schema_editor.connection.alias
|
|
for tirage in Tirage.objects.all():
|
|
tirage.tokens = "Before %s\n\"\"\"%s\"\"\"\n" % (
|
|
timezone.now().strftime("%y-%m-%d %H:%M:%S"),
|
|
tirage.tokens)
|
|
tirage.save()
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('bda', '0003_update_tirage_and_spectacle'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RenameField('tirage', 'token', 'tokens'),
|
|
migrations.AddField(
|
|
model_name='tirage',
|
|
name='enable_do_tirage',
|
|
field=models.BooleanField(default=False, verbose_name=b'Le tirage peut \xc3\xaatre lanc\xc3\xa9'),
|
|
),
|
|
migrations.RunPython(forwards_func, migrations.RunPython.noop),
|
|
]
|