def update_highlight(request, page, name, time): try: # Trying first to update an existing highlight. highlight = models.Highlight.objects.get(page=page, name=name) highlight.time = time highlight.save() except models.Highlight.DoesNotExist: # Creating a new highlight. models.Highlight.objects.create(page=page, name=name, time=time) # Updating the max highlight ID used value. page.max_highlight_id_used = max(page.max_highlight_id_used, name) page.save() helpers.set_modified(page.flowgram)
def add_audio_fms(request, page, time, duration): file_path = '%s/%s/%s/%d.flv' % (localsettings.FMS_STREAM_DIR, page.flowgram.id, page.id, time) if os.path.isfile(file_path): audio = models.Audio.objects.create(page=page, time=time, duration=duration) audio.path = file_path helpers.set_modified(page.flowgram) s3.save_filename_to_bucket(localsettings.S3_BUCKET_AUDIO, '%s.flv' % audio.id, file_path) return data_response.create(request.POST.get('enc', 'json'), 'ok', audio.id) else: log.debug('add_audio_fms called with page.id=%s, time=%d, and duration=%d but file_path=%s DNE' % \ (page.id, time, duration, file_path)) return error_response.create(request.POST.get('enc', 'json'), 'flv does not exist.')
def delete_highlight(request, page, name): get_object_or_404(models.Highlight, page=page, name=name).delete() helpers.set_modified(page.flowgram)