Show broadcasts created by the API

Broadcasts created by the API are different in that:
- they aren’t created by any user, so don’t have a `created_by_id`
- they are created instantly, not in steps, so don’t have an
  `updated_at` time

This commit alters the views to account for when these pieces of
information aren’t present.
This commit is contained in:
Chris Hill-Scott
2021-01-27 11:24:22 +00:00
parent 60aa2d2b42
commit 5ae53b625b
4 changed files with 95 additions and 15 deletions

View File

@@ -45,6 +45,10 @@ class BroadcastMessage(JSONModel):
return True
if not self.starts_at and other.starts_at:
return False
if self.updated_at and not other.updated_at:
return self.updated_at < other.created_at
if not self.updated_at and other.updated_at:
return self.created_at < other.updated_at
return self.updated_at < other.updated_at
@classmethod
@@ -129,7 +133,7 @@ class BroadcastMessage(JSONModel):
@cached_property
def created_by(self):
return User.from_id(self.created_by_id)
return User.from_id(self.created_by_id) if self.created_by_id else None
@cached_property
def approved_by(self):