Beispiel #1
0
    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)]
Beispiel #2
0
 def get(self, code):
     video = g.store.find(Video, code=code).one_or_none()
     if video is None:
         g.store.add(Event('VIDEO_STATUS_CHECK', {'code': code}))
         g.store.commit()
         return {'eta': Video.get_eta(g.store)}
     return video.dict(users=is_authenticated())
Beispiel #3
0
 def post(self, code):
     video = Video.get_or_create(g.store, {'code': code})
     user = self.get_resource('user', create=True)
     video.append(user, ip=get_ip())
     g.store.commit()
     return video.dict(users=is_authenticated())