Commit a4b710f5 authored by Julian Rother's avatar Julian Rother
Browse files

Migrated new_lecture to "new" endpoint

parent ac621026
......@@ -84,19 +84,19 @@ CREATE TABLE IF NOT EXISTS `lectures_data` (
`visible` INTEGER NOT NULL DEFAULT '1',
`timed_release` datetime DEFAULT NULL,
`use_timed_release` INTEGER NOT NULL DEFAULT '0',
`drehplan` varchar(10) NOT NULL,
`drehplan` varchar(10) NOT NULL DEFAULT '',
`deleted` INTEGER NOT NULL DEFAULT '0',
`title` text NOT NULL,
`comment` text NOT NULL,
`internal` text NOT NULL,
`speaker` text NOT NULL,
`place` text NOT NULL,
`title` text NOT NULL DEFAULT '',
`comment` text NOT NULL DEFAULT '',
`internal` text NOT NULL DEFAULT '',
`speaker` text NOT NULL DEFAULT '',
`place` text NOT NULL DEFAULT '',
`time` datetime NOT NULL,
`duration` INTEGER NOT NULL DEFAULT '90',
`time_created` datetime NOT NULL,
`time_updated` datetime NOT NULL,
`jumplist` text NOT NULL,
`titlefile` varchar(255) NOT NULL
`jumplist` text NOT NULL DEFAULT '',
`titlefile` varchar(255) NOT NULL DEFAULT ''
);
CREATE TABLE IF NOT EXISTS `places` (
`place` varchar(20) NOT NULL PRIMARY KEY,
......
......@@ -257,13 +257,20 @@ def logout():
tabs = {
'courses': ('courses_data', 'id', ['visible', 'listed', 'title', 'short',
'handle', 'organizer', 'subject', 'semester', 'downloadable',
'internal', 'responsible','deleted']),
'internal', 'responsible','deleted'],
['created_by', 'time_created', 'time_updated']),
'lectures': ('lectures_data', 'id', ['visible', 'title', 'comment',
'internal', 'speaker', 'place', 'time', 'duration', 'jumplist','deleted']),
'videos': ('videos_data', 'id', ['visible','deleted']),
'chapters': ('chapters', 'id', ['time', 'text', 'visible', 'deleted']),
'announcements': ('announcements', 'id', ['text', 'level', 'visible', 'deleted', 'time_publish', 'time_expire']),
'featured': ('featured', 'id', ['title', 'text', 'internal', 'visible', 'deleted'])
'internal', 'speaker', 'place', 'time', 'duration', 'jumplist','deleted'],
['course_id', 'time_created', 'time_updated']),
'videos': ('videos_data', 'id', ['visible','deleted'],
['created_by', 'time_created', 'time_updated']),
'chapters': ('chapters', 'id', ['time', 'text', 'visible', 'deleted'],
['created_by', 'time_created', 'time_updated']),
'announcements': ('announcements', 'id', ['text', 'level', 'visible',
'deleted', 'time_publish', 'time_expire'],
['created_by', 'time_created', 'time_updated']),
'featured': ('featured', 'id', ['title', 'text', 'internal', 'visible', 'deleted'],
['created_by', 'time_created', 'time_updated'])
}
@app.route('/edit', methods=['GET', 'POST'])
......@@ -297,15 +304,21 @@ def edit(prefix='', ignore=[]):
@mod_required
def create(table):
assert table in tabs
columns = ['created_by', 'time_created', 'time_updated']
values = [session['user']['dbid'], datetime.now(), datetime.now()]
defaults = {'created_by': session['user']['dbid'], 'time_created': datetime.now(), 'time_updated': datetime.now()}
columns = []
values = []
for column, val in defaults.items():
if column in tabs[table][3]:
columns.append(column)
values.append(val)
args = request.values
if request.is_json:
args = request.get_json()
for column, val in args.items():
if column == 'ref':
continue
assert column in tabs[table][2]
assert column in tabs[table][2]+tabs[table][3]
assert column not in defaults
columns.append(column)
values.append(val)
id = modify('INSERT INTO %s (%s) VALUES (%s)'%(tabs[table][0],
......@@ -314,20 +327,6 @@ def create(table):
return redirect(request.values['ref'])
return str(id), 200
@app.route('/newlecture/<courseid>', methods=['GET', 'POST'])
@mod_required
def new_lecture(courseid):
id = modify('''
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:
......
......@@ -38,7 +38,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="{{ url_for('new_lecture', 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 %} <a class="fa fa-rss-square pull-right" aria-hidden="true" href="{{url_for('feed', handle=course.handle)}}"></a> </h1>
<h1 class="panel-title">Videos{% if ismod() %} <a class="btn btn-default" style="margin-right: 5px;" href="{{ url_for('create', table='lectures', time=datetime.now(), title='Noch kein Title', course_id=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 %} <a class="fa fa-rss-square pull-right" aria-hidden="true" href="{{url_for('feed', handle=course.handle)}}"></a> </h1>
</div>
<ul class="list-group lectureslist">
{% for l in lectures %}
......
......@@ -90,7 +90,7 @@
{{ valuedeletebtn(['lectures',i.id,'deleted']) }}
{% endif%}
{% if (i.type == 'import') %}
<button class="btn btn-default newlecture" onclick="moderatorinterface.gethttp('{{ url_for('new_lecture', courseid=course.id, time=i.time, title=i.title, place=i.place) }}')">anlegen</a>
<button class="btn btn-default newlecture" onclick="moderatorinterface.gethttp('{{ url_for('create', table='lecture', course_id=course.id, time=i.time, title=i.title, place=i.place) }}')">anlegen</a>
{% endif%}
</span>
</span>
......
Supports Markdown
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