mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 16:32:15 +00:00
More efficient, but it does reduce app seperation. Probably not an issue for us!
26 lines
856 B
Python
26 lines
856 B
Python
# 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)
|
|
]
|