-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change condition on signage & blade to select many of them
- Loading branch information
Showing
25 changed files
with
366 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Generated by Django 3.2.21 on 2023-10-13 13:26 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
def copy_infrastructure_conditions(apps, schema_editor): | ||
|
||
# Get conditions models to use them | ||
InfrastructureCondition = apps.get_model('infrastructure', 'InfrastructureCondition') | ||
SignageCondition = apps.get_model('signage', 'SignageCondition') | ||
BladeCondition = apps.get_model('signage', 'BladeCondition') | ||
|
||
Signage = apps.get_model('signage', 'Signage') | ||
Blade = apps.get_model('signage', 'Blade') | ||
|
||
# Copy InfrastructureCondition to SignageCondition and BladeCondition | ||
for condition in InfrastructureCondition.objects.all(): | ||
SignageCondition.objects.get_or_create(label=condition.label) | ||
BladeCondition.objects.get_or_create(label=condition.label) | ||
|
||
# Associate signage condition to signage condition_tmp | ||
for signage in Signage.objects.all(): | ||
if (signage.condition is not None): | ||
signage_condition, created = SignageCondition.objects.get_or_create(label=signage.condition.label) | ||
signage.condition_tmp.add(signage_condition) | ||
|
||
# Associate blade condition to blade condition_tmp | ||
for blade in Blade.objects.all(): | ||
if (blade.condition is not None): | ||
blade_condition, created = BladeCondition.objects.get_or_create(label=blade.condition.label) | ||
blade.condition_tmp.add(blade_condition) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('authent', '0011_alter_userprofile_structure'), | ||
('signage', '0035_delete_pictogramname'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='SignageCondition', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('date_insert', models.DateTimeField(auto_now_add=True, verbose_name='Insertion date')), | ||
('date_update', models.DateTimeField(auto_now=True, db_index=True, verbose_name='Update date')), | ||
('label', models.CharField(max_length=250, verbose_name='Name')), | ||
('structure', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='authent.structure', verbose_name='Related structure')), | ||
], | ||
options={ | ||
'verbose_name': 'Signage Condition', | ||
'verbose_name_plural': 'Signage Conditions', | ||
'ordering': ('label',), | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='BladeCondition', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('date_insert', models.DateTimeField(auto_now_add=True, verbose_name='Insertion date')), | ||
('date_update', models.DateTimeField(auto_now=True, db_index=True, verbose_name='Update date')), | ||
('label', models.CharField(max_length=250, verbose_name='Name')), | ||
('structure', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='authent.structure', verbose_name='Related structure')), | ||
], | ||
options={ | ||
'verbose_name': 'Blade Condition', | ||
'verbose_name_plural': 'Blade Conditions', | ||
'ordering': ('label',), | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='blade', | ||
name='condition_tmp', | ||
field=models.ManyToManyField(blank=True, related_name='blades', to='signage.BladeCondition', verbose_name='Condition'), | ||
), | ||
migrations.AddField( | ||
model_name='signage', | ||
name='condition_tmp', | ||
field=models.ManyToManyField(blank=True, related_name='signages', to='signage.SignageCondition', verbose_name='Condition'), | ||
), | ||
migrations.RunPython(copy_infrastructure_conditions, reverse_code=migrations.RunPython.noop), | ||
] |
Oops, something went wrong.