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

Added ordering buttons for featured panels

parent 8cbe0793
......@@ -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,
......
......@@ -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
......
......@@ -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' %}
......
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