Skip to content

Commit 6888586

Browse files
committed
🦺(migration) add back the migration folders to linter
Previous commit add "core/tests/migrations". The linter could not pass on it because all the migration folders were excluded from the linter. We remove this exclusion, tests and migrations can now be linted and formatted automatically.
1 parent c518bbf commit 6888586

18 files changed

+840
-253
lines changed

src/backend/core/migrations/0001_initial.py

Lines changed: 483 additions & 97 deletions
Large diffs are not rendered by default.

src/backend/core/migrations/0002_create_pg_trgm_extension.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from django.db import migrations
22

3-
class Migration(migrations.Migration):
43

4+
class Migration(migrations.Migration):
55
dependencies = [
6-
('core', '0001_initial'),
6+
("core", "0001_initial"),
77
]
88

99
operations = [
Lines changed: 86 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,114 @@
11
# Generated by Django 5.1 on 2024-09-08 16:55
22

3-
import django.db.models.deletion
43
import uuid
4+
5+
import django.db.models.deletion
56
from django.conf import settings
67
from django.db import migrations, models
78

89

910
class Migration(migrations.Migration):
10-
1111
dependencies = [
12-
('core', '0002_create_pg_trgm_extension'),
12+
("core", "0002_create_pg_trgm_extension"),
1313
]
1414

1515
operations = [
1616
migrations.AddField(
17-
model_name='document',
18-
name='link_reach',
19-
field=models.CharField(choices=[('restricted', 'Restricted'), ('authenticated', 'Authenticated'), ('public', 'Public')], default='authenticated', max_length=20),
17+
model_name="document",
18+
name="link_reach",
19+
field=models.CharField(
20+
choices=[
21+
("restricted", "Restricted"),
22+
("authenticated", "Authenticated"),
23+
("public", "Public"),
24+
],
25+
default="authenticated",
26+
max_length=20,
27+
),
2028
),
2129
migrations.AddField(
22-
model_name='document',
23-
name='link_role',
24-
field=models.CharField(choices=[('reader', 'Reader'), ('editor', 'Editor')], default='reader', max_length=20),
30+
model_name="document",
31+
name="link_role",
32+
field=models.CharField(
33+
choices=[("reader", "Reader"), ("editor", "Editor")],
34+
default="reader",
35+
max_length=20,
36+
),
2537
),
2638
migrations.AlterField(
27-
model_name='document',
28-
name='is_public',
39+
model_name="document",
40+
name="is_public",
2941
field=models.BooleanField(null=True),
3042
),
3143
migrations.AlterField(
32-
model_name='user',
33-
name='language',
34-
field=models.CharField(choices="(('en-us', 'English'), ('fr-fr', 'French'))", default='en-us', help_text='The language in which the user wants to see the interface.', max_length=10, verbose_name='language'),
44+
model_name="user",
45+
name="language",
46+
field=models.CharField(
47+
choices="(('en-us', 'English'), ('fr-fr', 'French'))",
48+
default="en-us",
49+
help_text="The language in which the user wants to see the interface.",
50+
max_length=10,
51+
verbose_name="language",
52+
),
3553
),
3654
migrations.CreateModel(
37-
name='LinkTrace',
55+
name="LinkTrace",
3856
fields=[
39-
('id', models.UUIDField(default=uuid.uuid4, editable=False, help_text='primary key for the record as UUID', primary_key=True, serialize=False, verbose_name='id')),
40-
('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')),
41-
('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')),
42-
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='link_traces', to='core.document')),
43-
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='link_traces', to=settings.AUTH_USER_MODEL)),
57+
(
58+
"id",
59+
models.UUIDField(
60+
default=uuid.uuid4,
61+
editable=False,
62+
help_text="primary key for the record as UUID",
63+
primary_key=True,
64+
serialize=False,
65+
verbose_name="id",
66+
),
67+
),
68+
(
69+
"created_at",
70+
models.DateTimeField(
71+
auto_now_add=True,
72+
help_text="date and time at which a record was created",
73+
verbose_name="created on",
74+
),
75+
),
76+
(
77+
"updated_at",
78+
models.DateTimeField(
79+
auto_now=True,
80+
help_text="date and time at which a record was last updated",
81+
verbose_name="updated on",
82+
),
83+
),
84+
(
85+
"document",
86+
models.ForeignKey(
87+
on_delete=django.db.models.deletion.CASCADE,
88+
related_name="link_traces",
89+
to="core.document",
90+
),
91+
),
92+
(
93+
"user",
94+
models.ForeignKey(
95+
on_delete=django.db.models.deletion.CASCADE,
96+
related_name="link_traces",
97+
to=settings.AUTH_USER_MODEL,
98+
),
99+
),
44100
],
45101
options={
46-
'verbose_name': 'Document/user link trace',
47-
'verbose_name_plural': 'Document/user link traces',
48-
'db_table': 'impress_link_trace',
49-
'constraints': [models.UniqueConstraint(fields=('user', 'document'), name='unique_link_trace_document_user', violation_error_message='A link trace already exists for this document/user.')],
102+
"verbose_name": "Document/user link trace",
103+
"verbose_name_plural": "Document/user link traces",
104+
"db_table": "impress_link_trace",
105+
"constraints": [
106+
models.UniqueConstraint(
107+
fields=("user", "document"),
108+
name="unique_link_trace_document_user",
109+
violation_error_message="A link trace already exists for this document/user.",
110+
)
111+
],
50112
},
51113
),
52114
]
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Generated by Django 5.1 on 2024-09-08 17:04
22
from django.db import migrations
33

4+
45
def migrate_is_public_to_link_reach(apps, schema_editor):
56
"""
67
Forward migration: Migrate 'is_public' to 'link_reach'.
78
If is_public == True, set link_reach to 'public'
89
"""
9-
Document = apps.get_model('core', 'Document')
10-
Document.objects.filter(is_public=True).update(link_reach='public')
10+
Document = apps.get_model("core", "Document")
11+
Document.objects.filter(is_public=True).update(link_reach="public")
1112

1213

1314
def reverse_migrate_link_reach_to_is_public(apps, schema_editor):
@@ -16,20 +17,20 @@ def reverse_migrate_link_reach_to_is_public(apps, schema_editor):
1617
- If link_reach == 'public', set is_public to True
1718
- Else set is_public to False
1819
"""
19-
Document = apps.get_model('core', 'Document')
20-
Document.objects.filter(link_reach='public').update(is_public=True)
21-
Document.objects.filter(link_reach__in=['restricted', "authenticated"]).update(is_public=False)
20+
Document = apps.get_model("core", "Document")
21+
Document.objects.filter(link_reach="public").update(is_public=True)
22+
Document.objects.filter(link_reach__in=["restricted", "authenticated"]).update(
23+
is_public=False
24+
)
2225

2326

2427
class Migration(migrations.Migration):
25-
2628
dependencies = [
27-
('core', '0003_document_link_reach_document_link_role_and_more'),
29+
("core", "0003_document_link_reach_document_link_role_and_more"),
2830
]
2931

3032
operations = [
3133
migrations.RunPython(
32-
migrate_is_public_to_link_reach,
33-
reverse_migrate_link_reach_to_is_public
34+
migrate_is_public_to_link_reach, reverse_migrate_link_reach_to_is_public
3435
),
3536
]

src/backend/core/migrations/0005_remove_document_is_public_alter_document_link_reach_and_more.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-
('core', '0004_migrate_is_public_to_link_reach'),
8+
("core", "0004_migrate_is_public_to_link_reach"),
109
]
1110

1211
operations = [
1312
migrations.AlterField(
14-
model_name='document',
15-
name='title',
16-
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='title'),
13+
model_name="document",
14+
name="title",
15+
field=models.CharField(
16+
blank=True, max_length=255, null=True, verbose_name="title"
17+
),
1718
),
1819
]

src/backend/core/migrations/0006_add_user_full_name_and_short_name.py

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

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
9-
('core', '0005_remove_document_is_public_alter_document_link_reach_and_more'),
8+
("core", "0005_remove_document_is_public_alter_document_link_reach_and_more"),
109
]
1110

1211
operations = [
1312
migrations.AddField(
14-
model_name='user',
15-
name='full_name',
16-
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='full name'),
13+
model_name="user",
14+
name="full_name",
15+
field=models.CharField(
16+
blank=True, max_length=100, null=True, verbose_name="full name"
17+
),
1718
),
1819
migrations.AddField(
19-
model_name='user',
20-
name='short_name',
21-
field=models.CharField(blank=True, max_length=20, null=True, verbose_name='short name'),
20+
model_name="user",
21+
name="short_name",
22+
field=models.CharField(
23+
blank=True, max_length=20, null=True, verbose_name="short name"
24+
),
2225
),
2326
migrations.AlterField(
24-
model_name='user',
25-
name='language',
26-
field=models.CharField(choices="(('en-us', 'English'), ('fr-fr', 'French'))", default='en-us', help_text='The language in which the user wants to see the interface.', max_length=10, verbose_name='language'),
27+
model_name="user",
28+
name="language",
29+
field=models.CharField(
30+
choices="(('en-us', 'English'), ('fr-fr', 'French'))",
31+
default="en-us",
32+
help_text="The language in which the user wants to see the interface.",
33+
max_length=10,
34+
verbose_name="language",
35+
),
2736
),
2837
]

src/backend/core/migrations/0007_fix_users_duplicate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@
117117
END $$;
118118
"""
119119

120-
class Migration(migrations.Migration):
121120

121+
class Migration(migrations.Migration):
122122
dependencies = [
123-
('core', '0006_add_user_full_name_and_short_name'),
123+
("core", "0006_add_user_full_name_and_short_name"),
124124
]
125125

126126
operations = [

src/backend/core/migrations/0008_alter_document_link_reach.py

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

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
9-
('core', '0007_fix_users_duplicate'),
8+
("core", "0007_fix_users_duplicate"),
109
]
1110

1211
operations = [
1312
migrations.AlterField(
14-
model_name='document',
15-
name='link_reach',
16-
field=models.CharField(choices=[('restricted', 'Restricted'), ('authenticated', 'Authenticated'), ('public', 'Public')], default='restricted', max_length=20),
13+
model_name="document",
14+
name="link_reach",
15+
field=models.CharField(
16+
choices=[
17+
("restricted", "Restricted"),
18+
("authenticated", "Authenticated"),
19+
("public", "Public"),
20+
],
21+
default="restricted",
22+
max_length=20,
23+
),
1724
),
1825
]

0 commit comments

Comments
 (0)