-
-
Notifications
You must be signed in to change notification settings - Fork 303
Add Organization and OrganizationRole models to studio #5953
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
Merged
bjester
merged 1 commit into
learningequality:unstable
from
yasinelmi:feature_organization_model
Jun 25, 2026
+284
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
contentcuration/contentcuration/constants/organization_roles.py
This file contains hidden or 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,23 @@ | ||
| ORGANIZATION_ADMIN = "admin" | ||
| ORGANIZATION_EDITOR = "editor" | ||
| ORGANIZATION_VIEWER = "viewer" | ||
|
|
||
| organization_role_choices = ( | ||
| (ORGANIZATION_ADMIN, "Admin"), | ||
| (ORGANIZATION_EDITOR, "Editor"), | ||
| (ORGANIZATION_VIEWER, "Viewer"), | ||
| ) | ||
|
|
||
| ORGANIZATION_ROLE_STATUS_ACTIVE = "active" | ||
| ORGANIZATION_ROLE_STATUS_INACTIVE = "inactive" | ||
| ORGANIZATION_ROLE_STATUS_PENDING = "pending" | ||
| ORGANIZATION_ROLE_STATUS_SUSPENDED = "suspended" | ||
| ORGANIZATION_ROLE_STATUS_DECLINED = "declined" | ||
|
|
||
| organization_role_status_choices = ( | ||
| (ORGANIZATION_ROLE_STATUS_ACTIVE, "Active"), | ||
| (ORGANIZATION_ROLE_STATUS_INACTIVE, "Inactive"), | ||
| (ORGANIZATION_ROLE_STATUS_PENDING, "Pending Invitation"), | ||
| (ORGANIZATION_ROLE_STATUS_SUSPENDED, "Suspended"), | ||
| (ORGANIZATION_ROLE_STATUS_DECLINED, "Declined Invitation"), | ||
| ) |
155 changes: 155 additions & 0 deletions
155
contentcuration/contentcuration/migrations/0167_add_organization.py
This file contains hidden or 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,155 @@ | ||
| # Generated by Django 3.2.24 on 2026-06-25 01:47 | ||
| import uuid | ||
|
|
||
| import django.db.models.deletion | ||
| from django.conf import settings | ||
| from django.db import migrations | ||
| from django.db import models | ||
|
|
||
| import contentcuration.models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("contentcuration", "0166_add_usersubscription"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="Organization", | ||
| fields=[ | ||
| ( | ||
| "id", | ||
| contentcuration.models.UUIDField( | ||
| default=uuid.uuid4, | ||
| max_length=32, | ||
| primary_key=True, | ||
| serialize=False, | ||
| ), | ||
| ), | ||
| ("name", models.CharField(db_index=True, max_length=200)), | ||
| ("description", models.TextField(blank=True)), | ||
| ("thumbnail", models.TextField(blank=True, null=True)), | ||
| ("thumbnail_encoding", models.JSONField(default=dict)), | ||
| ( | ||
| "public", | ||
| models.BooleanField( | ||
| db_index=True, | ||
| default=False, | ||
| help_text="Whether organization is publicly visible", | ||
| ), | ||
| ), | ||
| ( | ||
| "deleted", | ||
| models.BooleanField( | ||
| db_index=True, default=False, help_text="Soft delete flag" | ||
| ), | ||
| ), | ||
| ("created_at", models.DateTimeField(auto_now_add=True)), | ||
| ("updated_at", models.DateTimeField(auto_now=True)), | ||
| ], | ||
| options={ | ||
| "verbose_name": "Organization", | ||
| "verbose_name_plural": "Organizations", | ||
| "ordering": ["name"], | ||
| }, | ||
| ), | ||
| migrations.AddField( | ||
| model_name="channel", | ||
| name="organization", | ||
| field=models.ForeignKey( | ||
| blank=True, | ||
| help_text="Organization that this channel belongs to.", | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| related_name="channel_organization", | ||
| to="contentcuration.organization", | ||
| ), | ||
| ), | ||
| migrations.CreateModel( | ||
| name="OrganizationRole", | ||
| fields=[ | ||
| ( | ||
| "id", | ||
| contentcuration.models.UUIDField( | ||
| default=uuid.uuid4, | ||
| max_length=32, | ||
| primary_key=True, | ||
| serialize=False, | ||
| ), | ||
| ), | ||
| ( | ||
| "role", | ||
| models.CharField( | ||
| choices=[ | ||
| ("admin", "Admin"), | ||
| ("editor", "Editor"), | ||
| ("viewer", "Viewer"), | ||
| ], | ||
| help_text="The user's role within the organization.", | ||
| max_length=100, | ||
| ), | ||
| ), | ||
| ( | ||
| "description", | ||
| models.TextField( | ||
| blank=True, | ||
| help_text="Description of the user's role within the organization", | ||
| ), | ||
| ), | ||
| ( | ||
| "status", | ||
| models.CharField( | ||
| choices=[ | ||
| ("active", "Active"), | ||
| ("inactive", "Inactive"), | ||
| ("pending", "Pending Invitation"), | ||
| ("suspended", "Suspended"), | ||
| ("declined", "Declined Invitation"), | ||
| ], | ||
| db_index=True, | ||
| default="pending", | ||
| help_text="Membership status", | ||
| max_length=20, | ||
| ), | ||
| ), | ||
| ( | ||
| "joined_at", | ||
| models.DateTimeField( | ||
| auto_now_add=True, help_text="Date user joined the organization" | ||
| ), | ||
| ), | ||
| ( | ||
| "updated_at", | ||
| models.DateTimeField( | ||
| auto_now=True, help_text="Last update timestamp" | ||
| ), | ||
| ), | ||
| ( | ||
| "organization", | ||
| models.ForeignKey( | ||
| help_text="Organization the user belongs to", | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="user_roles", | ||
| to="contentcuration.organization", | ||
| ), | ||
| ), | ||
| ( | ||
| "user", | ||
| models.ForeignKey( | ||
| help_text="User in the organization", | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="organization_roles", | ||
| to=settings.AUTH_USER_MODEL, | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "verbose_name": "Organization Role", | ||
| "verbose_name_plural": "Organization Roles", | ||
| "ordering": ["-joined_at"], | ||
| "unique_together": {("user", "organization")}, | ||
| }, | ||
| ), | ||
| ] |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.