diff --git a/imperial_coldfront_plugin/migrations/0001_initial.py b/imperial_coldfront_plugin/migrations/0001_initial.py new file mode 100644 index 0000000..1c3198c --- /dev/null +++ b/imperial_coldfront_plugin/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.11 on 2024-11-18 16:50 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='GroupMembership', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('member', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='group_memberships_set', to=settings.AUTH_USER_MODEL)), + ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='owned_group_memberships_set', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/imperial_coldfront_plugin/models.py b/imperial_coldfront_plugin/models.py index ae7aa91..deb78c6 100644 --- a/imperial_coldfront_plugin/models.py +++ b/imperial_coldfront_plugin/models.py @@ -4,7 +4,7 @@ from django.db import models -class GroupMember(models.Model): +class GroupMembership(models.Model): """Membership relationship within a group, associating an owner with a member. This model stores relationships where each instance represents an ownership @@ -19,5 +19,13 @@ class GroupMember(models.Model): AUTH_USER_MODEL. Deletes related memberships when the member is deleted. """ - owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) - member = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) + owner = models.ForeignKey( + settings.AUTH_USER_MODEL, + on_delete=models.CASCADE, + related_name="owned_group_memberships_set", + ) + member = models.ForeignKey( + settings.AUTH_USER_MODEL, + on_delete=models.CASCADE, + related_name="group_memberships_set", + )