mirror of https://github.com/zulip/zulip.git
get_stream: Use try/except
For consistency with the rest of our code. (imported from commit a2df17facad1a4e3b9e5e1dc4d33b64010cee939)
This commit is contained in:
parent
8df247708c
commit
f2ac76aeac
|
@ -84,10 +84,9 @@ def json_error(msg, data={}, status=400):
|
|||
return json_response(res_type="error", msg=msg, data=data, status=status)
|
||||
|
||||
def get_stream(stream_name, realm):
|
||||
stream = Stream.objects.filter(name__iexact=stream_name, realm=realm)
|
||||
if stream:
|
||||
return stream[0]
|
||||
else:
|
||||
try:
|
||||
return Stream.objects.get(name__iexact=stream_name, realm=realm)
|
||||
except Stream.DoesNotExist:
|
||||
return None
|
||||
|
||||
@require_post
|
||||
|
|
Loading…
Reference in New Issue