-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenConceptLab/ocl_issues#1732 | URL registry | fixing namespace and …
…uniq clauses
- Loading branch information
1 parent
1e88723
commit 6c5b4eb
Showing
5 changed files
with
89 additions
and
74 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
21 changes: 21 additions & 0 deletions
21
core/url_registry/migrations/0002_remove_urlregistry_global_url_unique_and_more.py
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,21 @@ | ||
# Generated by Django 4.2.4 on 2024-01-15 02:56 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('url_registry', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveConstraint( | ||
model_name='urlregistry', | ||
name='global_url_unique', | ||
), | ||
migrations.AddConstraint( | ||
model_name='urlregistry', | ||
constraint=models.UniqueConstraint(condition=models.Q(('is_active', True), ('organization__isnull', True), ('user__isnull', True)), fields=('url',), name='global_url_unique'), | ||
), | ||
] |
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
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,20 @@ | ||
from core.common.tests import OCLTestCase | ||
from core.orgs.models import Organization | ||
from core.url_registry.models import URLRegistry | ||
from core.users.models import UserProfile | ||
|
||
|
||
class URLRegistryTest(OCLTestCase): | ||
def test_owner(self): | ||
org = Organization() | ||
user = UserProfile() | ||
self.assertEqual(URLRegistry().owner, None) | ||
self.assertEqual(URLRegistry(organization=org).owner, org) | ||
self.assertEqual(URLRegistry(user=user).owner, user) | ||
|
||
def test_owner_type(self): | ||
org = Organization() | ||
user = UserProfile() | ||
self.assertEqual(URLRegistry().owner_type, None) | ||
self.assertEqual(URLRegistry(organization=org).owner_type, 'Organization') | ||
self.assertEqual(URLRegistry(user=user).owner, 'User') |