Skip to content
Snippets Groups Projects
Commit 7b01c4e7 authored by Julian Rother's avatar Julian Rother
Browse files

Implemented newcourse and newlecture

parent a3a201fc
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import threading
import os
import hashlib
import locale
import random
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
......@@ -219,7 +220,7 @@ def logout():
@app.route('/edit', methods=['GET', 'POST'])
@mod_required
def edit():
def edit(prefix="", ignore=[]):
tabs = {
'courses': ('courses_data', 'id', ['visible', 'listed', 'title', 'short',
'handle', 'organizer', 'subject', 'semester', 'downloadable',
......@@ -235,6 +236,9 @@ def edit():
else:
changes = request.args.items()
for key, val in changes:
if key in ignore:
continue
key = prefix+key
table, id, column = key.split('.', 2)
assert table in tabs
assert column in tabs[table][2]
......@@ -243,6 +247,35 @@ def edit():
query('COMMIT')
return "OK", 200
@app.route('/newcourse', methods=['GET', 'POST'])
@mod_required
def newcourse():
id = query('''
INSERT INTO courses_data
(visible, title, short, handle, organizer, subject, created_by, time_created,
time_updated, semester, settings, description, internal, responsible, feed_url)
VALUES (0, "Neue Veranstaltung", "Neu", ?, "", "", ?, ?, ?, "", "", "", "", ?, "")
''', 'new'+str(random.randint(0,1000)), session['user']['dbid'], datetime.now(), datetime.now(),
session['user']['givenName'])
edit(prefix='courses.'+str(id)+'.', ignore=['ref'])
if 'ref' in request.values:
return redirect(request.values['ref'])
return str(id), 200
@app.route('/newlecture/<courseid>', methods=['GET', 'POST'])
@mod_required
def newlecture(courseid):
id = query('''
INSERT INTO lectures_data
(course_id, visible, drehplan, title, comment, internal, speaker, place,
time, time_created, time_updated, jumplist, titlefile)
VALUES (?, 0, "", "Noch kein Titel", "", "", "", "", ?, ?, ?, "", "")
''', courseid, datetime.now(), datetime.now(), datetime.now())
edit(prefix='lectures.'+str(id)+'.', ignore=['ref'])
if 'ref' in request.values:
return redirect(request.values['ref'])
return str(id), 200
@app.route('/auth')
def auth(): # For use with nginx auth_request
if 'X-Original-Uri' not in request.headers:
......
......@@ -4,7 +4,7 @@
<div class="row">
<div class="col-xs-12 dropdown" style="margin-bottom: 10px;">
<span class="pull-right">
{% if ismod() %} <a class="btn btn-default" style="margin-right: 5px;" href="todo">Neue Veranstaltung</a> {% endif %}
{% if ismod() %} <a class="btn btn-default" style="margin-right: 5px;" href="{{ url_for('newcourse', ref=request.url) }}">Neue Veranstaltung</a> {% endif %}
<button class="btn btn-primary dropdown-toggle pull-right" type="button" data-toggle="dropdown">Gruppierung
<span class="caret"></span></button>
......
......@@ -31,7 +31,7 @@
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">Videos{% if ismod() %} <a class="btn btn-default" style="margin-right: 5px;" href="todo">Neuer Termin</a><a class="btn btn-default" style="margin-right: 5px;" href="{{url_for('import_from', id=course['id'])}}">Campus Import</a>{% endif %}</h1>
<h1 class="panel-title">Videos{% if ismod() %} <a class="btn btn-default" style="margin-right: 5px;" href="{{ url_for('newlecture', courseid=course.id, ref=request.url) }}">Neuer Termin</a><a class="btn btn-default" style="margin-right: 5px;" href="{{url_for('import_from', id=course['id'])}}">Campus Import</a>{% endif %}</h1>
</div>
<ul class="list-group lectureslist">
{% for l in lectures %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment