mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 00:12:15 +00:00
Split power related parts of event checklist into a seperate form
This commit is contained in:
71
RIGS/migrations/0046_create_powertests.py
Normal file
71
RIGS/migrations/0046_create_powertests.py
Normal file
@@ -0,0 +1,71 @@
|
||||
# Generated by Django 3.2.16 on 2023-05-08 15:58
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import versioning.versioning
|
||||
|
||||
def migrate_old_data(apps, schema_editor):
|
||||
EventChecklist = apps.get_model('RIGS', 'EventChecklist')
|
||||
PowerTestRecord = apps.get_model('RIGS', 'PowerTestRecord')
|
||||
for ec in EventChecklist.objects.all():
|
||||
# New highscore for the most pythonic BS I've ever written.
|
||||
PowerTestRecord.objects.create(event=ec.event, **{i.name:getattr(ec, i.attname) for i in PowerTestRecord._meta.get_fields() if not (i.is_relation or i.auto_created)})
|
||||
|
||||
|
||||
def revert(apps, schema_editor):
|
||||
apps.get_model('RIGS', 'PowerTestRecord').objects.all().delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('RIGS', '0045_alter_profile_is_approved'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='PowerTestRecord',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='power_tests', to='RIGS.event')),
|
||||
('notes', models.TextField(blank=True, default='')),
|
||||
('venue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='RIGS.venue')),
|
||||
('reviewed_at', models.DateTimeField(null=True)),
|
||||
('rcds', models.BooleanField(blank=True, help_text='RCDs installed where needed and tested?', null=True)),
|
||||
('supply_test', models.BooleanField(blank=True, help_text='Electrical supplies tested?<br><small>(using socket tester)</small>', null=True)),
|
||||
('earthing', models.BooleanField(blank=True, help_text='Equipment appropriately earthed?<br><small>(truss, stage, generators etc)</small>', null=True)),
|
||||
('pat', models.BooleanField(blank=True, help_text='All equipment in PAT period?', null=True)),
|
||||
('source_rcd', models.BooleanField(blank=True, help_text='Source RCD protected?<br><small>(if cable is more than 3m long) </small>', null=True)),
|
||||
('labelling', models.BooleanField(blank=True, help_text='Appropriate and clear labelling on distribution and cabling?', null=True)),
|
||||
('fd_voltage_l1', models.IntegerField(blank=True, help_text='L1 - N', null=True, verbose_name='First Distro Voltage L1-N')),
|
||||
('fd_voltage_l2', models.IntegerField(blank=True, help_text='L2 - N', null=True, verbose_name='First Distro Voltage L2-N')),
|
||||
('fd_voltage_l3', models.IntegerField(blank=True, help_text='L3 - N', null=True, verbose_name='First Distro Voltage L3-N')),
|
||||
('fd_phase_rotation', models.BooleanField(blank=True, help_text='Phase Rotation<br><small>(if required)</small>', null=True, verbose_name='Phase Rotation')),
|
||||
('fd_earth_fault', models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>)', max_digits=5, null=True, verbose_name='Earth Fault Loop Impedance')),
|
||||
('fd_pssc', models.IntegerField(blank=True, help_text='Prospective Short Circuit Current', null=True, verbose_name='PSCC')),
|
||||
('w1_description', models.CharField(blank=True, default='', help_text='Description', max_length=255)),
|
||||
('w1_polarity', models.BooleanField(blank=True, help_text='Polarity Checked?', null=True)),
|
||||
('w1_voltage', models.IntegerField(blank=True, help_text='Voltage', null=True)),
|
||||
('w1_earth_fault', models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>)', max_digits=5, null=True, verbose_name='Earth Fault Loop Impedance')),
|
||||
('w2_description', models.CharField(blank=True, default='', help_text='Description', max_length=255)),
|
||||
('w2_polarity', models.BooleanField(blank=True, help_text='Polarity Checked?', null=True)),
|
||||
('w2_voltage', models.IntegerField(blank=True, help_text='Voltage', null=True)),
|
||||
('w2_earth_fault', models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>)', max_digits=5, null=True, verbose_name='Earth Fault Loop Impedance')),
|
||||
('w3_description', models.CharField(blank=True, default='', help_text='Description', max_length=255)),
|
||||
('w3_polarity', models.BooleanField(blank=True, help_text='Polarity Checked?', null=True)),
|
||||
('w3_voltage', models.IntegerField(blank=True, help_text='Voltage', null=True)),
|
||||
('w3_earth_fault', models.DecimalField(blank=True, decimal_places=2, help_text='Earth Fault Loop Impedance (Z<small>S</small>)', max_digits=5, null=True, verbose_name='Earth Fault Loop Impedance')),
|
||||
('all_rcds_tested', models.BooleanField(blank=True, help_text='All circuit RCDs tested?<br><small>(using test button)</small>', null=True)),
|
||||
('public_sockets_tested', models.BooleanField(blank=True, help_text='Public/Performer accessible circuits tested?<br><small>(using socket tester)</small>', null=True)),
|
||||
('reviewed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Reviewer')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
'ordering': ['event'],
|
||||
'permissions': [('review_power', 'Can review Power Test Records')],
|
||||
},
|
||||
bases=(models.Model, versioning.versioning.RevisionMixin),
|
||||
),
|
||||
migrations.RunPython(migrate_old_data, reverse_code=revert),
|
||||
]
|
||||
117
RIGS/migrations/0047_auto_20230508_1946.py
Normal file
117
RIGS/migrations/0047_auto_20230508_1946.py
Normal file
@@ -0,0 +1,117 @@
|
||||
# Generated by Django 3.2.16 on 2023-05-08 18:46
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('RIGS', '0046_create_powertests'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='all_rcds_tested',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='earthing',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='fd_earth_fault',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='fd_phase_rotation',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='fd_pssc',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='fd_voltage_l1',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='fd_voltage_l2',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='fd_voltage_l3',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='labelling',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='pat',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='public_sockets_tested',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='rcds',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='source_rcd',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='supply_test',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w1_description',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w1_earth_fault',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w1_polarity',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w1_voltage',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w2_description',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w2_earth_fault',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w2_polarity',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w2_voltage',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w3_description',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w3_earth_fault',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w3_polarity',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='eventchecklist',
|
||||
name='w3_voltage',
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user