Skip to content

Commit

Permalink
Merge branch 'v0.13.0' into remove-copy-to-category
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Oct 4, 2018
2 parents 8291752 + fcd8481 commit 35e1a17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions changelog.md
Expand Up @@ -13,6 +13,14 @@ This includes the API endpoint at `episode/$id/actions/copyto/$category/`, the t
`copy_to_category.html`, the Angular controller `CopyToCategoryCtrl` and service
`CopyToCategory` and Subrecord property `_clonable`.


#### Lookuplist data format

Lookuplist entries in data files are no longer required to have an empty synonyms list
if the entry doesn't have a synonym. This reduces the file size and makes it easier to
hand craft data files for new applications.


#### Removes the deprecated Model._title property

Use of `Model._title` to set a display name of a subrecord has issued a warning for several
Expand Down
2 changes: 1 addition & 1 deletion opal/core/lookuplists.py
Expand Up @@ -16,7 +16,7 @@ def load_lookuplist_item(model, item):
instance, created = model.objects.get_or_create(name=item['name'])
synonyms_created = 0

for synonym in item['synonyms']:
for synonym in item.get('synonyms', []):
syn, created_synonym = Synonym.objects.get_or_create(
content_type=content_type,
object_id=instance.id,
Expand Down
7 changes: 7 additions & 0 deletions opal/tests/test_lookuplists.py
Expand Up @@ -20,6 +20,7 @@ def setUp(self):


class LookupListLoadingTestCase(AbstractLookupListTestCase):

def test_create_instance(self):
data = {"hat": [dict(name="Bowler", synonyms=[])]}
_, created, _ = load_lookuplist(data)
Expand Down Expand Up @@ -48,6 +49,12 @@ def test_create_instance_and_synonym(self):
self.assertEqual(created, 1)
self.assertEqual(synonyms, 1)

def test_create_instance_allow_no_symptom(self):
data = {"hat": [dict(name="Bowler")]}
_, created, synonyms = load_lookuplist(data)
self.assertEqual(created, 1)
self.assertEqual(synonyms, 0)


class LookupListClassTestCase(AbstractLookupListTestCase):
def test_unicode(self):
Expand Down

0 comments on commit 35e1a17

Please sign in to comment.