|
| 1 | +# Copyright The IETF Trust 2021 All Rights Reserved |
| 2 | + |
| 3 | +# Generated by Django 2.2.24 on 2021-09-26 11:29 |
| 4 | + |
| 5 | +from django.db import migrations |
| 6 | + |
| 7 | + |
| 8 | +default_purposes = dict( |
| 9 | + adhoc=['presentation'], |
| 10 | + adm=['closed_meeting', 'officehours'], |
| 11 | + ag=['regular'], |
| 12 | + area=['regular'], |
| 13 | + dir=['open_meeting', 'presentation', 'regular', 'social', 'tutorial'], |
| 14 | + iab=['closed_meeting', 'regular'], |
| 15 | + iabasg=['closed_meeting', 'officehours', 'open_meeting'], |
| 16 | + iana=['officehours'], |
| 17 | + iesg=['closed_meeting', 'open_meeting'], |
| 18 | + ietf=['admin', 'plenary', 'presentation', 'social'], |
| 19 | + irtf=[], |
| 20 | + ise=['officehours'], |
| 21 | + isoc=['officehours', 'open_meeting', 'presentation'], |
| 22 | + nomcom=['closed_meeting', 'officehours'], |
| 23 | + program=['regular', 'tutorial'], |
| 24 | + rag=['regular'], |
| 25 | + review=['open_meeting', 'social'], |
| 26 | + rfcedtyp=['officehours'], |
| 27 | + rg=['regular'], |
| 28 | + team=['coding', 'presentation', 'social', 'tutorial'], |
| 29 | + wg=['regular'], |
| 30 | +) |
| 31 | + |
| 32 | + |
| 33 | +def forward(apps, schema_editor): |
| 34 | + GroupFeatures = apps.get_model('group', 'GroupFeatures') |
| 35 | + SessionPurposeName = apps.get_model('name', 'SessionPurposeName') |
| 36 | + |
| 37 | + # verify that we're not about to use an invalid purpose |
| 38 | + for purposes in default_purposes.values(): |
| 39 | + for purpose in purposes: |
| 40 | + SessionPurposeName.objects.get(pk=purpose) # throws an exception unless exists |
| 41 | + |
| 42 | + for type_, purposes in default_purposes.items(): |
| 43 | + GroupFeatures.objects.filter( |
| 44 | + type=type_ |
| 45 | + ).update( |
| 46 | + session_purposes=purposes |
| 47 | + ) |
| 48 | + |
| 49 | +def reverse(apps, schema_editor): |
| 50 | + GroupFeatures = apps.get_model('group', 'GroupFeatures') |
| 51 | + GroupFeatures.objects.update(session_purposes=[]) # clear back out to default |
| 52 | + |
| 53 | + |
| 54 | +class Migration(migrations.Migration): |
| 55 | + |
| 56 | + dependencies = [ |
| 57 | + ('group', '0052_groupfeatures_session_purposes'), |
| 58 | + ('name', '0035_populate_sessionpurposename'), |
| 59 | + |
| 60 | + ] |
| 61 | + |
| 62 | + operations = [ |
| 63 | + migrations.RunPython(forward, reverse), |
| 64 | + ] |
0 commit comments