Coverage for marvin.views.streams : 98%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" marvin.views.streams ~~~~~~~~~~~~~~~~~~~~
CRUD endpoints for streams.
""" # pylint: disable=no-self-use
""" RUD interface to streams. """
""" Get the stream with the given ID. """ 'stream': stream.to_json(), } else: stream.name, g.user) 'msg': 'This stream is not public yet.', }, 403 if g.user else 401
def put(self, stream_id): """ Update the stream with the given ID. """ 'msg': 'Stream updated.', 'stream': stream.to_json(), } 'msg': 'Some attributes did not pass validation.', 'errors': form.errors, }, 400 else: 'msg': "You're not allowed to edit this stream" }, 403
def delete(self, stream_id): """ Delete the stream with the given ID. """ else: 'msg': "You're not allowed to delete this stream." }, 403
""" Create interface for streams. """
def post(self, movie_id): """ Create new stream. """ 'msg': 'Stream created', 'stream': stream.to_json(), }, 201 'msg': 'Data did not validate.', 'errors': form.errors, }, 400
""" Read endpoint for entries in a stream. """
""" Get entries for the given stream.
Respect the following request parameters:
* ``limit``: Restrict number of entries returned to this amount. * ``starttime_gt``: Only return entries that enter after this time, in ms. """ .filter(Entry.entry_point_in_ms > starttime_gt) .order_by(Entry.entry_point_in_ms.asc()) .limit(max_number_of_entries)) 'entries': [entry.to_json() for entry in entries], } else: 'msg': 'This stream is not public yet.', }, 403 if g.user else 401
""" Publish the given stream. """
def post(self, stream_id): """ Publish the stream, increase movie's stream count. """ 'msg': 'This stream has already been published!', }, 400 'msg': 'Congratulations! The stream "%s" was published successfully.' % stream.name, } else: 'msg': 'You can only publish your own streams.' }, 403
""" Unpublish the given stream. """
def post(self, stream_id): """ Unpublish the stream, decrease movie's stream count. """ return { 'msg': "This stream hasn't been published yet!", }, 400 'msg': 'The stream "%s" was removed from public view successfully.' % stream.name, } else: 'msg': 'You can only unpublish your own streams.' }, 403 |