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 model for unix uid #41

Merged
merged 4 commits into from
Nov 21, 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
24 changes: 24 additions & 0 deletions imperial_coldfront_plugin/migrations/0002_unixuid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.11 on 2024-11-21 14:41

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('imperial_coldfront_plugin', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='UnixUID',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('identifier', models.IntegerField()),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='user_id', to=settings.AUTH_USER_MODEL)),
],
),
]
21 changes: 21 additions & 0 deletions imperial_coldfront_plugin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,24 @@ class GroupMembership(models.Model):
on_delete=models.CASCADE,
related_name="group_memberships_set",
)


class UnixUID(models.Model):
"""Identity data to map a user to a unique identifier.

This model stores a unique identifier for each user, which can be used to
identify users in external systems. The identifier is an integer value that
is unique to each user user.

Attributes:
user (OneToOneField): A reference to the user, connected to AUTH_USER_MODEL.
Deletes the related identifier when the user is deleted.
identifier (IntegerField): A unique identifier for the user.
"""

user = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="user_id",
)
identifier = models.IntegerField()