Set start and end date from change log dates fixes #342
This commit is contained in:
Родитель
1294dd0983
Коммит
48f26b2527
|
@ -5,6 +5,25 @@ from __future__ import unicode_literals
|
|||
from django.db import migrations, models
|
||||
|
||||
|
||||
def update_dates(apps, schema_editor): # pragma: no cover
|
||||
Experiment = apps.get_model('experiments', 'Experiment')
|
||||
ExperimentChangeLog = apps.get_model('experiments', 'ExperimentChangeLog')
|
||||
|
||||
for experiment in Experiment.objects.all():
|
||||
try:
|
||||
start_date = ExperimentChangeLog.objects.get(experiment=experiment, old_status='Accepted', new_status='Launched').changed_on
|
||||
experiment.proposed_start_date = start_date
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
end_date = ExperimentChangeLog.objects.get(experiment=experiment, old_status='Launched', new_status='Complete').changed_on
|
||||
experiment.proposed_end_date = end_date
|
||||
except:
|
||||
pass
|
||||
experiment.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
|
@ -27,4 +46,5 @@ class Migration(migrations.Migration):
|
|||
name='firefox_version',
|
||||
field=models.CharField(choices=[('55.0', '55.0'), ('56.0', '56.0'), ('57.0', '57.0'), ('58.0', '58.0'), ('59.0', '59.0'), ('60.0', '60.0'), ('61.0', '61.0'), ('62.0', '62.0'), ('63.0', '63.0'), ('64.0', '64.0')], max_length=255),
|
||||
),
|
||||
migrations.RunPython(update_dates),
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче