diff --git a/db_schema.sql b/db_schema.sql index 5496ae135ae94978890b0be2c467403b622ad265..f38b5a5380314ea71fc5b12cc6192f9b0df9bbfd 100644 --- a/db_schema.sql +++ b/db_schema.sql @@ -42,26 +42,26 @@ CREATE TABLE IF NOT EXISTS `chapters` ( ); CREATE TABLE IF NOT EXISTS `courses_data` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - `visible` INTEGER NOT NULL, + `visible` INTEGER NOT NULL DEFAULT '0', `listed` INTEGER NOT NULL DEFAULT '1', `deleted` INTEGER NOT NULL DEFAULT '0', - `title` text NOT NULL, - `short` varchar(32) NOT NULL, - `handle` varchar(32) NOT NULL, - `organizer` text NOT NULL, - `subject` varchar(32) NOT NULL, + `title` text NOT NULL DEFAULT 'Neue Veranstaltung', + `short` varchar(32) NOT NULL DEFAULT '', + `handle` varchar(32) NOT NULL DEFAULT '', + `organizer` text NOT NULL DEFAULT '', + `subject` varchar(32) NOT NULL DEFAULT '', `credits` INTEGER NOT NULL DEFAULT '0', `created_by` INTEGER DEFAULT NULL, `time_created` datetime NOT NULL, `time_updated` datetime NOT NULL, - `semester` char(6) NOT NULL, - `settings` text NOT NULL, + `semester` char(6) NOT NULL DEFAULT '', + `settings` text NOT NULL DEFAULT '', `downloadable` INTEGER NOT NULL DEFAULT '1', `embedinvisible` INTEGER NOT NULL DEFAULT '0', - `description` text NOT NULL, - `internal` text NOT NULL, - `responsible` text NOT NULL, - `feed_url` text NOT NULL + `description` text NOT NULL DEFAULT '', + `internal` text NOT NULL DEFAULT '', + `responsible` text NOT NULL DEFAULT '', + `feed_url` text NOT NULL DEFAULT '' ); CREATE TABLE IF NOT EXISTS `filesizes` ( `path` varchar(255) NOT NULL PRIMARY KEY, diff --git a/server.py b/server.py index 769228a1bc393d8cbdce2613e35d79b031f8cc08..ff8dfc8339a4f8ddbfd1203b8c32c9ea2f8a45a1 100755 --- a/server.py +++ b/server.py @@ -12,6 +12,7 @@ app = Flask(__name__) app.jinja_env.trim_blocks = True app.jinja_env.lstrip_blocks = True +app.add_template_global(random.randint, name='randint') def timer_func(): with app.test_request_context(): @@ -295,21 +296,6 @@ def create(table): return redirect(request.values['ref']) return str(id), 200 -@app.route('/newcourse', methods=['GET', 'POST']) -@mod_required -def new_course(): - id = modify(''' - 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 new_lecture(courseid): diff --git a/templates/courses.html b/templates/courses.html index f8f07bf0b99a085af995c81da5bb273f67733179..6f34a57b01eae78802de039bdfa6c5aed548341e 100644 --- a/templates/courses.html +++ b/templates/courses.html @@ -9,7 +9,7 @@ </li> {% if ismod() %} <li> - <a class="btn btn-default" href="{{ url_for('new_course', ref=request.url) }}">Neue Veranstaltung</a> + <a class="btn btn-default" href="{{ url_for('create', table='courses', handle='new'+(randint(0,1000)|string), responsible=session.user.givenName, ref=request.url) }}">Neue Veranstaltung</a> </li> {% endif %} <li class="dropdown" style="padding-right: 0px">