From 15dc1e30128518c8bdfd44135b328497335037dd Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Sat, 15 Feb 2025 23:27:43 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=BA(migration)=20add=20back=20the=20mi?= =?UTF-8?q?gration=20folders=20to=20linter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/backend/core/migrations/0001_initial.py | 580 +++++++++++++++--- .../0002_create_pg_trgm_extension.py | 4 +- ..._link_reach_document_link_role_and_more.py | 110 +++- .../0004_migrate_is_public_to_link_reach.py | 19 +- ...blic_alter_document_link_reach_and_more.py | 11 +- .../0006_add_user_full_name_and_short_name.py | 31 +- .../migrations/0007_fix_users_duplicate.py | 4 +- .../0008_alter_document_link_reach.py | 17 +- .../migrations/0009_add_document_favorite.py | 82 ++- .../0010_add_field_creator_to_document.py | 45 +- ...late_creator_field_and_make_it_required.py | 39 +- ..._creator_and_invitation_issuer_optional.py | 39 +- .../0013_activate_fuzzystrmatch_extension.py | 4 +- .../0014_add_tree_structure_to_documents.py | 19 +- .../0015_set_path_on_existing_documents.py | 23 +- .../migrations/0016_add_document_excerpt.py | 23 +- .../0017_add_fields_for_soft_delete.py | 42 +- .../migrations/0018_update_blank_title.py | 3 +- src/backend/pyproject.toml | 1 - 19 files changed, 841 insertions(+), 255 deletions(-) diff --git a/src/backend/core/migrations/0001_initial.py b/src/backend/core/migrations/0001_initial.py index 38bdb4f3..7f4d80ab 100644 --- a/src/backend/core/migrations/0001_initial.py +++ b/src/backend/core/migrations/0001_initial.py @@ -1,166 +1,552 @@ # Generated by Django 5.0.3 on 2024-05-28 20:29 +import uuid + import django.contrib.auth.models import django.core.validators import django.db.models.deletion -import timezone_field.fields -import uuid from django.conf import settings from django.db import migrations, models +import timezone_field.fields + class Migration(migrations.Migration): - initial = True dependencies = [ - ('auth', '0012_alter_user_first_name_max_length'), + ("auth", "0012_alter_user_first_name_max_length"), ] operations = [ migrations.CreateModel( - name='Document', + name="Document", fields=[ - ('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')), - ('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')), - ('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')), - ('title', models.CharField(max_length=255, verbose_name='title')), - ('is_public', models.BooleanField(default=False, help_text='Whether this document is public for anyone to use.', verbose_name='public')), + ( + "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", + ), + ), + ( + "created_at", + models.DateTimeField( + auto_now_add=True, + help_text="date and time at which a record was created", + verbose_name="created on", + ), + ), + ( + "updated_at", + models.DateTimeField( + auto_now=True, + help_text="date and time at which a record was last updated", + verbose_name="updated on", + ), + ), + ("title", models.CharField(max_length=255, verbose_name="title")), + ( + "is_public", + models.BooleanField( + default=False, + help_text="Whether this document is public for anyone to use.", + verbose_name="public", + ), + ), ], options={ - 'verbose_name': 'Document', - 'verbose_name_plural': 'Documents', - 'db_table': 'impress_document', - 'ordering': ('title',), + "verbose_name": "Document", + "verbose_name_plural": "Documents", + "db_table": "impress_document", + "ordering": ("title",), }, ), migrations.CreateModel( - name='Template', + name="Template", fields=[ - ('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')), - ('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')), - ('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')), - ('title', models.CharField(max_length=255, verbose_name='title')), - ('description', models.TextField(blank=True, verbose_name='description')), - ('code', models.TextField(blank=True, verbose_name='code')), - ('css', models.TextField(blank=True, verbose_name='css')), - ('is_public', models.BooleanField(default=False, help_text='Whether this template is public for anyone to use.', verbose_name='public')), + ( + "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", + ), + ), + ( + "created_at", + models.DateTimeField( + auto_now_add=True, + help_text="date and time at which a record was created", + verbose_name="created on", + ), + ), + ( + "updated_at", + models.DateTimeField( + auto_now=True, + help_text="date and time at which a record was last updated", + verbose_name="updated on", + ), + ), + ("title", models.CharField(max_length=255, verbose_name="title")), + ( + "description", + models.TextField(blank=True, verbose_name="description"), + ), + ("code", models.TextField(blank=True, verbose_name="code")), + ("css", models.TextField(blank=True, verbose_name="css")), + ( + "is_public", + models.BooleanField( + default=False, + help_text="Whether this template is public for anyone to use.", + verbose_name="public", + ), + ), ], options={ - 'verbose_name': 'Template', - 'verbose_name_plural': 'Templates', - 'db_table': 'impress_template', - 'ordering': ('title',), + "verbose_name": "Template", + "verbose_name_plural": "Templates", + "db_table": "impress_template", + "ordering": ("title",), }, ), migrations.CreateModel( - name='User', + name="User", fields=[ - ('password', models.CharField(max_length=128, verbose_name='password')), - ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), - ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), - ('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')), - ('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')), - ('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')), - ('sub', models.CharField(blank=True, help_text='Required. 255 characters or fewer. Letters, numbers, and @/./+/-/_ characters only.', max_length=255, null=True, unique=True, validators=[django.core.validators.RegexValidator(message='Enter a valid sub. This value may contain only letters, numbers, and @/./+/-/_ characters.', regex='^[\\w.@+-]+\\Z')], verbose_name='sub')), - ('email', models.EmailField(blank=True, max_length=254, null=True, verbose_name='identity email address')), - ('admin_email', models.EmailField(blank=True, max_length=254, null=True, unique=True, verbose_name='admin email address')), - ('language', 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')), - ('timezone', timezone_field.fields.TimeZoneField(choices_display='WITH_GMT_OFFSET', default='UTC', help_text='The timezone in which the user wants to see times.', use_pytz=False)), - ('is_device', models.BooleanField(default=False, help_text='Whether the user is a device or a real user.', verbose_name='device')), - ('is_staff', models.BooleanField(default=False, help_text='Whether the user can log into this admin site.', verbose_name='staff status')), - ('is_active', models.BooleanField(default=True, help_text='Whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), - ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), - ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), + ("password", models.CharField(max_length=128, verbose_name="password")), + ( + "last_login", + models.DateTimeField( + blank=True, null=True, verbose_name="last login" + ), + ), + ( + "is_superuser", + models.BooleanField( + default=False, + help_text="Designates that this user has all permissions without explicitly assigning them.", + verbose_name="superuser status", + ), + ), + ( + "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", + ), + ), + ( + "created_at", + models.DateTimeField( + auto_now_add=True, + help_text="date and time at which a record was created", + verbose_name="created on", + ), + ), + ( + "updated_at", + models.DateTimeField( + auto_now=True, + help_text="date and time at which a record was last updated", + verbose_name="updated on", + ), + ), + ( + "sub", + models.CharField( + blank=True, + help_text="Required. 255 characters or fewer. Letters, numbers, and @/./+/-/_ characters only.", + max_length=255, + null=True, + unique=True, + validators=[ + django.core.validators.RegexValidator( + message="Enter a valid sub. This value may contain only letters, numbers, and @/./+/-/_ characters.", + regex="^[\\w.@+-]+\\Z", + ) + ], + verbose_name="sub", + ), + ), + ( + "email", + models.EmailField( + blank=True, + max_length=254, + null=True, + verbose_name="identity email address", + ), + ), + ( + "admin_email", + models.EmailField( + blank=True, + max_length=254, + null=True, + unique=True, + verbose_name="admin email address", + ), + ), + ( + "language", + 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", + ), + ), + ( + "timezone", + timezone_field.fields.TimeZoneField( + choices_display="WITH_GMT_OFFSET", + default="UTC", + help_text="The timezone in which the user wants to see times.", + use_pytz=False, + ), + ), + ( + "is_device", + models.BooleanField( + default=False, + help_text="Whether the user is a device or a real user.", + verbose_name="device", + ), + ), + ( + "is_staff", + models.BooleanField( + default=False, + help_text="Whether the user can log into this admin site.", + verbose_name="staff status", + ), + ), + ( + "is_active", + models.BooleanField( + default=True, + help_text="Whether this user should be treated as active. Unselect this instead of deleting accounts.", + verbose_name="active", + ), + ), + ( + "groups", + models.ManyToManyField( + blank=True, + help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.", + related_name="user_set", + related_query_name="user", + to="auth.group", + verbose_name="groups", + ), + ), + ( + "user_permissions", + models.ManyToManyField( + blank=True, + help_text="Specific permissions for this user.", + related_name="user_set", + related_query_name="user", + to="auth.permission", + verbose_name="user permissions", + ), + ), ], options={ - 'verbose_name': 'user', - 'verbose_name_plural': 'users', - 'db_table': 'impress_user', + "verbose_name": "user", + "verbose_name_plural": "users", + "db_table": "impress_user", }, managers=[ - ('objects', django.contrib.auth.models.UserManager()), + ("objects", django.contrib.auth.models.UserManager()), ], ), migrations.CreateModel( - name='DocumentAccess', + name="DocumentAccess", fields=[ - ('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')), - ('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')), - ('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')), - ('team', models.CharField(blank=True, max_length=100)), - ('role', models.CharField(choices=[('reader', 'Reader'), ('editor', 'Editor'), ('administrator', 'Administrator'), ('owner', 'Owner')], default='reader', max_length=20)), - ('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='accesses', to='core.document')), - ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ( + "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", + ), + ), + ( + "created_at", + models.DateTimeField( + auto_now_add=True, + help_text="date and time at which a record was created", + verbose_name="created on", + ), + ), + ( + "updated_at", + models.DateTimeField( + auto_now=True, + help_text="date and time at which a record was last updated", + verbose_name="updated on", + ), + ), + ("team", models.CharField(blank=True, max_length=100)), + ( + "role", + models.CharField( + choices=[ + ("reader", "Reader"), + ("editor", "Editor"), + ("administrator", "Administrator"), + ("owner", "Owner"), + ], + default="reader", + max_length=20, + ), + ), + ( + "document", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="accesses", + to="core.document", + ), + ), + ( + "user", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + ), + ), ], options={ - 'verbose_name': 'Document/user relation', - 'verbose_name_plural': 'Document/user relations', - 'db_table': 'impress_document_access', - 'ordering': ('-created_at',), + "verbose_name": "Document/user relation", + "verbose_name_plural": "Document/user relations", + "db_table": "impress_document_access", + "ordering": ("-created_at",), }, ), migrations.CreateModel( - name='Invitation', + name="Invitation", fields=[ - ('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')), - ('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')), - ('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')), - ('email', models.EmailField(max_length=254, verbose_name='email address')), - ('role', models.CharField(choices=[('reader', 'Reader'), ('editor', 'Editor'), ('administrator', 'Administrator'), ('owner', 'Owner')], default='reader', max_length=20)), - ('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invitations', to='core.document')), - ('issuer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invitations', to=settings.AUTH_USER_MODEL)), + ( + "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", + ), + ), + ( + "created_at", + models.DateTimeField( + auto_now_add=True, + help_text="date and time at which a record was created", + verbose_name="created on", + ), + ), + ( + "updated_at", + models.DateTimeField( + auto_now=True, + help_text="date and time at which a record was last updated", + verbose_name="updated on", + ), + ), + ( + "email", + models.EmailField(max_length=254, verbose_name="email address"), + ), + ( + "role", + models.CharField( + choices=[ + ("reader", "Reader"), + ("editor", "Editor"), + ("administrator", "Administrator"), + ("owner", "Owner"), + ], + default="reader", + max_length=20, + ), + ), + ( + "document", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="invitations", + to="core.document", + ), + ), + ( + "issuer", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="invitations", + to=settings.AUTH_USER_MODEL, + ), + ), ], options={ - 'verbose_name': 'Document invitation', - 'verbose_name_plural': 'Document invitations', - 'db_table': 'impress_invitation', + "verbose_name": "Document invitation", + "verbose_name_plural": "Document invitations", + "db_table": "impress_invitation", }, ), migrations.CreateModel( - name='TemplateAccess', + name="TemplateAccess", fields=[ - ('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')), - ('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')), - ('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')), - ('team', models.CharField(blank=True, max_length=100)), - ('role', models.CharField(choices=[('reader', 'Reader'), ('editor', 'Editor'), ('administrator', 'Administrator'), ('owner', 'Owner')], default='reader', max_length=20)), - ('template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='accesses', to='core.template')), - ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ( + "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", + ), + ), + ( + "created_at", + models.DateTimeField( + auto_now_add=True, + help_text="date and time at which a record was created", + verbose_name="created on", + ), + ), + ( + "updated_at", + models.DateTimeField( + auto_now=True, + help_text="date and time at which a record was last updated", + verbose_name="updated on", + ), + ), + ("team", models.CharField(blank=True, max_length=100)), + ( + "role", + models.CharField( + choices=[ + ("reader", "Reader"), + ("editor", "Editor"), + ("administrator", "Administrator"), + ("owner", "Owner"), + ], + default="reader", + max_length=20, + ), + ), + ( + "template", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="accesses", + to="core.template", + ), + ), + ( + "user", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + ), + ), ], options={ - 'verbose_name': 'Template/user relation', - 'verbose_name_plural': 'Template/user relations', - 'db_table': 'impress_template_access', - 'ordering': ('-created_at',), + "verbose_name": "Template/user relation", + "verbose_name_plural": "Template/user relations", + "db_table": "impress_template_access", + "ordering": ("-created_at",), }, ), migrations.AddConstraint( - model_name='documentaccess', - constraint=models.UniqueConstraint(condition=models.Q(('user__isnull', False)), fields=('user', 'document'), name='unique_document_user', violation_error_message='This user is already in this document.'), + model_name="documentaccess", + constraint=models.UniqueConstraint( + condition=models.Q(("user__isnull", False)), + fields=("user", "document"), + name="unique_document_user", + violation_error_message="This user is already in this document.", + ), ), migrations.AddConstraint( - model_name='documentaccess', - constraint=models.UniqueConstraint(condition=models.Q(('team__gt', '')), fields=('team', 'document'), name='unique_document_team', violation_error_message='This team is already in this document.'), + model_name="documentaccess", + constraint=models.UniqueConstraint( + condition=models.Q(("team__gt", "")), + fields=("team", "document"), + name="unique_document_team", + violation_error_message="This team is already in this document.", + ), ), migrations.AddConstraint( - model_name='documentaccess', - constraint=models.CheckConstraint(check=models.Q(models.Q(('team', ''), ('user__isnull', False)), models.Q(('team__gt', ''), ('user__isnull', True)), _connector='OR'), name='check_document_access_either_user_or_team', violation_error_message='Either user or team must be set, not both.'), + model_name="documentaccess", + constraint=models.CheckConstraint( + check=models.Q( + models.Q(("team", ""), ("user__isnull", False)), + models.Q(("team__gt", ""), ("user__isnull", True)), + _connector="OR", + ), + name="check_document_access_either_user_or_team", + violation_error_message="Either user or team must be set, not both.", + ), ), migrations.AddConstraint( - model_name='invitation', - constraint=models.UniqueConstraint(fields=('email', 'document'), name='email_and_document_unique_together'), + model_name="invitation", + constraint=models.UniqueConstraint( + fields=("email", "document"), name="email_and_document_unique_together" + ), ), migrations.AddConstraint( - model_name='templateaccess', - constraint=models.UniqueConstraint(condition=models.Q(('user__isnull', False)), fields=('user', 'template'), name='unique_template_user', violation_error_message='This user is already in this template.'), + model_name="templateaccess", + constraint=models.UniqueConstraint( + condition=models.Q(("user__isnull", False)), + fields=("user", "template"), + name="unique_template_user", + violation_error_message="This user is already in this template.", + ), ), migrations.AddConstraint( - model_name='templateaccess', - constraint=models.UniqueConstraint(condition=models.Q(('team__gt', '')), fields=('team', 'template'), name='unique_template_team', violation_error_message='This team is already in this template.'), + model_name="templateaccess", + constraint=models.UniqueConstraint( + condition=models.Q(("team__gt", "")), + fields=("team", "template"), + name="unique_template_team", + violation_error_message="This team is already in this template.", + ), ), migrations.AddConstraint( - model_name='templateaccess', - constraint=models.CheckConstraint(check=models.Q(models.Q(('team', ''), ('user__isnull', False)), models.Q(('team__gt', ''), ('user__isnull', True)), _connector='OR'), name='check_template_access_either_user_or_team', violation_error_message='Either user or team must be set, not both.'), + model_name="templateaccess", + constraint=models.CheckConstraint( + check=models.Q( + models.Q(("team", ""), ("user__isnull", False)), + models.Q(("team__gt", ""), ("user__isnull", True)), + _connector="OR", + ), + name="check_template_access_either_user_or_team", + violation_error_message="Either user or team must be set, not both.", + ), ), ] diff --git a/src/backend/core/migrations/0002_create_pg_trgm_extension.py b/src/backend/core/migrations/0002_create_pg_trgm_extension.py index 64f58842..ff92a7d5 100644 --- a/src/backend/core/migrations/0002_create_pg_trgm_extension.py +++ b/src/backend/core/migrations/0002_create_pg_trgm_extension.py @@ -1,9 +1,9 @@ from django.db import migrations -class Migration(migrations.Migration): +class Migration(migrations.Migration): dependencies = [ - ('core', '0001_initial'), + ("core", "0001_initial"), ] operations = [ diff --git a/src/backend/core/migrations/0003_document_link_reach_document_link_role_and_more.py b/src/backend/core/migrations/0003_document_link_reach_document_link_role_and_more.py index 71a4434a..02104a11 100644 --- a/src/backend/core/migrations/0003_document_link_reach_document_link_role_and_more.py +++ b/src/backend/core/migrations/0003_document_link_reach_document_link_role_and_more.py @@ -1,52 +1,114 @@ # Generated by Django 5.1 on 2024-09-08 16:55 -import django.db.models.deletion import uuid + +import django.db.models.deletion from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('core', '0002_create_pg_trgm_extension'), + ("core", "0002_create_pg_trgm_extension"), ] operations = [ migrations.AddField( - model_name='document', - name='link_reach', - field=models.CharField(choices=[('restricted', 'Restricted'), ('authenticated', 'Authenticated'), ('public', 'Public')], default='authenticated', max_length=20), + model_name="document", + name="link_reach", + field=models.CharField( + choices=[ + ("restricted", "Restricted"), + ("authenticated", "Authenticated"), + ("public", "Public"), + ], + default="authenticated", + max_length=20, + ), ), migrations.AddField( - model_name='document', - name='link_role', - field=models.CharField(choices=[('reader', 'Reader'), ('editor', 'Editor')], default='reader', max_length=20), + model_name="document", + name="link_role", + field=models.CharField( + choices=[("reader", "Reader"), ("editor", "Editor")], + default="reader", + max_length=20, + ), ), migrations.AlterField( - model_name='document', - name='is_public', + model_name="document", + name="is_public", field=models.BooleanField(null=True), ), migrations.AlterField( - model_name='user', - name='language', - 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'), + model_name="user", + name="language", + 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", + ), ), migrations.CreateModel( - name='LinkTrace', + name="LinkTrace", fields=[ - ('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')), - ('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')), - ('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')), - ('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='link_traces', to='core.document')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='link_traces', to=settings.AUTH_USER_MODEL)), + ( + "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", + ), + ), + ( + "created_at", + models.DateTimeField( + auto_now_add=True, + help_text="date and time at which a record was created", + verbose_name="created on", + ), + ), + ( + "updated_at", + models.DateTimeField( + auto_now=True, + help_text="date and time at which a record was last updated", + verbose_name="updated on", + ), + ), + ( + "document", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="link_traces", + to="core.document", + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="link_traces", + to=settings.AUTH_USER_MODEL, + ), + ), ], options={ - 'verbose_name': 'Document/user link trace', - 'verbose_name_plural': 'Document/user link traces', - 'db_table': 'impress_link_trace', - 'constraints': [models.UniqueConstraint(fields=('user', 'document'), name='unique_link_trace_document_user', violation_error_message='A link trace already exists for this document/user.')], + "verbose_name": "Document/user link trace", + "verbose_name_plural": "Document/user link traces", + "db_table": "impress_link_trace", + "constraints": [ + models.UniqueConstraint( + fields=("user", "document"), + name="unique_link_trace_document_user", + violation_error_message="A link trace already exists for this document/user.", + ) + ], }, ), ] diff --git a/src/backend/core/migrations/0004_migrate_is_public_to_link_reach.py b/src/backend/core/migrations/0004_migrate_is_public_to_link_reach.py index 3e5184db..8c0b21e0 100644 --- a/src/backend/core/migrations/0004_migrate_is_public_to_link_reach.py +++ b/src/backend/core/migrations/0004_migrate_is_public_to_link_reach.py @@ -1,13 +1,14 @@ # Generated by Django 5.1 on 2024-09-08 17:04 from django.db import migrations + def migrate_is_public_to_link_reach(apps, schema_editor): """ Forward migration: Migrate 'is_public' to 'link_reach'. If is_public == True, set link_reach to 'public' """ - Document = apps.get_model('core', 'Document') - Document.objects.filter(is_public=True).update(link_reach='public') + Document = apps.get_model("core", "Document") + Document.objects.filter(is_public=True).update(link_reach="public") 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): - If link_reach == 'public', set is_public to True - Else set is_public to False """ - Document = apps.get_model('core', 'Document') - Document.objects.filter(link_reach='public').update(is_public=True) - Document.objects.filter(link_reach__in=['restricted', "authenticated"]).update(is_public=False) + Document = apps.get_model("core", "Document") + Document.objects.filter(link_reach="public").update(is_public=True) + Document.objects.filter(link_reach__in=["restricted", "authenticated"]).update( + is_public=False + ) class Migration(migrations.Migration): - dependencies = [ - ('core', '0003_document_link_reach_document_link_role_and_more'), + ("core", "0003_document_link_reach_document_link_role_and_more"), ] operations = [ migrations.RunPython( - migrate_is_public_to_link_reach, - reverse_migrate_link_reach_to_is_public + migrate_is_public_to_link_reach, reverse_migrate_link_reach_to_is_public ), ] diff --git a/src/backend/core/migrations/0005_remove_document_is_public_alter_document_link_reach_and_more.py b/src/backend/core/migrations/0005_remove_document_is_public_alter_document_link_reach_and_more.py index 49c3983a..75436a68 100644 --- a/src/backend/core/migrations/0005_remove_document_is_public_alter_document_link_reach_and_more.py +++ b/src/backend/core/migrations/0005_remove_document_is_public_alter_document_link_reach_and_more.py @@ -4,15 +4,16 @@ from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('core', '0004_migrate_is_public_to_link_reach'), + ("core", "0004_migrate_is_public_to_link_reach"), ] operations = [ migrations.AlterField( - model_name='document', - name='title', - field=models.CharField(blank=True, max_length=255, null=True, verbose_name='title'), + model_name="document", + name="title", + field=models.CharField( + blank=True, max_length=255, null=True, verbose_name="title" + ), ), ] diff --git a/src/backend/core/migrations/0006_add_user_full_name_and_short_name.py b/src/backend/core/migrations/0006_add_user_full_name_and_short_name.py index dd5e3b7c..d3e8e78e 100644 --- a/src/backend/core/migrations/0006_add_user_full_name_and_short_name.py +++ b/src/backend/core/migrations/0006_add_user_full_name_and_short_name.py @@ -4,25 +4,34 @@ from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('core', '0005_remove_document_is_public_alter_document_link_reach_and_more'), + ("core", "0005_remove_document_is_public_alter_document_link_reach_and_more"), ] operations = [ migrations.AddField( - model_name='user', - name='full_name', - field=models.CharField(blank=True, max_length=100, null=True, verbose_name='full name'), + model_name="user", + name="full_name", + field=models.CharField( + blank=True, max_length=100, null=True, verbose_name="full name" + ), ), migrations.AddField( - model_name='user', - name='short_name', - field=models.CharField(blank=True, max_length=20, null=True, verbose_name='short name'), + model_name="user", + name="short_name", + field=models.CharField( + blank=True, max_length=20, null=True, verbose_name="short name" + ), ), migrations.AlterField( - model_name='user', - name='language', - 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'), + model_name="user", + name="language", + 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", + ), ), ] diff --git a/src/backend/core/migrations/0007_fix_users_duplicate.py b/src/backend/core/migrations/0007_fix_users_duplicate.py index 50139299..3eec88fe 100644 --- a/src/backend/core/migrations/0007_fix_users_duplicate.py +++ b/src/backend/core/migrations/0007_fix_users_duplicate.py @@ -117,10 +117,10 @@ BEGIN END $$; """ -class Migration(migrations.Migration): +class Migration(migrations.Migration): dependencies = [ - ('core', '0006_add_user_full_name_and_short_name'), + ("core", "0006_add_user_full_name_and_short_name"), ] operations = [ diff --git a/src/backend/core/migrations/0008_alter_document_link_reach.py b/src/backend/core/migrations/0008_alter_document_link_reach.py index 001269af..334cdd48 100644 --- a/src/backend/core/migrations/0008_alter_document_link_reach.py +++ b/src/backend/core/migrations/0008_alter_document_link_reach.py @@ -4,15 +4,22 @@ from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('core', '0007_fix_users_duplicate'), + ("core", "0007_fix_users_duplicate"), ] operations = [ migrations.AlterField( - model_name='document', - name='link_reach', - field=models.CharField(choices=[('restricted', 'Restricted'), ('authenticated', 'Authenticated'), ('public', 'Public')], default='restricted', max_length=20), + model_name="document", + name="link_reach", + field=models.CharField( + choices=[ + ("restricted", "Restricted"), + ("authenticated", "Authenticated"), + ("public", "Public"), + ], + default="restricted", + max_length=20, + ), ), ] diff --git a/src/backend/core/migrations/0009_add_document_favorite.py b/src/backend/core/migrations/0009_add_document_favorite.py index 9254f9fb..4e137b83 100644 --- a/src/backend/core/migrations/0009_add_document_favorite.py +++ b/src/backend/core/migrations/0009_add_document_favorite.py @@ -1,37 +1,87 @@ # Generated by Django 5.1.2 on 2024-11-08 07:59 -import django.db.models.deletion import uuid + +import django.db.models.deletion from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('core', '0008_alter_document_link_reach'), + ("core", "0008_alter_document_link_reach"), ] operations = [ migrations.AlterField( - model_name='user', - name='language', - field=models.CharField(choices="(('en-us', 'English'), ('fr-fr', 'French'), ('de-de', 'German'))", default='en-us', help_text='The language in which the user wants to see the interface.', max_length=10, verbose_name='language'), + model_name="user", + name="language", + field=models.CharField( + choices="(('en-us', 'English'), ('fr-fr', 'French'), ('de-de', 'German'))", + default="en-us", + help_text="The language in which the user wants to see the interface.", + max_length=10, + verbose_name="language", + ), ), migrations.CreateModel( - name='DocumentFavorite', + name="DocumentFavorite", fields=[ - ('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')), - ('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')), - ('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')), - ('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='favorited_by_users', to='core.document')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='favorite_documents', to=settings.AUTH_USER_MODEL)), + ( + "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", + ), + ), + ( + "created_at", + models.DateTimeField( + auto_now_add=True, + help_text="date and time at which a record was created", + verbose_name="created on", + ), + ), + ( + "updated_at", + models.DateTimeField( + auto_now=True, + help_text="date and time at which a record was last updated", + verbose_name="updated on", + ), + ), + ( + "document", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="favorited_by_users", + to="core.document", + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="favorite_documents", + to=settings.AUTH_USER_MODEL, + ), + ), ], options={ - 'verbose_name': 'Document favorite', - 'verbose_name_plural': 'Document favorites', - 'db_table': 'impress_document_favorite', - 'constraints': [models.UniqueConstraint(fields=('user', 'document'), name='unique_document_favorite_user', violation_error_message='This document is already targeted by a favorite relation instance for the same user.')], + "verbose_name": "Document favorite", + "verbose_name_plural": "Document favorites", + "db_table": "impress_document_favorite", + "constraints": [ + models.UniqueConstraint( + fields=("user", "document"), + name="unique_document_favorite_user", + violation_error_message="This document is already targeted by a favorite relation instance for the same user.", + ) + ], }, ), ] diff --git a/src/backend/core/migrations/0010_add_field_creator_to_document.py b/src/backend/core/migrations/0010_add_field_creator_to_document.py index 0fa619e2..2d8c1c1b 100644 --- a/src/backend/core/migrations/0010_add_field_creator_to_document.py +++ b/src/backend/core/migrations/0010_add_field_creator_to_document.py @@ -7,25 +7,48 @@ from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('core', '0009_add_document_favorite'), + ("core", "0009_add_document_favorite"), ] operations = [ migrations.AddField( - model_name='document', - name='creator', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.RESTRICT, related_name='documents_created', to=settings.AUTH_USER_MODEL), + model_name="document", + name="creator", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.RESTRICT, + related_name="documents_created", + to=settings.AUTH_USER_MODEL, + ), ), migrations.AlterField( - model_name='user', - name='language', - field=models.CharField(choices="(('en-us', 'English'), ('fr-fr', 'French'), ('de-de', 'German'))", default='en-us', help_text='The language in which the user wants to see the interface.', max_length=10, verbose_name='language'), + model_name="user", + name="language", + field=models.CharField( + choices="(('en-us', 'English'), ('fr-fr', 'French'), ('de-de', 'German'))", + default="en-us", + help_text="The language in which the user wants to see the interface.", + max_length=10, + verbose_name="language", + ), ), migrations.AlterField( - model_name='user', - name='sub', - field=models.CharField(blank=True, help_text='Required. 255 characters or fewer. Letters, numbers, and @/./+/-/_/: characters only.', max_length=255, null=True, unique=True, validators=[django.core.validators.RegexValidator(message='Enter a valid sub. This value may contain only letters, numbers, and @/./+/-/_/: characters.', regex='^[\\w.@+-:]+\\Z')], verbose_name='sub'), + model_name="user", + name="sub", + field=models.CharField( + blank=True, + help_text="Required. 255 characters or fewer. Letters, numbers, and @/./+/-/_/: characters only.", + max_length=255, + null=True, + unique=True, + validators=[ + django.core.validators.RegexValidator( + message="Enter a valid sub. This value may contain only letters, numbers, and @/./+/-/_/: characters.", + regex="^[\\w.@+-:]+\\Z", + ) + ], + verbose_name="sub", + ), ), ] diff --git a/src/backend/core/migrations/0011_populate_creator_field_and_make_it_required.py b/src/backend/core/migrations/0011_populate_creator_field_and_make_it_required.py index 1895993d..62b1c9f2 100644 --- a/src/backend/core/migrations/0011_populate_creator_field_and_make_it_required.py +++ b/src/backend/core/migrations/0011_populate_creator_field_and_make_it_required.py @@ -3,7 +3,7 @@ import django.db.models.deletion from django.conf import settings from django.db import migrations -from django.db.models import F, ForeignKey, Subquery, OuterRef, Q +from django.db.models import F, ForeignKey, OuterRef, Q, Subquery def set_creator_from_document_access(apps, schema_editor): @@ -25,28 +25,37 @@ def set_creator_from_document_access(apps, schema_editor): DocumentAccess = apps.get_model("core", "DocumentAccess") # Update `creator` using the "owner" role - owner_subquery = DocumentAccess.objects.filter( - document=OuterRef('pk'), - user__isnull=False, - role='owner', - ).order_by('created_at').values('user_id')[:1] + owner_subquery = ( + DocumentAccess.objects.filter( + document=OuterRef("pk"), + user__isnull=False, + role="owner", + ) + .order_by("created_at") + .values("user_id")[:1] + ) - Document.objects.filter( - creator__isnull=True - ).update(creator=Subquery(owner_subquery)) + Document.objects.filter(creator__isnull=True).update( + creator=Subquery(owner_subquery) + ) class Migration(migrations.Migration): - dependencies = [ - ('core', '0010_add_field_creator_to_document'), + ("core", "0010_add_field_creator_to_document"), ] operations = [ - migrations.RunPython(set_creator_from_document_access, reverse_code=migrations.RunPython.noop), + migrations.RunPython( + set_creator_from_document_access, reverse_code=migrations.RunPython.noop + ), migrations.AlterField( - model_name='document', - name='creator', - field=ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='documents_created', to=settings.AUTH_USER_MODEL), + model_name="document", + name="creator", + field=ForeignKey( + on_delete=django.db.models.deletion.RESTRICT, + related_name="documents_created", + to=settings.AUTH_USER_MODEL, + ), ), ] diff --git a/src/backend/core/migrations/0012_make_document_creator_and_invitation_issuer_optional.py b/src/backend/core/migrations/0012_make_document_creator_and_invitation_issuer_optional.py index b0902896..f10d2bc3 100644 --- a/src/backend/core/migrations/0012_make_document_creator_and_invitation_issuer_optional.py +++ b/src/backend/core/migrations/0012_make_document_creator_and_invitation_issuer_optional.py @@ -6,25 +6,42 @@ from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('core', '0011_populate_creator_field_and_make_it_required'), + ("core", "0011_populate_creator_field_and_make_it_required"), ] operations = [ migrations.AlterField( - model_name='document', - name='creator', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.RESTRICT, related_name='documents_created', to=settings.AUTH_USER_MODEL), + model_name="document", + name="creator", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.RESTRICT, + related_name="documents_created", + to=settings.AUTH_USER_MODEL, + ), ), migrations.AlterField( - model_name='invitation', - name='issuer', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='invitations', to=settings.AUTH_USER_MODEL), + model_name="invitation", + name="issuer", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="invitations", + to=settings.AUTH_USER_MODEL, + ), ), migrations.AlterField( - model_name='user', - name='language', - field=models.CharField(choices="(('en-us', 'English'), ('fr-fr', 'French'), ('de-de', 'German'))", default='en-us', help_text='The language in which the user wants to see the interface.', max_length=10, verbose_name='language'), + model_name="user", + name="language", + field=models.CharField( + choices="(('en-us', 'English'), ('fr-fr', 'French'), ('de-de', 'German'))", + default="en-us", + help_text="The language in which the user wants to see the interface.", + max_length=10, + verbose_name="language", + ), ), ] diff --git a/src/backend/core/migrations/0013_activate_fuzzystrmatch_extension.py b/src/backend/core/migrations/0013_activate_fuzzystrmatch_extension.py index db7fbb3a..01b4dc6f 100644 --- a/src/backend/core/migrations/0013_activate_fuzzystrmatch_extension.py +++ b/src/backend/core/migrations/0013_activate_fuzzystrmatch_extension.py @@ -2,10 +2,10 @@ from django.db import migrations -class Migration(migrations.Migration): +class Migration(migrations.Migration): dependencies = [ - ('core', '0012_make_document_creator_and_invitation_issuer_optional'), + ("core", "0012_make_document_creator_and_invitation_issuer_optional"), ] operations = [ diff --git a/src/backend/core/migrations/0014_add_tree_structure_to_documents.py b/src/backend/core/migrations/0014_add_tree_structure_to_documents.py index bd237f74..c99473ab 100644 --- a/src/backend/core/migrations/0014_add_tree_structure_to_documents.py +++ b/src/backend/core/migrations/0014_add_tree_structure_to_documents.py @@ -4,28 +4,29 @@ from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('core', '0013_activate_fuzzystrmatch_extension'), + ("core", "0013_activate_fuzzystrmatch_extension"), ] operations = [ migrations.AddField( - model_name='document', - name='depth', + model_name="document", + name="depth", field=models.PositiveIntegerField(default=0), preserve_default=False, ), migrations.AddField( - model_name='document', - name='numchild', + model_name="document", + name="numchild", field=models.PositiveIntegerField(default=0), ), migrations.AddField( - model_name='document', - name='path', + model_name="document", + name="path", # Allow null values pending the next datamigration to populate the field - field=models.CharField(db_collation='C', max_length=252, null=True, unique=True), + field=models.CharField( + db_collation="C", max_length=252, null=True, unique=True + ), preserve_default=False, ), ] diff --git a/src/backend/core/migrations/0015_set_path_on_existing_documents.py b/src/backend/core/migrations/0015_set_path_on_existing_documents.py index 250d8dbd..1c3081fc 100644 --- a/src/backend/core/migrations/0015_set_path_on_existing_documents.py +++ b/src/backend/core/migrations/0015_set_path_on_existing_documents.py @@ -7,9 +7,10 @@ from treebeard.numconv import NumConv ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" STEPLEN = 7 + def set_path_on_existing_documents(apps, schema_editor): """ - Updates the `path` and `depth` fields for all existing Document records + Updates the `path` and `depth` fields for all existing Document records to ensure valid materialized paths. This function assigns a unique `path` to each Document as a root node @@ -26,27 +27,25 @@ def set_path_on_existing_documents(apps, schema_editor): updates = [] for i, pk in enumerate(documents): key = numconv.int2str(i) - path = "{0}{1}".format( - ALPHABET[0] * (STEPLEN - len(key)), - key - ) + path = "{0}{1}".format(ALPHABET[0] * (STEPLEN - len(key)), key) updates.append(Document(pk=pk, path=path, depth=1)) # Bulk update using the prepared updates list - Document.objects.bulk_update(updates, ['depth', 'path']) + Document.objects.bulk_update(updates, ["depth", "path"]) class Migration(migrations.Migration): - dependencies = [ - ('core', '0014_add_tree_structure_to_documents'), + ("core", "0014_add_tree_structure_to_documents"), ] operations = [ - migrations.RunPython(set_path_on_existing_documents, reverse_code=migrations.RunPython.noop), + migrations.RunPython( + set_path_on_existing_documents, reverse_code=migrations.RunPython.noop + ), migrations.AlterField( - model_name='document', - name='path', - field=models.CharField(db_collation='C', max_length=252, unique=True), + model_name="document", + name="path", + field=models.CharField(db_collation="C", max_length=252, unique=True), ), ] diff --git a/src/backend/core/migrations/0016_add_document_excerpt.py b/src/backend/core/migrations/0016_add_document_excerpt.py index 302cd260..8a107789 100644 --- a/src/backend/core/migrations/0016_add_document_excerpt.py +++ b/src/backend/core/migrations/0016_add_document_excerpt.py @@ -4,20 +4,27 @@ from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('core', '0015_set_path_on_existing_documents'), + ("core", "0015_set_path_on_existing_documents"), ] operations = [ migrations.AddField( - model_name='document', - name='excerpt', - field=models.TextField(blank=True, max_length=300, null=True, verbose_name='excerpt'), + model_name="document", + name="excerpt", + field=models.TextField( + blank=True, max_length=300, null=True, verbose_name="excerpt" + ), ), migrations.AlterField( - model_name='user', - name='language', - field=models.CharField(choices="(('en-us', 'English'), ('fr-fr', 'French'), ('de-de', 'German'))", default='en-us', help_text='The language in which the user wants to see the interface.', max_length=10, verbose_name='language'), + model_name="user", + name="language", + field=models.CharField( + choices="(('en-us', 'English'), ('fr-fr', 'French'), ('de-de', 'German'))", + default="en-us", + help_text="The language in which the user wants to see the interface.", + max_length=10, + verbose_name="language", + ), ), ] diff --git a/src/backend/core/migrations/0017_add_fields_for_soft_delete.py b/src/backend/core/migrations/0017_add_fields_for_soft_delete.py index 54c9df5c..00cd8a90 100644 --- a/src/backend/core/migrations/0017_add_fields_for_soft_delete.py +++ b/src/backend/core/migrations/0017_add_fields_for_soft_delete.py @@ -4,33 +4,49 @@ from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('core', '0016_add_document_excerpt'), + ("core", "0016_add_document_excerpt"), ] operations = [ migrations.AlterModelOptions( - name='document', - options={'ordering': ('path',), 'verbose_name': 'Document', 'verbose_name_plural': 'Documents'}, + name="document", + options={ + "ordering": ("path",), + "verbose_name": "Document", + "verbose_name_plural": "Documents", + }, ), migrations.AddField( - model_name='document', - name='ancestors_deleted_at', + model_name="document", + name="ancestors_deleted_at", field=models.DateTimeField(blank=True, null=True), ), migrations.AddField( - model_name='document', - name='deleted_at', + model_name="document", + name="deleted_at", field=models.DateTimeField(blank=True, null=True), ), migrations.AlterField( - model_name='user', - name='language', - field=models.CharField(choices="(('en-us', 'English'), ('fr-fr', 'French'), ('de-de', 'German'))", default='en-us', help_text='The language in which the user wants to see the interface.', max_length=10, verbose_name='language'), + model_name="user", + name="language", + field=models.CharField( + choices="(('en-us', 'English'), ('fr-fr', 'French'), ('de-de', 'German'))", + default="en-us", + help_text="The language in which the user wants to see the interface.", + max_length=10, + verbose_name="language", + ), ), migrations.AddConstraint( - model_name='document', - constraint=models.CheckConstraint(condition=models.Q(('deleted_at__isnull', True), ('deleted_at', models.F('ancestors_deleted_at')), _connector='OR'), name='check_deleted_at_matches_ancestors_deleted_at_when_set'), + model_name="document", + constraint=models.CheckConstraint( + condition=models.Q( + ("deleted_at__isnull", True), + ("deleted_at", models.F("ancestors_deleted_at")), + _connector="OR", + ), + name="check_deleted_at_matches_ancestors_deleted_at_when_set", + ), ), ] diff --git a/src/backend/core/migrations/0018_update_blank_title.py b/src/backend/core/migrations/0018_update_blank_title.py index 74e379e9..9576f53a 100644 --- a/src/backend/core/migrations/0018_update_blank_title.py +++ b/src/backend/core/migrations/0018_update_blank_title.py @@ -19,7 +19,6 @@ class Migration(migrations.Migration): operations = [ migrations.RunPython( - update_titles_to_null, - reverse_code=migrations.RunPython.noop + update_titles_to_null, reverse_code=migrations.RunPython.noop ), ] diff --git a/src/backend/pyproject.toml b/src/backend/pyproject.toml index 4cd076f4..a7fe9a36 100644 --- a/src/backend/pyproject.toml +++ b/src/backend/pyproject.toml @@ -100,7 +100,6 @@ exclude = [ "build", "venv", "__pycache__", - "*/migrations/*", ] line-length = 88