(project) add Room, Ressource, Access models from Magnify

I picked few models from Magnify to build our MVP:

- Resource:
   A generic model representing any type of resource. Though currently used only by Room,
   it encapsulates a meaningful business logic as an abstract model.
- Room:
   The primary object we manipulate, representing a meeting room with access
   and permission controls.
- ResourceAccess
   Ensures relevant users have the appropriate permissions for a given room.

** What’s different from Magnify ? **

Removed group logic; it will be added later. For now, we rely on the user model's
property to get its groups via desk.

Removed any logic or method related to Jitsi or LiveKit. These servers will be integrated
in the upcomming commits.

Focus on Room-related models to maintain a minimal and functional product (KISS principle)
until we achieve product-market fit (PMF).

Creating simple public and private, permanent and temporary rooms
is sufficient for building our MVP.

The Meeting model in Magnify, which supports recurrence, should be handled by
the collaborative calendar instead.

Adapted the unit test to use Pytest, and linted all the sources using Ruff linter.

(Migrations will be squashed before releasing the MVP)
This commit is contained in:
lebaudantoine
2024-06-24 19:14:27 +02:00
parent fbe79b7b2b
commit 2e6feede31
6 changed files with 565 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
# Generated by Django 5.0.3 on 2024-06-24 15:37
import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0002_create_pg_trgm_extension'),
]
operations = [
migrations.CreateModel(
name='Resource',
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')),
('is_public', models.BooleanField(default=True)),
],
options={
'verbose_name': 'Resource',
'verbose_name_plural': 'Resources',
'db_table': 'impress_resource',
},
),
migrations.RemoveField(
model_name='documentaccess',
name='document',
),
migrations.RemoveField(
model_name='invitation',
name='document',
),
migrations.RemoveField(
model_name='documentaccess',
name='user',
),
migrations.RemoveField(
model_name='invitation',
name='issuer',
),
migrations.RemoveField(
model_name='templateaccess',
name='template',
),
migrations.RemoveField(
model_name='templateaccess',
name='user',
),
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'),
),
migrations.CreateModel(
name='Room',
fields=[
('name', models.CharField(max_length=500)),
('resource', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.resource')),
('slug', models.SlugField(blank=True, max_length=100, null=True, unique=True)),
('configuration', models.JSONField(blank=True, default={}, help_text='Values for Magnify parameters to configure the room.', verbose_name='Magnify room configuration')),
],
options={
'verbose_name': 'Room',
'verbose_name_plural': 'Rooms',
'db_table': 'impress_room',
'ordering': ('name',),
},
bases=('core.resource',),
),
migrations.CreateModel(
name='ResourceAccess',
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')),
('role', models.CharField(choices=[('member', 'Member'), ('administrator', 'Administrator'), ('owner', 'Owner')], default='member', max_length=20)),
('resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='accesses', to='core.resource')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='accesses', to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'Resource access',
'verbose_name_plural': 'Resource accesses',
'db_table': 'impress_resource_access',
},
),
migrations.AddField(
model_name='resource',
name='users',
field=models.ManyToManyField(related_name='resources', through='core.ResourceAccess', to=settings.AUTH_USER_MODEL),
),
migrations.DeleteModel(
name='Document',
),
migrations.DeleteModel(
name='DocumentAccess',
),
migrations.DeleteModel(
name='Invitation',
),
migrations.DeleteModel(
name='Template',
),
migrations.DeleteModel(
name='TemplateAccess',
),
migrations.AddConstraint(
model_name='resourceaccess',
constraint=models.UniqueConstraint(fields=('user', 'resource'), name='resource_access_unique_user_resource', violation_error_message='Resource access with this user and resource already exists.'),
),
]