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

Migrated new_lecture to "new" endpoint

parent ac621026
No related branches found
No related tags found
No related merge requests found
...@@ -84,19 +84,19 @@ CREATE TABLE IF NOT EXISTS `lectures_data` ( ...@@ -84,19 +84,19 @@ CREATE TABLE IF NOT EXISTS `lectures_data` (
`visible` INTEGER NOT NULL DEFAULT '1', `visible` INTEGER NOT NULL DEFAULT '1',
`timed_release` datetime DEFAULT NULL, `timed_release` datetime DEFAULT NULL,
`use_timed_release` INTEGER NOT NULL DEFAULT '0', `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', `deleted` INTEGER NOT NULL DEFAULT '0',
`title` text NOT NULL, `title` text NOT NULL DEFAULT '',
`comment` text NOT NULL, `comment` text NOT NULL DEFAULT '',
`internal` text NOT NULL, `internal` text NOT NULL DEFAULT '',
`speaker` text NOT NULL, `speaker` text NOT NULL DEFAULT '',
`place` text NOT NULL, `place` text NOT NULL DEFAULT '',
`time` datetime NOT NULL, `time` datetime NOT NULL,
`duration` INTEGER NOT NULL DEFAULT '90', `duration` INTEGER NOT NULL DEFAULT '90',
`time_created` datetime NOT NULL, `time_created` datetime NOT NULL,
`time_updated` datetime NOT NULL, `time_updated` datetime NOT NULL,
`jumplist` text NOT NULL, `jumplist` text NOT NULL DEFAULT '',
`titlefile` varchar(255) NOT NULL `titlefile` varchar(255) NOT NULL DEFAULT ''
); );
CREATE TABLE IF NOT EXISTS `places` ( CREATE TABLE IF NOT EXISTS `places` (
`place` varchar(20) NOT NULL PRIMARY KEY, `place` varchar(20) NOT NULL PRIMARY KEY,
......
...@@ -257,13 +257,20 @@ def logout(): ...@@ -257,13 +257,20 @@ def logout():
tabs = { tabs = {
'courses': ('courses_data', 'id', ['visible', 'listed', 'title', 'short', 'courses': ('courses_data', 'id', ['visible', 'listed', 'title', 'short',
'handle', 'organizer', 'subject', 'semester', 'downloadable', 'handle', 'organizer', 'subject', 'semester', 'downloadable',
'internal', 'responsible','deleted']), 'internal', 'responsible','deleted'],
['created_by', 'time_created', 'time_updated']),
'lectures': ('lectures_data', 'id', ['visible', 'title', 'comment', 'lectures': ('lectures_data', 'id', ['visible', 'title', 'comment',
'internal', 'speaker', 'place', 'time', 'duration', 'jumplist','deleted']), 'internal', 'speaker', 'place', 'time', 'duration', 'jumplist','deleted'],
'videos': ('videos_data', 'id', ['visible','deleted']), ['course_id', 'time_created', 'time_updated']),
'chapters': ('chapters', 'id', ['time', 'text', 'visible', 'deleted']), 'videos': ('videos_data', 'id', ['visible','deleted'],
'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']) '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']) @app.route('/edit', methods=['GET', 'POST'])
...@@ -297,15 +304,21 @@ def edit(prefix='', ignore=[]): ...@@ -297,15 +304,21 @@ def edit(prefix='', ignore=[]):
@mod_required @mod_required
def create(table): def create(table):
assert table in tabs assert table in tabs
columns = ['created_by', 'time_created', 'time_updated'] defaults = {'created_by': session['user']['dbid'], 'time_created': datetime.now(), 'time_updated': datetime.now()}
values = [session['user']['dbid'], datetime.now(), 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 args = request.values
if request.is_json: if request.is_json:
args = request.get_json() args = request.get_json()
for column, val in args.items(): for column, val in args.items():
if column == 'ref': if column == 'ref':
continue continue
assert column in tabs[table][2] assert column in tabs[table][2]+tabs[table][3]
assert column not in defaults
columns.append(column) columns.append(column)
values.append(val) values.append(val)
id = modify('INSERT INTO %s (%s) VALUES (%s)'%(tabs[table][0], id = modify('INSERT INTO %s (%s) VALUES (%s)'%(tabs[table][0],
...@@ -314,20 +327,6 @@ def create(table): ...@@ -314,20 +327,6 @@ def create(table):
return redirect(request.values['ref']) return redirect(request.values['ref'])
return str(id), 200 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') @app.route('/auth')
def auth(): # For use with nginx auth_request def auth(): # For use with nginx auth_request
if 'X-Original-Uri' not in request.headers: if 'X-Original-Uri' not in request.headers:
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</div> </div>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <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> </div>
<ul class="list-group lectureslist"> <ul class="list-group lectureslist">
{% for l in lectures %} {% for l in lectures %}
......
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
{{ valuedeletebtn(['lectures',i.id,'deleted']) }} {{ valuedeletebtn(['lectures',i.id,'deleted']) }}
{% endif%} {% endif%}
{% if (i.type == 'import') %} {% 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%} {% endif%}
</span> </span>
</span> </span>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment