def update_recording(quip_id): parser = reqparse.RequestParser() parser.add_argument('duration', type=int, location='json') parser.add_argument('position', type=int, location='json') parser.add_argument('progress', type=int, location='json') parser.add_argument('isPublic', type=bool, location='json') update = parser.parse_args() Recording.objects(Q(id=quip_id)).modify( upsert=True, set__isPublic=update['isPublic'] ) Listen.objects(Q(user=g.user['id']) & Q(recording=quip_id)).modify( upsert=True, set__progress=update['progress'], set__position=update['position'], set__duration=update['duration'], ) return QuipMapper.to_web_dto(Recording.objects.get_or_404(Q(id=quip_id))), 200
def get_user_recording_stats(): num_recordings = Recording.objects(Q(user=g.user['id'])).count() return { 'num_recordings': num_recordings, 'user': g.user }
def get_list_of_user_recordings(user_id): dbref_user_id = User.objects.get(username=user_id) entities = Recording.objects(Q(isPublic=True) & Q(user=dbref_user_id))[:50].order_by('-postedAt') return map(QuipMapper.to_web_dto, entities)
def get_list_all_recordings(): entities = Recording.objects(Q(isPublic=True))[:50].order_by('-postedAt') return map(QuipMapper.to_web_dto, entities)