forked from rapidpro/rapidpro
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5774 from nyaruka/remove_viewers
Data migration to remove viewers from workspaces
- Loading branch information
Showing
4 changed files
with
27 additions
and
11 deletions.
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,17 @@ | ||
# Generated by Django 5.1.4 on 2025-01-08 20:51 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def remove_viewers(apps, schema_editor): | ||
OrgMembership = apps.get_model("orgs", "OrgMembership") | ||
num_deleted = OrgMembership.objects.filter(role_code="V").delete()[0] | ||
if num_deleted: | ||
print(f"Deleted {num_deleted} viewer memberships") | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [("orgs", "0163_squashed")] | ||
|
||
operations = [migrations.RunPython(remove_viewers, migrations.RunPython.noop)] |
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,10 @@ | ||
from temba.tests import MigrationTest | ||
|
||
|
||
class RemoveViewersTest(MigrationTest): | ||
app = "orgs" | ||
migrate_from = "0163_squashed" | ||
migrate_to = "0164_remove_viewers" | ||
|
||
def test_migration(self): | ||
self.assertEqual({self.admin, self.editor, self.agent}, set(self.org.get_users())) |
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