Exemplo n.º 1
0
    def delete(self, id):
        video = VideoDAO.find_video_by_id(id)
        if not video:
            return RESOURCE_NOT_FOUND, 404

        VideoDAO.delete_video(video)
        return {"message": "Video Deleted Successfully."}, 200
Exemplo n.º 2
0
 def post(self, id):
     video = VideoDAO.find_video_by_id(id)
     if not video:
         return RESOURCE_NOT_FOUND, 404
     data = request.json
     validation_result = validate_video_sections_data(data)
     if validation_result:
         return validation_result, 400
     section_ids = data["sections"]
     sections = SectionDAO.find_sections_by_ids(section_ids)
     note = ""
     if sections.count() != len(section_ids):
         note = "Not all sections are valid/existing!"
     all_sections_added = VideoDAO.add_video_sections(video, sections)
     if not all_sections_added:
         note += " Duplicate video sections detected and they were not added!"
     response = {"message": "Video sections added successfully."}, 201
     if note:
         response = {"message": note}, 201
     return response