diff --git a/db_schema.sql b/db_schema.sql index 03ea4c23fe8cd72bfadfe11b083eaf17ddd18b6d..8ec94a7af613e06816beb3abded23e8a79b56da1 100644 --- a/db_schema.sql +++ b/db_schema.sql @@ -222,7 +222,7 @@ CREATE TABLE IF NOT EXISTS `featured` ( `internal` text NOT NULL DEFAULT '', `type` varchar(32) NOT NULL DEFAULT '', `param` text NOT NULL DEFAULT '', - `order` INTEGER UNIQUE, + `order` INTEGER NOT NULL, `visible` INTEGER NOT NULL DEFAULT 0, `deleted` INTEGER NOT NULL DEFAULT 0, `time_created` datetime NOT NULL, diff --git a/server.py b/server.py index d6202bfdf656f02d0fc6d4bc2ef8129329d23fee..3f5e4240b8607dbbb342c616882e085b846abcba 100644 --- a/server.py +++ b/server.py @@ -330,7 +330,7 @@ def index(): newfeatured = 0 if featured: newfeatured = featured[-1]['order'] + 1 - featured = filter(lambda x: not x['deleted'], featured) + featured = list(filter(lambda x: not x['deleted'], featured)) return render_template('index.html', latestvideos=livestreams+latestvideos, upcomming=upcomming, featured=featured, newfeatured=newfeatured) @app.route('/course') @@ -514,7 +514,6 @@ def edit(prefix='', ignore=[]): ignore.append('_csrf_token') if not prefix and 'prefix' in request.args: prefix = request.args['prefix'] - modify('BEGIN') changes = request.values.items() if (request.method == 'POST') and (request.get_json()): changes = request.get_json().items() @@ -525,10 +524,9 @@ def edit(prefix='', ignore=[]): table, id, column = key.split('.', 2) assert table in tabs assert column in tabs[table][2] - modify('INSERT INTO changelog (`table`,id_value, id_key, field, value_new, value_old, `when`, who, executed) VALUES (?,?,?,?,?,(SELECT %s FROM %s WHERE %s = ?),?,?,1)'%(column, tabs[table][0], tabs[table][1]), + modify('INSERT INTO changelog (`table`,id_value, id_key, field, value_new, value_old, `when`, who, executed) VALUES (?,?,?,?,?,(SELECT `%s` FROM %s WHERE %s = ?),?,?,1)'%(column, tabs[table][0], tabs[table][1]), table, id, tabs[table][1], column, val, id, datetime.now(), session['user']['dbid']) - modify('UPDATE %s SET %s = ?, time_updated = ? WHERE `%s` = ?'%(tabs[table][0], column, tabs[table][1]), val, datetime.now(), id) - modify('COMMIT') + modify('UPDATE %s SET `%s` = ?, time_updated = ? WHERE `%s` = ?'%(tabs[table][0], column, tabs[table][1]), val, datetime.now(), id) if 'ref' in request.values: return redirect(request.values['ref']) return "OK", 200 diff --git a/templates/index.html b/templates/index.html index 762281f9e2623cd7a650307f2277e904a1d0ba4f..15589a586fcef9644e4daa9d713c5171b84eacce 100644 --- a/templates/index.html +++ b/templates/index.html @@ -76,9 +76,17 @@ <div class="panel-heading"> <h1 class="panel-title"> {{ moderator_editor(('featured',item.id,'title'), item.title) }} {{ moderator_checkbox(('featured',item.id,'visible'), item.visible) }} + {% if ismod() %} <ul class="pull-right list-inline"> + {% if not loop.first %} + <li><a class="btn btn-default" href="{{ url_for('edit', **{'featured.'+item.id|string+'.order': featured[loop.index0-1].order, 'featured.'+featured[loop.index0-1].id|string+'.order': item.order, 'ref': request.url})}}"><span class="glyphicon glyphicon-arrow-up"></span></a></li> + {% endif %} + {% if not loop.last %} + <li><a class="btn btn-default" href="{{ url_for('edit', **{'featured.'+item.id|string+'.order': featured[loop.index0+1].order, 'featured.'+featured[loop.index0+1].id|string+'.order': item.order, 'ref': request.url})}}"><span class="glyphicon glyphicon-arrow-down"></span></a></li> + {% endif %} <li>{{ moderator_delete(['featured',item.id,'deleted']) }}</li> </ul> + {% endif %} </h1> </div> {% if item.type == 'image' %}