Skip to content

Commit

Permalink
chore/updated-migrations (#871)
Browse files Browse the repository at this point in the history
* 2 migrations

* Tidy up OrganisationRole logic

Co-authored-by: Matthew Elwell <[email protected]>
  • Loading branch information
dabeeeenster and matthewelwell authored Mar 24, 2022
1 parent d64609a commit a0b4b87
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 13 deletions.
17 changes: 17 additions & 0 deletions api/features/migrations/0036_alter_feature_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.12 on 2022-03-23 11:42

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('features', '0035_auto_20211109_0603'),
]

operations = [
migrations.AlterModelOptions(
name='feature',
options={'ordering': ('id',)},
),
]
23 changes: 23 additions & 0 deletions api/organisations/invites/migrations/0003_auto_20220323_1455.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.12 on 2022-03-23 14:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('invites', '0002_auto_20210118_2026'),
]

operations = [
migrations.AlterField(
model_name='invite',
name='role',
field=models.CharField(choices=[('ADMIN', 'Admin'), ('USER', 'User')], default='USER', max_length=50),
),
migrations.AlterField(
model_name='invitelink',
name='role',
field=models.CharField(choices=[('ADMIN', 'Admin'), ('USER', 'User')], default='USER', max_length=50),
),
]
10 changes: 4 additions & 6 deletions api/organisations/invites/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
from django.utils import timezone

from app.utils import create_hash
from organisations.models import (
Organisation,
OrganisationRole,
organisation_roles,
)
from organisations.models import Organisation, OrganisationRole
from users.models import FFAdminUser


Expand All @@ -18,7 +14,9 @@ class AbstractBaseInviteModel(models.Model):
date_created = models.DateTimeField("DateCreated", auto_now_add=True)
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE)
role = models.CharField(
choices=organisation_roles, max_length=50, default=OrganisationRole.USER.name
choices=OrganisationRole.choices,
max_length=50,
default=OrganisationRole.USER,
)

class Meta:
Expand Down
18 changes: 18 additions & 0 deletions api/organisations/migrations/0030_alter_userorganisation_role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2022-03-23 14:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('organisations', '0029_add_max_api_calls_to_subscription_model'),
]

operations = [
migrations.AlterField(
model_name='userorganisation',
name='role',
field=models.CharField(choices=[('ADMIN', 'Admin'), ('USER', 'User')], max_length=50),
),
]
11 changes: 4 additions & 7 deletions api/organisations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
from webhooks.models import AbstractBaseWebhookModel


class OrganisationRole(enum.Enum):
ADMIN = "ADMIN"
USER = "USER"


organisation_roles = ((tag.name, tag.value) for tag in OrganisationRole)
class OrganisationRole(models.TextChoices):
ADMIN = ("ADMIN", "Admin")
USER = ("USER", "User")


class Organisation(models.Model):
Expand Down Expand Up @@ -89,7 +86,7 @@ class UserOrganisation(models.Model):
user = models.ForeignKey("users.FFAdminUser", on_delete=models.CASCADE)
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE)
date_joined = models.DateTimeField(auto_now_add=True)
role = models.CharField(max_length=50, choices=organisation_roles)
role = models.CharField(max_length=50, choices=OrganisationRole.choices)

class Meta:
unique_together = (
Expand Down

0 comments on commit a0b4b87

Please sign in to comment.