Skip to content

Commit

Permalink
Using ternary equivalent for conditional attribute access
Browse files Browse the repository at this point in the history
  • Loading branch information
cuttlefish committed Jan 24, 2018
1 parent ddeef70 commit 196b3d5
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions mapstory/mapstories/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,12 @@ def get_absolute_url(self):
return '/story/' + str(self.slug) + '/'

def viewer_json(self, user):
if self.category is not None:
category_id = self.category.id
else:
category_id = None

about = {
'title': self.title,
'abstract': self.abstract,
'owner': self.owner.name_long,
'username': self.owner.username,
'categoryID': category_id
'categoryID': self.category.id if self.category is not None else None
}

config = {
Expand Down

0 comments on commit 196b3d5

Please sign in to comment.