-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Generated by Django 4.2.9 on 2024-02-05 16:05 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("galaxy", "0048_update_collection_remote_rhcertified_url"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Organization", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
( | ||
"created_on", | ||
models.DateTimeField( | ||
default=None, | ||
editable=False, | ||
help_text="The date/time this resource was created", | ||
), | ||
), | ||
( | ||
"modified_on", | ||
models.DateTimeField( | ||
default=None, | ||
editable=False, | ||
help_text="The date/time this resource was created", | ||
), | ||
), | ||
( | ||
"name", | ||
models.CharField( | ||
help_text="The name of this resource", max_length=512, unique=True | ||
), | ||
), | ||
( | ||
"description", | ||
models.TextField( | ||
blank=True, default="", help_text="The organization description." | ||
), | ||
), | ||
( | ||
"created_by", | ||
models.ForeignKey( | ||
default=None, | ||
editable=False, | ||
help_text="The user who created this resource", | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
related_name="%(app_label)s_%(class)s_created+", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
( | ||
"main_group", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="+", | ||
to="galaxy.group", | ||
), | ||
), | ||
( | ||
"modified_by", | ||
models.ForeignKey( | ||
default=None, | ||
editable=False, | ||
help_text="The user who last modified this resource", | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
related_name="%(app_label)s_%(class)s_modified+", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="OrganizationTeam", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
( | ||
"organization", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="+", | ||
to="galaxy.organization", | ||
), | ||
), | ||
( | ||
"team", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="+", | ||
to="galaxy.group", | ||
), | ||
), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name="organization", | ||
name="teams", | ||
field=models.ManyToManyField(through="galaxy.OrganizationTeam", to="galaxy.group"), | ||
), | ||
migrations.AddConstraint( | ||
model_name="organizationteam", | ||
constraint=models.UniqueConstraint( | ||
models.F("organization"), models.F("team"), name="uq_organization_team" | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.db import models | ||
from ansible_base.lib.abstract_models import AbstractOrganization | ||
|
||
from .auth import Group | ||
|
||
|
||
class Organization(AbstractOrganization): | ||
"""An organization model.""" | ||
main_group = models.OneToOneField(Group, on_delete=models.CASCADE, related_name='+') | ||
|
||
teams = models.ManyToManyField(Group, through="OrganizationTeam") | ||
|
||
|
||
class OrganizationTeam(models.Model): | ||
"""A team to organization relationship joint table.""" | ||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name='+') | ||
team = models.OneToOneField(Group, on_delete=models.CASCADE, related_name='+') | ||
|
||
class Meta: | ||
constraints = [ | ||
models.UniqueConstraint("organization", "team", name="uq_organization_team"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters