Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Merge pull request #238 from theonion/infographics
Browse files Browse the repository at this point in the history
Infographics
  • Loading branch information
benghaziboy committed Jun 29, 2016
2 parents f390ca1 + 48c22ab commit 21dc174
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Development

## Version 3.1.3

- Added `AbstractInfographic.get_infographic_type_name` method.

## Version 3.1.2

- Added styling for mobile ads in bulbs-styles
Expand Down
2 changes: 1 addition & 1 deletion bulbs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.1.2"
__version__ = "3.1.3"
8 changes: 8 additions & 0 deletions bulbs/infographics/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ class InfographicType(enum.Enum):
STRONGSIDE_WEAKSIDE = 2
PRO_CON = 3
COMPARISON = 4

labels = {
LIST: "List",
TIMELINE: "Timeline",
STRONGSIDE_WEAKSIDE: "Strongside_Weakside",
PRO_CON: "Pro_Con",
COMPARISON: "Comparison"
}
3 changes: 3 additions & 0 deletions bulbs/infographics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class AbstractInfographic(models.Model):
class Meta:
abstract = True

def get_infographic_type_name(self):
return InfographicType.label(self.infographic_type)

def get_data_serializer(self):
return get_data_serializer(self.infographic_type)

Expand Down
14 changes: 14 additions & 0 deletions tests/infographics/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,17 @@ def test_timeline_validator(self):
}]
}
)

def test_get_infographic_type_name(self):
instance = BaseInfographic.objects.create(
title="A GOD BOY ADVENTURE",
infographic_type=InfographicType.TIMELINE,
data={
"entries": [{
"title": "Sickass",
"copy": "heya",
"image": {"id": 50}
}]
}
)
self.assertEqual(instance.get_infographic_type_name(), "Timeline")

0 comments on commit 21dc174

Please sign in to comment.