Skip to content

Commit

Permalink
Merge d7d81de into 0595611
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmiller committed Oct 3, 2018
2 parents 0595611 + d7d81de commit 103a25b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
5 changes: 5 additions & 0 deletions changelog.md
@@ -1,5 +1,10 @@
### 0.13.0 (Major Release)

#### Removes the deprecated Model._title property

Use of `Model._title` to set a display name of a subrecord has issued a warning for several
releases - this has now been removed and will no longer work.

### 0.12.0 (Major Release)

#### Misc Changes
Expand Down
7 changes: 0 additions & 7 deletions opal/models.py
Expand Up @@ -895,13 +895,6 @@ def get_icon(cls):

@classmethod
def get_display_name(cls):
if hasattr(cls, '_title'):
w = "_title has been deprecated and will be removed in v0.12.0, "
w = w + "please use verbose_name in Meta instead for {}"
logging.warning(
w.format(cls.__name__)
)
return cls._title
if cls._meta.verbose_name.islower():
return cls._meta.verbose_name.title()
return cls._meta.verbose_name
Expand Down
10 changes: 5 additions & 5 deletions opal/templatetags/panels.py
Expand Up @@ -65,12 +65,12 @@ def record_timeline(model, whenfield):
name = camelcase_to_underscore(model.__class__.__name__)

return {
'name': name,
'editable': True,
'title': getattr(model, '_title', name.replace('_', ' ').title()),
'name' : name,
'editable' : True,
'title' : model.__class__.get_display_name(),
'detail_template': model.__class__.get_detail_template(),
'icon': getattr(model, '_icon', None),
'whenfield': whenfield,
'icon' : getattr(model, '_icon', None),
'whenfield' : whenfield,
}


Expand Down
4 changes: 3 additions & 1 deletion opal/tests/models.py
Expand Up @@ -43,12 +43,14 @@ class Meta:


class EntitledHatWearer(models.EpisodeSubrecord):
_title = 'Entitled Wearer of Hats'
_advanced_searchable = False
_exclude_from_extract = True

name = dmodels.CharField(max_length=200)

class Meta:
verbose_name = 'Entitled Wearer of Hats'


class InvisibleHatWearer(models.EpisodeSubrecord):
_exclude_from_subrecords = True
Expand Down
10 changes: 0 additions & 10 deletions opal/tests/test_models.py
Expand Up @@ -283,16 +283,6 @@ def test_get_template_with_prefixes(self, find):
])
self.assertEqual(result, "found")

@patch('opal.models.logging')
def test_get_display_name_from_property(self, logging):
display_name = EntitledHatWearer.get_display_name()
self.assertEqual('Entitled Wearer of Hats', display_name)
self.assertTrue(logging.warning)
logging.warning.assert_called_once_with(
"_title has been deprecated and will be removed in v0.12.0, please \
use verbose_name in Meta instead for EntitledHatWearer"
)

def test_get_display_name_from_meta_verbose_name(self):
self.assertEqual(
'Invisible Wearer of Hats',
Expand Down
9 changes: 9 additions & 0 deletions opal/tests/test_templatetags_panels.py
Expand Up @@ -3,6 +3,8 @@
"""
import os

from mock import patch

from django.template import Template, Context
from opal.core.test import OpalTestCase
from opal.templatetags import panels
Expand Down Expand Up @@ -75,6 +77,7 @@ def test_error_thrown(self):


class RecordTimelineTestCase(OpalTestCase):

def test_record_timeline(self):
expected = dict(
name='demographics',
Expand All @@ -87,6 +90,12 @@ def test_record_timeline(self):
result = panels.record_timeline(Demographics(), 'when')
self.assertEqual(expected, result)

def test_record_timeline_uses_get_display_name(self):
with patch.object(Demographics, 'get_display_name') as display:
display.return_value = 'Person Deets'
result = panels.record_timeline(Demographics(), 'when')
self.assertEqual('Person Deets', result['title'])


class TemasPanelTestCase(OpalTestCase):
def test_teams_panel(self):
Expand Down

0 comments on commit 103a25b

Please sign in to comment.