Skip to content

Commit 9ae4f5e

Browse files
committed
style: include migrations to ruff-config
Apply ruff formatting. Refs: PT-1947
1 parent c17fad3 commit 9ae4f5e

11 files changed

Lines changed: 79 additions & 62 deletions

occurrences/migrations/0023_study_level_data.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def init_study_levels(apps, schema_editor):
1818

1919
translation.activate("en")
2020
for level in range(len(StudyGroupStudyLevels.STUDY_LEVELS)):
21-
id, en_label = StudyGroupStudyLevels.STUDY_LEVELS[level]
21+
_id, en_label = StudyGroupStudyLevels.STUDY_LEVELS[level]
2222
# Multiply by 10, so it's easier to add new levels between existing ones.
2323
study_level = NewStudyLevel(
24-
id=id,
24+
id=_id,
2525
level=level * 10,
2626
)
2727
study_level.label = en_label
@@ -33,8 +33,8 @@ def clear_study_levels(apps, schema_editor):
3333
Reverse for init_study_levels: Clears the StudyLevel table.
3434
"""
3535

36-
StudyLevel = apps.get_model("occurrences", "StudyLevel")
37-
StudyLevel.objects.all().delete()
36+
study_level_model = apps.get_model("occurrences", "StudyLevel")
37+
study_level_model.objects.all().delete()
3838

3939

4040
def link_study_levels(apps, schema_editor):
@@ -48,19 +48,19 @@ def link_study_levels(apps, schema_editor):
4848

4949
# The StudyGroup model cannot be imported directly as it has been changed.
5050
# The historical version must be used instead.
51-
StudyGroup = apps.get_model("occurrences", "StudyGroup")
52-
ThroughModel = NewStudyGroup.study_levels.through
51+
study_group_model = apps.get_model("occurrences", "StudyGroup")
52+
through_model = NewStudyGroup.study_levels.through
5353

5454
new_objects = [
55-
ThroughModel(studygroup_id=studygroup_id, studylevel_id=studylevel_id)
56-
for studygroup_id, studylevel_id in StudyGroup.objects.exclude(
55+
through_model(studygroup_id=studygroup_id, studylevel_id=studylevel_id)
56+
for studygroup_id, studylevel_id in study_group_model.objects.exclude(
5757
study_level__isnull=True
5858
)
5959
.exclude(study_level__exact="")
6060
.values_list("id", "study_level")
6161
]
6262

63-
ThroughModel.objects.bulk_create(new_objects)
63+
through_model.objects.bulk_create(new_objects)
6464

6565

6666
def reverse_link_study_levels(apps, schema_editor):
@@ -69,8 +69,8 @@ def reverse_link_study_levels(apps, schema_editor):
6969
StudyGroups and StudyLevels and populates a study_level field.
7070
"""
7171

72-
StudyLevel = apps.get_model("occurrences", "StudyLevel")
73-
for study_level in StudyLevel.objects.all():
72+
study_level_model = apps.get_model("occurrences", "StudyLevel")
73+
for study_level in study_level_model.objects.all():
7474
study_level.study_groups.all().update(study_level=study_level.id)
7575

7676

occurrences/migrations/0038_deletable_person_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by Django 3.2.13 on 2022-12-27 14:03
22

3-
from django.db import migrations, models
43
import django.db.models.deletion
4+
from django.db import migrations, models
55

66

77
class Migration(migrations.Migration):

occurrences/migrations/0039_deletable_contact_info_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by Django 3.2.13 on 2022-12-29 09:58
22

3-
from django.db import migrations, models
43
import django.db.models.deletion
4+
from django.db import migrations, models
55

66

77
class Migration(migrations.Migration):

occurrences/migrations/0044_add_group_name_to_studygroup_order_by.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
9-
('occurrences', '0043_add_is_queueing_allowed_and_preferred_times'),
8+
("occurrences", "0043_add_is_queueing_allowed_and_preferred_times"),
109
]
1110

1211
operations = [
1312
migrations.AlterModelOptions(
14-
name='studygroup',
15-
options={'ordering': ['created_at', 'group_name'], 'verbose_name': 'study group', 'verbose_name_plural': 'study groups'},
13+
name="studygroup",
14+
options={
15+
"ordering": ["created_at", "group_name"],
16+
"verbose_name": "study group",
17+
"verbose_name_plural": "study groups",
18+
},
1619
),
1720
]

organisations/migrations/0001_initial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Generated by Django 2.2.10 on 2020-04-29 09:17
22

3+
import uuid
4+
35
import django.contrib.auth.models
46
import django.contrib.auth.validators
57
import django.db.models.deletion
68
import django.utils.timezone
7-
import uuid
89
from django.conf import settings
910
from django.db import migrations, models
1011

organisations/migrations/0010_fix_user_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Generated by Django 3.2.13 on 2023-01-05 08:24
22

33
from django.db import migrations
4+
45
import organisations.models
56

67

organisations/migrations/0013_user_is_event_staff_alter_user_is_admin_and_more.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,36 @@
44

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
9-
('organisations', '0012_alter_person_options'),
8+
("organisations", "0012_alter_person_options"),
109
]
1110

1211
operations = [
1312
migrations.AddField(
14-
model_name='user',
15-
name='is_event_staff',
16-
field=models.BooleanField(default=False, help_text='Designates whether the user can access the Kultus Admin UI (React app) as an event provider to manage events and their enrolments. Note that staff users are automatically also event staff members.', verbose_name='Event Admin (in Kultus Admin UI)'),
13+
model_name="user",
14+
name="is_event_staff",
15+
field=models.BooleanField(
16+
default=False,
17+
help_text="Designates whether the user can access the Kultus Admin UI (React app) as an event provider to manage events and their enrolments. Note that staff users are automatically also event staff members.",
18+
verbose_name="Event Admin (in Kultus Admin UI)",
19+
),
1720
),
1821
migrations.AlterField(
19-
model_name='user',
20-
name='is_admin',
21-
field=models.BooleanField(default=False, help_text='Designates whether the user actively administrates the provider users. Admins receives some administrative emails, e.g, whenever a user requests a provider user status and an access to the Kultus Admin UI. Note that admin users are automatically also staff members.', verbose_name='Admin status'),
22+
model_name="user",
23+
name="is_admin",
24+
field=models.BooleanField(
25+
default=False,
26+
help_text="Designates whether the user actively administrates the provider users. Admins receives some administrative emails, e.g, whenever a user requests a provider user status and an access to the Kultus Admin UI. Note that admin users are automatically also staff members.",
27+
verbose_name="Admin status",
28+
),
2229
),
2330
migrations.AlterField(
24-
model_name='user',
25-
name='is_staff',
26-
field=models.BooleanField(default=False, help_text='Designates whether the user can log into the Django Admin site. This permission is primarily intended for internal Django administration tasks. Note that staff users are automatically also event staff members.', verbose_name='Staff Status (Django Admin)'),
31+
model_name="user",
32+
name="is_staff",
33+
field=models.BooleanField(
34+
default=False,
35+
help_text="Designates whether the user can log into the Django Admin site. This permission is primarily intended for internal Django administration tasks. Note that staff users are automatically also event staff members.",
36+
verbose_name="Staff Status (Django Admin)",
37+
),
2738
),
2839
]
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,40 @@
11
from django.db import migrations
22
from django.db.models import F
33

4+
45
def data_populate_kultus_admin_access(apps, schema_editor):
5-
User = apps.get_model('organisations', 'User')
6+
User = apps.get_model("organisations", "User")
67

78
# Update non-superusers: Set is_event_staff based on is_staff and set is_staff to False
89
User.objects.filter(is_superuser=False).update(
9-
is_event_staff=F('is_staff'),
10-
is_staff=False
10+
is_event_staff=F("is_staff"), is_staff=False
1111
)
1212

1313
# Update superusers: Set is_staff and is_event_staff to True
14-
User.objects.filter(is_superuser=True).update(
15-
is_staff=True,
16-
is_event_staff=True
17-
)
14+
User.objects.filter(is_superuser=True).update(is_staff=True, is_event_staff=True)
15+
1816

1917
def reverse_data_populate_kultus_admin_access(apps, schema_editor):
20-
User = apps.get_model('organisations', 'User')
18+
User = apps.get_model("organisations", "User")
2119

2220
# WARNING: Reversing this data migration might lead to data loss in the
2321
# 'is_staff' field for non-superusers if the 'is_event_staff' field has
2422
# been modified after the forward migration.
2523

2624
# Reverse for non-superusers: Set is_staff based on is_event_staff
27-
User.objects.filter(is_superuser=False).update(
28-
is_staff=F('is_event_staff')
29-
)
25+
User.objects.filter(is_superuser=False).update(is_staff=F("is_event_staff"))
3026

3127
# Reverse for all users: Set is_event_staff to False (as it was the new field)
32-
User.objects.all().update(
33-
is_event_staff=False
34-
)
28+
User.objects.all().update(is_event_staff=False)
3529

36-
class Migration(migrations.Migration):
3730

31+
class Migration(migrations.Migration):
3832
dependencies = [
39-
('organisations', '0013_user_is_event_staff_alter_user_is_admin_and_more'),
33+
("organisations", "0013_user_is_event_staff_alter_user_is_admin_and_more"),
4034
]
4135

4236
operations = [
43-
migrations.RunPython(data_populate_kultus_admin_access, reverse_data_populate_kultus_admin_access),
37+
migrations.RunPython(
38+
data_populate_kultus_admin_access, reverse_data_populate_kultus_admin_access
39+
),
4440
]

organisations/migrations/0015_add_ordering_and_indices_to_organisations.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,29 @@
44

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
9-
('organisations', '0014_data_populate_kultus_admin_access'),
8+
("organisations", "0014_data_populate_kultus_admin_access"),
109
]
1110

1211
operations = [
1312
migrations.AlterModelOptions(
14-
name='organisation',
15-
options={'ordering': ['name', 'publisher_id', 'id'], 'verbose_name': 'organisation', 'verbose_name_plural': 'organisations'},
13+
name="organisation",
14+
options={
15+
"ordering": ["name", "publisher_id", "id"],
16+
"verbose_name": "organisation",
17+
"verbose_name_plural": "organisations",
18+
},
1619
),
1720
migrations.AlterField(
18-
model_name='organisation',
19-
name='name',
20-
field=models.CharField(db_index=True, max_length=255, verbose_name='name'),
21+
model_name="organisation",
22+
name="name",
23+
field=models.CharField(db_index=True, max_length=255, verbose_name="name"),
2124
),
2225
migrations.AlterField(
23-
model_name='organisation',
24-
name='publisher_id',
25-
field=models.CharField(db_index=True, max_length=255, verbose_name='publisher id'),
26+
model_name="organisation",
27+
name="publisher_id",
28+
field=models.CharField(
29+
db_index=True, max_length=255, verbose_name="publisher id"
30+
),
2631
),
2732
]

organisations/migrations/0016_user_last_api_use.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
9-
('organisations', '0015_add_ordering_and_indices_to_organisations'),
8+
("organisations", "0015_add_ordering_and_indices_to_organisations"),
109
]
1110

1211
operations = [
1312
migrations.AddField(
14-
model_name='user',
15-
name='last_api_use',
16-
field=models.DateField(blank=True, null=True, verbose_name='Latest API token usage date'),
13+
model_name="user",
14+
name="last_api_use",
15+
field=models.DateField(
16+
blank=True, null=True, verbose_name="Latest API token usage date"
17+
),
1718
),
1819
]

0 commit comments

Comments
 (0)