Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migration for GroupMembership model #39

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions imperial_coldfront_plugin/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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)),
],
),
]
14 changes: 11 additions & 3 deletions imperial_coldfront_plugin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
)