def get_recording(quip_id): tiny_id = ObjectId(tinyurl.decode(quip_id)) record = Recording.objects.get_or_404(Q(id=tiny_id)) if not record or not record.isPublic or record.user.id != g.user['id']: return {}, 404 return QuipMapper.to_web_dto(record)
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