Commit f55e474f authored by Julian Rother's avatar Julian Rother

Fixed decorator issue in schedule_* functions

parent 72555a73
......@@ -10,17 +10,7 @@ def set_metadata(dest, course, lecture):
dest['metadata'] = metadata
dest['chapters'] = chapters
@app.route('/internal/jobs/add/remux', methods=['GET', 'POST'])
@mod_required
@csrf_protect
def schedule_remux(lectureid=None, videoid=None):
ret = None
if not lectureid:
lectureid = request.values.get('lectureid')
videoid = int(request.values.get('videoid', 0))
if not lectureid:
lectureid = query('SELECT lecture_id FROM videos WHERE id = ?', videoid)[0]['lecture_id']
ret = redirect(request.values.get('ref', url_for('jobs_overview')))
def schedule_remux(lectureid, videoid=None):
lecture = query('SELECT * FROM lectures WHERE id = ?', lectureid)[0]
course = query('SELECT * FROM courses WHERE id = ?', lecture['course_id'])[0]
videos = query('''SELECT videos.*, sources.path AS srcpath, sources.hash AS srchash, formats.options AS fmtopts
......@@ -41,7 +31,17 @@ def schedule_remux(lectureid=None, videoid=None):
data['options'] = fmt.get('options', {})
set_metadata(data, course, lecture)
schedule_job('remux', data)
return ret
@app.route('/internal/jobs/add/remux', methods=['GET', 'POST'])
@mod_required
@csrf_protect
def add_remux_job():
lectureid = request.values.get('lectureid')
videoid = int(request.values.get('videoid', 0))
if not lectureid:
lectureid = query('SELECT lecture_id FROM videos WHERE id = ?', videoid)[0]['lecture_id']
schedule_remux(lectureid, videoid)
return redirect(request.values.get('ref', url_for('jobs_overview')))
def schedule_transcode(source, fmt_id=None, video=None):
if video:
......@@ -78,7 +78,7 @@ def schedule_transcode(source, fmt_id=None, video=None):
@mod_required
@csrf_protect
@handle_errors('jobs_overview', 'Video nicht gefunden!', 404, IndexError)
def schedule_reencode():
def add_reencode_job():
video = query('SELECT * FROM videos WHERE id = ?', request.values['videoid'])[0]
if not video['source']:
flash('Manuell erstellte Videos können nicht neukodiert werden!')
......
......@@ -53,15 +53,7 @@ def insert_video(lectureid, dbfilepath, fileformatid, hash="", filesize=-1, dura
course = query('SELECT * FROM courses WHERE id = ?', lecture['course_id'])[0]
notify_mods('new_video', course['id'], course=course, lecture=lecture, video=video)
@app.route('/internal/jobs/add/thumbnail', methods=['GET', 'POST'])
@mod_required
@csrf_protect
@handle_errors('jobs_overview', 'Zu dieser Veranstaltung existieren keine Videos!', 404, IndexError)
def schedule_thumbnail(lectureid=None):
ret = None
if not lectureid:
lectureid = request.values['lectureid']
ret = redirect(request.values.get('ref', url_for('jobs_overview')))
def schedule_thumbnail(lectureid):
videos = query('''
SELECT videos.path
FROM videos
......@@ -69,7 +61,14 @@ def schedule_thumbnail(lectureid=None):
WHERE videos.lecture_id = ?
ORDER BY formats.prio DESC''', lectureid)
schedule_job('thumbnail', {'lectureid': str(lectureid), 'path': videos[0]['path']})
return ret
@app.route('/internal/jobs/add/thumbnail', methods=['GET', 'POST'])
@mod_required
@csrf_protect
@handle_errors('jobs_overview', 'Zu dieser Veranstaltung existieren keine Videos!', 404, IndexError)
def add_thumbnail_job():
schedule_thumbnail(request.values['lectureid'])
return redirect(request.values.get('ref', url_for('jobs_overview')))
@job_handler('transcode')
def insert_transcoded_video(jobid, jobtype, data, state, status):
......
......@@ -18,7 +18,7 @@
</ul>
<div class="tab-content" style="margin-top: 10px;">
<div role="tabpanel" class="tab-pane active" id="add_thumbnail">
<form class="form-inline" action="{{url_for('schedule_thumbnail', ref=request.url)}}" method="post">
<form class="form-inline" action="{{url_for('add_thumbnail_job', ref=request.url)}}" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Lecture ID" name="lectureid">
<button type="submit" class="btn btn-primary">Thumbnail erzeugen</button>
......@@ -26,13 +26,13 @@
</form>
</div>
<div role="tabpanel" class="tab-pane" id="add_remux">
<form class="form-inline" action="{{url_for('schedule_remux', ref=request.url)}}" method="post">
<form class="form-inline" action="{{url_for('add_remux_job', ref=request.url)}}" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Lecture ID" name="lectureid">
<button type="submit" class="btn btn-primary">Videos remuxen</button>
</div>
</form><br>
<form class="form-inline" action="{{url_for('schedule_remux', ref=request.url)}}" method="post">
<form class="form-inline" action="{{url_for('add_remux_job', ref=request.url)}}" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Video ID" name="videoid">
<button type="submit" class="btn btn-primary">Einzelnes Video remuxen</button>
......@@ -40,7 +40,7 @@
</form>
</div>
<div role="tabpanel" class="tab-pane" id="add_reencode">
<form class="form-inline" action="{{url_for('schedule_reencode', ref=request.url)}}" method="post">
<form class="form-inline" action="{{url_for('add_reencode_job', ref=request.url)}}" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Video ID" name="videoid">
<button type="submit" class="btn btn-primary">Video neukodieren</button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment