Skip to content

Commit

Permalink
don't title abbreviations
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Aug 18, 2016
1 parent 78ef1d6 commit 8b5b1c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions opal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ def _get_field_title(cls, name):
else:
field_name = field.verbose_name

if field_name.islower():
field_name = field_name.title()

except FieldDoesNotExist:
# else its foreign key or free text
field_name = getattr(cls, name).verbose_name

if field_name.islower():
field_name = field_name.title()

return field_name

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion opal/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Dog(lookuplists.LookupList):
class DogOwner(models.EpisodeSubrecord):
name = dmodels.CharField(max_length=200)
dog = fields.ForeignKeyOrFreeText(Dog)
ownership_start_date = dmodels.DateField(blank=True, null=True)
ownership_start_date = dmodels.DateField(blank=True, null=True, verbose_name="OSD")


class HoundOwner(models.EpisodeSubrecord):
Expand Down
5 changes: 5 additions & 0 deletions opal/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ def test_verbose_name(self):
only_words = FamousLastWords._get_field_title("words")
self.assertEqual(only_words, "Only Words")

def test_verbose_name_abbreviation(self):
# if a word is an abbreviation already, don't title case it!
osd = DogOwner._get_field_title("ownership_start_date")
self.assertEqual(osd, "OSD")


class BulkUpdateFromDictsTest(OpalTestCase):

Expand Down

0 comments on commit 8b5b1c6

Please sign in to comment.