🦺(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.
This commit is contained in:
@@ -1,166 +1,552 @@
|
|||||||
# Generated by Django 5.0.3 on 2024-05-28 20:29
|
# Generated by Django 5.0.3 on 2024-05-28 20:29
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
import django.contrib.auth.models
|
import django.contrib.auth.models
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import timezone_field.fields
|
|
||||||
import uuid
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
import timezone_field.fields
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('auth', '0012_alter_user_first_name_max_length'),
|
("auth", "0012_alter_user_first_name_max_length"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Document',
|
name="Document",
|
||||||
fields=[
|
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')),
|
"id",
|
||||||
('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')),
|
models.UUIDField(
|
||||||
('title', models.CharField(max_length=255, verbose_name='title')),
|
default=uuid.uuid4,
|
||||||
('is_public', models.BooleanField(default=False, help_text='Whether this document is public for anyone to use.', verbose_name='public')),
|
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={
|
options={
|
||||||
'verbose_name': 'Document',
|
"verbose_name": "Document",
|
||||||
'verbose_name_plural': 'Documents',
|
"verbose_name_plural": "Documents",
|
||||||
'db_table': 'impress_document',
|
"db_table": "impress_document",
|
||||||
'ordering': ('title',),
|
"ordering": ("title",),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Template',
|
name="Template",
|
||||||
fields=[
|
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')),
|
"id",
|
||||||
('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')),
|
models.UUIDField(
|
||||||
('title', models.CharField(max_length=255, verbose_name='title')),
|
default=uuid.uuid4,
|
||||||
('description', models.TextField(blank=True, verbose_name='description')),
|
editable=False,
|
||||||
('code', models.TextField(blank=True, verbose_name='code')),
|
help_text="primary key for the record as UUID",
|
||||||
('css', models.TextField(blank=True, verbose_name='css')),
|
primary_key=True,
|
||||||
('is_public', models.BooleanField(default=False, help_text='Whether this template is public for anyone to use.', verbose_name='public')),
|
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={
|
options={
|
||||||
'verbose_name': 'Template',
|
"verbose_name": "Template",
|
||||||
'verbose_name_plural': 'Templates',
|
"verbose_name_plural": "Templates",
|
||||||
'db_table': 'impress_template',
|
"db_table": "impress_template",
|
||||||
'ordering': ('title',),
|
"ordering": ("title",),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='User',
|
name="User",
|
||||||
fields=[
|
fields=[
|
||||||
('password', models.CharField(max_length=128, verbose_name='password')),
|
("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')),
|
"last_login",
|
||||||
('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')),
|
models.DateTimeField(
|
||||||
('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')),
|
blank=True, null=True, verbose_name="last login"
|
||||||
('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')),
|
"is_superuser",
|
||||||
('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')),
|
models.BooleanField(
|
||||||
('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)),
|
default=False,
|
||||||
('is_device', models.BooleanField(default=False, help_text='Whether the user is a device or a real user.', verbose_name='device')),
|
help_text="Designates that this user has all permissions without explicitly assigning them.",
|
||||||
('is_staff', models.BooleanField(default=False, help_text='Whether the user can log into this admin site.', verbose_name='staff status')),
|
verbose_name="superuser 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')),
|
(
|
||||||
|
"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={
|
options={
|
||||||
'verbose_name': 'user',
|
"verbose_name": "user",
|
||||||
'verbose_name_plural': 'users',
|
"verbose_name_plural": "users",
|
||||||
'db_table': 'impress_user',
|
"db_table": "impress_user",
|
||||||
},
|
},
|
||||||
managers=[
|
managers=[
|
||||||
('objects', django.contrib.auth.models.UserManager()),
|
("objects", django.contrib.auth.models.UserManager()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='DocumentAccess',
|
name="DocumentAccess",
|
||||||
fields=[
|
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')),
|
"id",
|
||||||
('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')),
|
models.UUIDField(
|
||||||
('team', models.CharField(blank=True, max_length=100)),
|
default=uuid.uuid4,
|
||||||
('role', models.CharField(choices=[('reader', 'Reader'), ('editor', 'Editor'), ('administrator', 'Administrator'), ('owner', 'Owner')], default='reader', max_length=20)),
|
editable=False,
|
||||||
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='accesses', to='core.document')),
|
help_text="primary key for the record as UUID",
|
||||||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
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={
|
options={
|
||||||
'verbose_name': 'Document/user relation',
|
"verbose_name": "Document/user relation",
|
||||||
'verbose_name_plural': 'Document/user relations',
|
"verbose_name_plural": "Document/user relations",
|
||||||
'db_table': 'impress_document_access',
|
"db_table": "impress_document_access",
|
||||||
'ordering': ('-created_at',),
|
"ordering": ("-created_at",),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Invitation',
|
name="Invitation",
|
||||||
fields=[
|
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')),
|
"id",
|
||||||
('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')),
|
models.UUIDField(
|
||||||
('email', models.EmailField(max_length=254, verbose_name='email address')),
|
default=uuid.uuid4,
|
||||||
('role', models.CharField(choices=[('reader', 'Reader'), ('editor', 'Editor'), ('administrator', 'Administrator'), ('owner', 'Owner')], default='reader', max_length=20)),
|
editable=False,
|
||||||
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invitations', to='core.document')),
|
help_text="primary key for the record as UUID",
|
||||||
('issuer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invitations', to=settings.AUTH_USER_MODEL)),
|
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={
|
options={
|
||||||
'verbose_name': 'Document invitation',
|
"verbose_name": "Document invitation",
|
||||||
'verbose_name_plural': 'Document invitations',
|
"verbose_name_plural": "Document invitations",
|
||||||
'db_table': 'impress_invitation',
|
"db_table": "impress_invitation",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='TemplateAccess',
|
name="TemplateAccess",
|
||||||
fields=[
|
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')),
|
"id",
|
||||||
('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')),
|
models.UUIDField(
|
||||||
('team', models.CharField(blank=True, max_length=100)),
|
default=uuid.uuid4,
|
||||||
('role', models.CharField(choices=[('reader', 'Reader'), ('editor', 'Editor'), ('administrator', 'Administrator'), ('owner', 'Owner')], default='reader', max_length=20)),
|
editable=False,
|
||||||
('template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='accesses', to='core.template')),
|
help_text="primary key for the record as UUID",
|
||||||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
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={
|
options={
|
||||||
'verbose_name': 'Template/user relation',
|
"verbose_name": "Template/user relation",
|
||||||
'verbose_name_plural': 'Template/user relations',
|
"verbose_name_plural": "Template/user relations",
|
||||||
'db_table': 'impress_template_access',
|
"db_table": "impress_template_access",
|
||||||
'ordering': ('-created_at',),
|
"ordering": ("-created_at",),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.AddConstraint(
|
migrations.AddConstraint(
|
||||||
model_name='documentaccess',
|
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.'),
|
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(
|
migrations.AddConstraint(
|
||||||
model_name='documentaccess',
|
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.'),
|
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(
|
migrations.AddConstraint(
|
||||||
model_name='documentaccess',
|
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.'),
|
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(
|
migrations.AddConstraint(
|
||||||
model_name='invitation',
|
model_name="invitation",
|
||||||
constraint=models.UniqueConstraint(fields=('email', 'document'), name='email_and_document_unique_together'),
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=("email", "document"), name="email_and_document_unique_together"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AddConstraint(
|
migrations.AddConstraint(
|
||||||
model_name='templateaccess',
|
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.'),
|
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(
|
migrations.AddConstraint(
|
||||||
model_name='templateaccess',
|
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.'),
|
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(
|
migrations.AddConstraint(
|
||||||
model_name='templateaccess',
|
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.'),
|
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.",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0001_initial'),
|
("core", "0001_initial"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|||||||
@@ -1,52 +1,114 @@
|
|||||||
# Generated by Django 5.1 on 2024-09-08 16:55
|
# Generated by Django 5.1 on 2024-09-08 16:55
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0002_create_pg_trgm_extension'),
|
("core", "0002_create_pg_trgm_extension"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='link_reach',
|
name="link_reach",
|
||||||
field=models.CharField(choices=[('restricted', 'Restricted'), ('authenticated', 'Authenticated'), ('public', 'Public')], default='authenticated', max_length=20),
|
field=models.CharField(
|
||||||
|
choices=[
|
||||||
|
("restricted", "Restricted"),
|
||||||
|
("authenticated", "Authenticated"),
|
||||||
|
("public", "Public"),
|
||||||
|
],
|
||||||
|
default="authenticated",
|
||||||
|
max_length=20,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='link_role',
|
name="link_role",
|
||||||
field=models.CharField(choices=[('reader', 'Reader'), ('editor', 'Editor')], default='reader', max_length=20),
|
field=models.CharField(
|
||||||
|
choices=[("reader", "Reader"), ("editor", "Editor")],
|
||||||
|
default="reader",
|
||||||
|
max_length=20,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='is_public',
|
name="is_public",
|
||||||
field=models.BooleanField(null=True),
|
field=models.BooleanField(null=True),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='user',
|
model_name="user",
|
||||||
name='language',
|
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'),
|
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(
|
migrations.CreateModel(
|
||||||
name='LinkTrace',
|
name="LinkTrace",
|
||||||
fields=[
|
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')),
|
"id",
|
||||||
('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')),
|
models.UUIDField(
|
||||||
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='link_traces', to='core.document')),
|
default=uuid.uuid4,
|
||||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='link_traces', to=settings.AUTH_USER_MODEL)),
|
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={
|
options={
|
||||||
'verbose_name': 'Document/user link trace',
|
"verbose_name": "Document/user link trace",
|
||||||
'verbose_name_plural': 'Document/user link traces',
|
"verbose_name_plural": "Document/user link traces",
|
||||||
'db_table': 'impress_link_trace',
|
"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.')],
|
"constraints": [
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=("user", "document"),
|
||||||
|
name="unique_link_trace_document_user",
|
||||||
|
violation_error_message="A link trace already exists for this document/user.",
|
||||||
|
)
|
||||||
|
],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
# Generated by Django 5.1 on 2024-09-08 17:04
|
# Generated by Django 5.1 on 2024-09-08 17:04
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
def migrate_is_public_to_link_reach(apps, schema_editor):
|
def migrate_is_public_to_link_reach(apps, schema_editor):
|
||||||
"""
|
"""
|
||||||
Forward migration: Migrate 'is_public' to 'link_reach'.
|
Forward migration: Migrate 'is_public' to 'link_reach'.
|
||||||
If is_public == True, set link_reach to 'public'
|
If is_public == True, set link_reach to 'public'
|
||||||
"""
|
"""
|
||||||
Document = apps.get_model('core', 'Document')
|
Document = apps.get_model("core", "Document")
|
||||||
Document.objects.filter(is_public=True).update(link_reach='public')
|
Document.objects.filter(is_public=True).update(link_reach="public")
|
||||||
|
|
||||||
|
|
||||||
def reverse_migrate_link_reach_to_is_public(apps, schema_editor):
|
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
|
- If link_reach == 'public', set is_public to True
|
||||||
- Else set is_public to False
|
- Else set is_public to False
|
||||||
"""
|
"""
|
||||||
Document = apps.get_model('core', 'Document')
|
Document = apps.get_model("core", "Document")
|
||||||
Document.objects.filter(link_reach='public').update(is_public=True)
|
Document.objects.filter(link_reach="public").update(is_public=True)
|
||||||
Document.objects.filter(link_reach__in=['restricted', "authenticated"]).update(is_public=False)
|
Document.objects.filter(link_reach__in=["restricted", "authenticated"]).update(
|
||||||
|
is_public=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0003_document_link_reach_document_link_role_and_more'),
|
("core", "0003_document_link_reach_document_link_role_and_more"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(
|
migrations.RunPython(
|
||||||
migrate_is_public_to_link_reach,
|
migrate_is_public_to_link_reach, reverse_migrate_link_reach_to_is_public
|
||||||
reverse_migrate_link_reach_to_is_public
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,15 +4,16 @@ from django.db import migrations, models
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0004_migrate_is_public_to_link_reach'),
|
("core", "0004_migrate_is_public_to_link_reach"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='title',
|
name="title",
|
||||||
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='title'),
|
field=models.CharField(
|
||||||
|
blank=True, max_length=255, null=True, verbose_name="title"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,25 +4,34 @@ from django.db import migrations, models
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
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 = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='user',
|
model_name="user",
|
||||||
name='full_name',
|
name="full_name",
|
||||||
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='full name'),
|
field=models.CharField(
|
||||||
|
blank=True, max_length=100, null=True, verbose_name="full name"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='user',
|
model_name="user",
|
||||||
name='short_name',
|
name="short_name",
|
||||||
field=models.CharField(blank=True, max_length=20, null=True, verbose_name='short name'),
|
field=models.CharField(
|
||||||
|
blank=True, max_length=20, null=True, verbose_name="short name"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='user',
|
model_name="user",
|
||||||
name='language',
|
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'),
|
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",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -117,10 +117,10 @@ BEGIN
|
|||||||
END $$;
|
END $$;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0006_add_user_full_name_and_short_name'),
|
("core", "0006_add_user_full_name_and_short_name"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|||||||
@@ -4,15 +4,22 @@ from django.db import migrations, models
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0007_fix_users_duplicate'),
|
("core", "0007_fix_users_duplicate"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='link_reach',
|
name="link_reach",
|
||||||
field=models.CharField(choices=[('restricted', 'Restricted'), ('authenticated', 'Authenticated'), ('public', 'Public')], default='restricted', max_length=20),
|
field=models.CharField(
|
||||||
|
choices=[
|
||||||
|
("restricted", "Restricted"),
|
||||||
|
("authenticated", "Authenticated"),
|
||||||
|
("public", "Public"),
|
||||||
|
],
|
||||||
|
default="restricted",
|
||||||
|
max_length=20,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,37 +1,87 @@
|
|||||||
# Generated by Django 5.1.2 on 2024-11-08 07:59
|
# Generated by Django 5.1.2 on 2024-11-08 07:59
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0008_alter_document_link_reach'),
|
("core", "0008_alter_document_link_reach"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='user',
|
model_name="user",
|
||||||
name='language',
|
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'),
|
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(
|
migrations.CreateModel(
|
||||||
name='DocumentFavorite',
|
name="DocumentFavorite",
|
||||||
fields=[
|
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')),
|
"id",
|
||||||
('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')),
|
models.UUIDField(
|
||||||
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='favorited_by_users', to='core.document')),
|
default=uuid.uuid4,
|
||||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='favorite_documents', to=settings.AUTH_USER_MODEL)),
|
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={
|
options={
|
||||||
'verbose_name': 'Document favorite',
|
"verbose_name": "Document favorite",
|
||||||
'verbose_name_plural': 'Document favorites',
|
"verbose_name_plural": "Document favorites",
|
||||||
'db_table': 'impress_document_favorite',
|
"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.')],
|
"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.",
|
||||||
|
)
|
||||||
|
],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -7,25 +7,48 @@ from django.db import migrations, models
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0009_add_document_favorite'),
|
("core", "0009_add_document_favorite"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='creator',
|
name="creator",
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.RESTRICT, related_name='documents_created', to=settings.AUTH_USER_MODEL),
|
field=models.ForeignKey(
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.RESTRICT,
|
||||||
|
related_name="documents_created",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='user',
|
model_name="user",
|
||||||
name='language',
|
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'),
|
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(
|
migrations.AlterField(
|
||||||
model_name='user',
|
model_name="user",
|
||||||
name='sub',
|
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'),
|
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",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations
|
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):
|
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")
|
DocumentAccess = apps.get_model("core", "DocumentAccess")
|
||||||
|
|
||||||
# Update `creator` using the "owner" role
|
# Update `creator` using the "owner" role
|
||||||
owner_subquery = DocumentAccess.objects.filter(
|
owner_subquery = (
|
||||||
document=OuterRef('pk'),
|
DocumentAccess.objects.filter(
|
||||||
user__isnull=False,
|
document=OuterRef("pk"),
|
||||||
role='owner',
|
user__isnull=False,
|
||||||
).order_by('created_at').values('user_id')[:1]
|
role="owner",
|
||||||
|
)
|
||||||
|
.order_by("created_at")
|
||||||
|
.values("user_id")[:1]
|
||||||
|
)
|
||||||
|
|
||||||
Document.objects.filter(
|
Document.objects.filter(creator__isnull=True).update(
|
||||||
creator__isnull=True
|
creator=Subquery(owner_subquery)
|
||||||
).update(creator=Subquery(owner_subquery))
|
)
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0010_add_field_creator_to_document'),
|
("core", "0010_add_field_creator_to_document"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
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(
|
migrations.AlterField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='creator',
|
name="creator",
|
||||||
field=ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='documents_created', to=settings.AUTH_USER_MODEL),
|
field=ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.RESTRICT,
|
||||||
|
related_name="documents_created",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -6,25 +6,42 @@ from django.db import migrations, models
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0011_populate_creator_field_and_make_it_required'),
|
("core", "0011_populate_creator_field_and_make_it_required"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='creator',
|
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),
|
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(
|
migrations.AlterField(
|
||||||
model_name='invitation',
|
model_name="invitation",
|
||||||
name='issuer',
|
name="issuer",
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='invitations', to=settings.AUTH_USER_MODEL),
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="invitations",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='user',
|
model_name="user",
|
||||||
name='language',
|
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'),
|
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",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0012_make_document_creator_and_invitation_issuer_optional'),
|
("core", "0012_make_document_creator_and_invitation_issuer_optional"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|||||||
@@ -4,28 +4,29 @@ from django.db import migrations, models
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0013_activate_fuzzystrmatch_extension'),
|
("core", "0013_activate_fuzzystrmatch_extension"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='depth',
|
name="depth",
|
||||||
field=models.PositiveIntegerField(default=0),
|
field=models.PositiveIntegerField(default=0),
|
||||||
preserve_default=False,
|
preserve_default=False,
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='numchild',
|
name="numchild",
|
||||||
field=models.PositiveIntegerField(default=0),
|
field=models.PositiveIntegerField(default=0),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='path',
|
name="path",
|
||||||
# Allow null values pending the next datamigration to populate the field
|
# 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,
|
preserve_default=False,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from treebeard.numconv import NumConv
|
|||||||
ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||||
STEPLEN = 7
|
STEPLEN = 7
|
||||||
|
|
||||||
|
|
||||||
def set_path_on_existing_documents(apps, schema_editor):
|
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
|
||||||
@@ -26,27 +27,25 @@ def set_path_on_existing_documents(apps, schema_editor):
|
|||||||
updates = []
|
updates = []
|
||||||
for i, pk in enumerate(documents):
|
for i, pk in enumerate(documents):
|
||||||
key = numconv.int2str(i)
|
key = numconv.int2str(i)
|
||||||
path = "{0}{1}".format(
|
path = "{0}{1}".format(ALPHABET[0] * (STEPLEN - len(key)), key)
|
||||||
ALPHABET[0] * (STEPLEN - len(key)),
|
|
||||||
key
|
|
||||||
)
|
|
||||||
updates.append(Document(pk=pk, path=path, depth=1))
|
updates.append(Document(pk=pk, path=path, depth=1))
|
||||||
|
|
||||||
# Bulk update using the prepared updates list
|
# 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):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0014_add_tree_structure_to_documents'),
|
("core", "0014_add_tree_structure_to_documents"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
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(
|
migrations.AlterField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='path',
|
name="path",
|
||||||
field=models.CharField(db_collation='C', max_length=252, unique=True),
|
field=models.CharField(db_collation="C", max_length=252, unique=True),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,20 +4,27 @@ from django.db import migrations, models
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0015_set_path_on_existing_documents'),
|
("core", "0015_set_path_on_existing_documents"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='excerpt',
|
name="excerpt",
|
||||||
field=models.TextField(blank=True, max_length=300, null=True, verbose_name='excerpt'),
|
field=models.TextField(
|
||||||
|
blank=True, max_length=300, null=True, verbose_name="excerpt"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='user',
|
model_name="user",
|
||||||
name='language',
|
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'),
|
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",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,33 +4,49 @@ from django.db import migrations, models
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0016_add_document_excerpt'),
|
("core", "0016_add_document_excerpt"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterModelOptions(
|
migrations.AlterModelOptions(
|
||||||
name='document',
|
name="document",
|
||||||
options={'ordering': ('path',), 'verbose_name': 'Document', 'verbose_name_plural': 'Documents'},
|
options={
|
||||||
|
"ordering": ("path",),
|
||||||
|
"verbose_name": "Document",
|
||||||
|
"verbose_name_plural": "Documents",
|
||||||
|
},
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='ancestors_deleted_at',
|
name="ancestors_deleted_at",
|
||||||
field=models.DateTimeField(blank=True, null=True),
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='document',
|
model_name="document",
|
||||||
name='deleted_at',
|
name="deleted_at",
|
||||||
field=models.DateTimeField(blank=True, null=True),
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='user',
|
model_name="user",
|
||||||
name='language',
|
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'),
|
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(
|
migrations.AddConstraint(
|
||||||
model_name='document',
|
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'),
|
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",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class Migration(migrations.Migration):
|
|||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(
|
migrations.RunPython(
|
||||||
update_titles_to_null,
|
update_titles_to_null, reverse_code=migrations.RunPython.noop
|
||||||
reverse_code=migrations.RunPython.noop
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ exclude = [
|
|||||||
"build",
|
"build",
|
||||||
"venv",
|
"venv",
|
||||||
"__pycache__",
|
"__pycache__",
|
||||||
"*/migrations/*",
|
|
||||||
]
|
]
|
||||||
line-length = 88
|
line-length = 88
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user