Fix error in consumer when camp matching query does not exist.
This commit is contained in:
parent
af94eba144
commit
034543595a
|
@ -12,23 +12,26 @@ class ScheduleConsumer(JsonWebsocketConsumer):
|
||||||
|
|
||||||
def connect(self, message, **kwargs):
|
def connect(self, message, **kwargs):
|
||||||
camp_slug = message.http_session['campslug']
|
camp_slug = message.http_session['campslug']
|
||||||
camp = Camp.objects.get(slug=camp_slug)
|
try:
|
||||||
days = list(map(
|
camp = Camp.objects.get(slug=camp_slug)
|
||||||
lambda day:
|
days = list(map(
|
||||||
{ 'repr': day.lower.strftime('%A %Y-%m-%d')
|
lambda day:
|
||||||
, 'iso': day.lower.strftime('%Y-%m-%d')
|
{ 'repr': day.lower.strftime('%A %Y-%m-%d')
|
||||||
, 'day_name': day.lower.strftime('%A')
|
, 'iso': day.lower.strftime('%Y-%m-%d')
|
||||||
},
|
, 'day_name': day.lower.strftime('%A')
|
||||||
camp.get_days('camp')
|
},
|
||||||
))
|
camp.get_days('camp')
|
||||||
event_instances_query_set = EventInstance.objects.filter(event__camp=camp)
|
))
|
||||||
event_instances = list(map(lambda x: x.to_json(), event_instances_query_set))
|
event_instances_query_set = EventInstance.objects.filter(event__camp=camp)
|
||||||
self.send({
|
event_instances = list(map(lambda x: x.to_json(), event_instances_query_set))
|
||||||
"accept": True,
|
self.send({
|
||||||
"event_instances": event_instances,
|
"accept": True,
|
||||||
"days": days,
|
"event_instances": event_instances,
|
||||||
"action": "init"
|
"days": days,
|
||||||
})
|
"action": "init"
|
||||||
|
})
|
||||||
|
except Camp.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
def raw_receive(self, message, **kwargs):
|
def raw_receive(self, message, **kwargs):
|
||||||
content = self.decode_json(message['text'])
|
content = self.decode_json(message['text'])
|
||||||
|
|
Loading…
Reference in a new issue