Skip to content

Commit

Permalink
Source | restricting hierarchy_meaning choices
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Apr 17, 2021
1 parent 167f97b commit 8d8d812
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions core/sources/constants.py
Expand Up @@ -7,3 +7,9 @@
CONTENT_REFERRED_PRIVATELY = 'Could not delete source "{}". One or more resources in the source are ' \
'referenced by private repositories. Contact an OCL administrator for more information.'
HIERARCHY_ROOT_MUST_BELONG_TO_SAME_SOURCE = 'Hierarchy Root must belong to the same Source.'
HIERARCHY_MEANINGS = (
('grouped-by', 'grouped-by'),
('is-a', 'is-a'),
('part-of', 'part-of'),
('classified-with', 'classified-with'),
)
18 changes: 18 additions & 0 deletions core/sources/migrations/0018_auto_20210417_0430.py
@@ -0,0 +1,18 @@
# Generated by Django 3.1.8 on 2021-04-17 04:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sources', '0017_source_hierarchy_root'),
]

operations = [
migrations.AlterField(
model_name='source',
name='hierarchy_meaning',
field=models.CharField(blank=True, choices=[('grouped-by', 'grouped-by'), ('is-a', 'is-a'), ('part-of', 'part-of'), ('classified-with', 'classified-with')], max_length=50, null=True),
),
]
5 changes: 3 additions & 2 deletions core/sources/models.py
Expand Up @@ -8,7 +8,8 @@
from core.common.models import ConceptContainerModel
from core.common.utils import reverse_resource, get_query_params_from_url_string
from core.concepts.models import LocalizedText
from core.sources.constants import SOURCE_TYPE, SOURCE_VERSION_TYPE, HIERARCHY_ROOT_MUST_BELONG_TO_SAME_SOURCE
from core.sources.constants import SOURCE_TYPE, SOURCE_VERSION_TYPE, HIERARCHY_ROOT_MUST_BELONG_TO_SAME_SOURCE, \
HIERARCHY_MEANINGS


class Source(ConceptContainerModel):
Expand Down Expand Up @@ -44,7 +45,7 @@ class Meta:
source_type = models.TextField(blank=True, null=True)
content_type = models.TextField(blank=True, null=True)
collection_reference = models.CharField(null=True, blank=True, max_length=100)
hierarchy_meaning = models.CharField(null=True, blank=True, max_length=50)
hierarchy_meaning = models.CharField(null=True, blank=True, max_length=50, choices=HIERARCHY_MEANINGS)
case_sensitive = models.BooleanField(null=True, blank=True, default=None)
compositional = models.BooleanField(null=True, blank=True, default=None)
version_needed = models.BooleanField(null=True, blank=True, default=None)
Expand Down

0 comments on commit 8d8d812

Please sign in to comment.