mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-27 02:12:18 +00:00
Create the training database (#463)
Co-authored-by: josephjboyden <josephjboyden@gmail.com>
This commit is contained in:
18
RIGS/migrations/0043_auto_20211027_1519.py
Normal file
18
RIGS/migrations/0043_auto_20211027_1519.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.1.13 on 2021-10-27 14:19
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('RIGS', '0042_auto_20211007_2338'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='initials',
|
||||
field=models.CharField(max_length=5, null=True),
|
||||
),
|
||||
]
|
||||
18
RIGS/migrations/0044_profile_is_supervisor.py
Normal file
18
RIGS/migrations/0044_profile_is_supervisor.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.11 on 2022-01-09 14:56
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('RIGS', '0043_auto_20211027_1519'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='profile',
|
||||
name='is_supervisor',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
25
RIGS/migrations/0045_legacy_supervisors.py
Normal file
25
RIGS/migrations/0045_legacy_supervisors.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# Generated by Django 3.2.11 on 2022-01-09 15:00
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
from training.models import TrainingLevel
|
||||
|
||||
def find_existing_supervisors(apps, schema_editor):
|
||||
Profile = apps.get_model('RIGS', 'Profile')
|
||||
for person in Profile.objects.all():
|
||||
if person.level_qualifications.exclude(confirmed_on=None).select_related('level') \
|
||||
.filter(level__level__gte=TrainingLevel.SUPERVISOR) \
|
||||
.exclude(level__department=TrainingLevel.HAULAGE) \
|
||||
.exclude(level__department__isnull=True).exists():
|
||||
person.is_supervisor = True
|
||||
person.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('RIGS', '0044_profile_is_supervisor'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(find_existing_supervisors, migrations.RunPython.noop)
|
||||
]
|
||||
Reference in New Issue
Block a user