def patch(self, code):
        video = g.store.find(Video, code=code).one_or_none()
        if video is None:
            return message('video_not_found', code=404)

        if self.get_arg('donator') == 't':
            video.donator = True
        if self.get_arg('rendered'):
            video.rendered_on = datetime.now()

        g.store.commit()
        return video.dict(users=True)
    def get(self):
        queue = Video.get_queue(g.store)

        # If a specific index is requested, return it
        index = request.args.get('index', None)
        if index is not None and index.isdigit():
            try:
                return queue[int(index)].dict(users=True)
            except IndexError:
                return message('no_such_index', code=400)

        # Else return the whole queue
        return [v.dict(users=True) for v in Video.get_queue(g.store)]
 def decorated(*args, **kwargs):
     if not is_authenticated():
         return message('not_authenticated', 401)
     return func(*args, **kwargs)