From 2ebf5ee71ce564f30ab5b43a4eb9feb0a69f4552 Mon Sep 17 00:00:00 2001 From: Julian Rother <julianr@fsmpi.rwth-aachen.de> Date: Sat, 10 Sep 2016 13:21:21 +0200 Subject: [PATCH] Made code more compatible with mysql --- db_schema.sql | 6 +++--- server.py | 4 +++- templates/courses.html | 2 +- templates/index.html | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/db_schema.sql b/db_schema.sql index f38b5a5..7e60de3 100644 --- a/db_schema.sql +++ b/db_schema.sql @@ -45,7 +45,7 @@ CREATE TABLE IF NOT EXISTS `courses_data` ( `visible` INTEGER NOT NULL DEFAULT '0', `listed` INTEGER NOT NULL DEFAULT '1', `deleted` INTEGER NOT NULL DEFAULT '0', - `title` text NOT NULL DEFAULT 'Neue Veranstaltung', + `title` text NOT NULL DEFAULT '', `short` varchar(32) NOT NULL DEFAULT '', `handle` varchar(32) NOT NULL DEFAULT '', `organizer` text NOT NULL DEFAULT '', @@ -185,7 +185,7 @@ CREATE TABLE IF NOT EXISTS `videos_data` ( ); CREATE TABLE IF NOT EXISTS `announcements` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - `text` text NOT NULL DEFAULT "Neue Ankündigung", + `text` text NOT NULL DEFAULT '', `internal` text NOT NULL DEFAULT "", `level` INTEGER NOT NULL DEFAULT 0, `visible` INTEGER NOT NULL DEFAULT 0, @@ -196,7 +196,7 @@ CREATE TABLE IF NOT EXISTS `announcements` ( ); CREATE TABLE IF NOT EXISTS `featured` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - `title` text NOT NULL DEFAULT "Neuer Artikel", + `title` text NOT NULL DEFAULT '', `text` text NOT NULL DEFAULT "", `internal` text NOT NULL DEFAULT "", `visible` INTEGER NOT NULL DEFAULT 0, diff --git a/server.py b/server.py index 3c4c19d..6fe4b8d 100755 --- a/server.py +++ b/server.py @@ -364,7 +364,9 @@ def stats(): @register_navbar('Changelog', icon='book') @mod_required def changelog(): - changelog = query('SELECT *, ( "table" || "." || id_value || "." ||field) as path FROM changelog LEFT JOIN users ON (changelog.who = users.id) ORDER BY `when` DESC LIMIT 50') + changelog = query('SELECT * FROM changelog LEFT JOIN users ON (changelog.who = users.id) ORDER BY `when` DESC LIMIT 50') + for entry in changelog: + entry['path'] = '.'.join([entry['table'], entry['id_value'], entry['field']]) return render_template('changelog.html', changelog=changelog) @app.route('/files/<filename>') diff --git a/templates/courses.html b/templates/courses.html index 6f34a57..7a1cf91 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('create', table='courses', handle='new'+(randint(0,1000)|string), responsible=session.user.givenName, ref=request.url) }}">Neue Veranstaltung</a> + <a class="btn btn-default" href="{{ url_for('create', table='courses', handle='new'+(randint(0,1000)|string), title='Neue Veranstaltung', responsible=session.user.givenName, ref=request.url) }}">Neue Veranstaltung</a> </li> {% endif %} <li class="dropdown" style="padding-right: 0px"> diff --git a/templates/index.html b/templates/index.html index 8426f5d..9251993 100644 --- a/templates/index.html +++ b/templates/index.html @@ -8,7 +8,7 @@ <ul class="list-inline pull-right"> {% if ismod() %} <li style="padding-right: 0px;"> - <a class="btn btn-default" href="{{ url_for('create', table='announcements', ref=request.url) }}">Neue Ankündigung</a> + <a class="btn btn-default" href="{{ url_for('create', table='announcements', text='Neue Ankündigung', ref=request.url) }}">Neue Ankündigung</a> </li> {% endif %} </ul> @@ -35,7 +35,7 @@ <div class="panel-heading"> <h1 class="panel-title">Featured {% if ismod() %} - <a class="btn btn-default" href="{{ url_for('create', table='featured', ref=request.url) }}">Neue Empfehlung</a> + <a class="btn btn-default" href="{{ url_for('create', table='featured', title='Neuer Artikel', ref=request.url) }}">Neue Empfehlung</a> {% endif %} </h1> </div> -- GitLab