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

Added ordering buttons for featured panels

parent 8cbe0793
No related branches found
No related tags found
No related merge requests found
...@@ -222,7 +222,7 @@ CREATE TABLE IF NOT EXISTS `featured` ( ...@@ -222,7 +222,7 @@ CREATE TABLE IF NOT EXISTS `featured` (
`internal` text NOT NULL DEFAULT '', `internal` text NOT NULL DEFAULT '',
`type` varchar(32) NOT NULL DEFAULT '', `type` varchar(32) NOT NULL DEFAULT '',
`param` text NOT NULL DEFAULT '', `param` text NOT NULL DEFAULT '',
`order` INTEGER UNIQUE, `order` INTEGER NOT NULL,
`visible` INTEGER NOT NULL DEFAULT 0, `visible` INTEGER NOT NULL DEFAULT 0,
`deleted` INTEGER NOT NULL DEFAULT 0, `deleted` INTEGER NOT NULL DEFAULT 0,
`time_created` datetime NOT NULL, `time_created` datetime NOT NULL,
......
...@@ -330,7 +330,7 @@ def index(): ...@@ -330,7 +330,7 @@ def index():
newfeatured = 0 newfeatured = 0
if featured: if featured:
newfeatured = featured[-1]['order'] + 1 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) return render_template('index.html', latestvideos=livestreams+latestvideos, upcomming=upcomming, featured=featured, newfeatured=newfeatured)
@app.route('/course') @app.route('/course')
...@@ -514,7 +514,6 @@ def edit(prefix='', ignore=[]): ...@@ -514,7 +514,6 @@ def edit(prefix='', ignore=[]):
ignore.append('_csrf_token') ignore.append('_csrf_token')
if not prefix and 'prefix' in request.args: if not prefix and 'prefix' in request.args:
prefix = request.args['prefix'] prefix = request.args['prefix']
modify('BEGIN')
changes = request.values.items() changes = request.values.items()
if (request.method == 'POST') and (request.get_json()): if (request.method == 'POST') and (request.get_json()):
changes = request.get_json().items() changes = request.get_json().items()
...@@ -525,10 +524,9 @@ def edit(prefix='', ignore=[]): ...@@ -525,10 +524,9 @@ def edit(prefix='', ignore=[]):
table, id, column = key.split('.', 2) table, id, column = key.split('.', 2)
assert table in tabs assert table in tabs
assert column in tabs[table][2] 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']) 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('UPDATE %s SET `%s` = ?, time_updated = ? WHERE `%s` = ?'%(tabs[table][0], column, tabs[table][1]), val, datetime.now(), id)
modify('COMMIT')
if 'ref' in request.values: if 'ref' in request.values:
return redirect(request.values['ref']) return redirect(request.values['ref'])
return "OK", 200 return "OK", 200
......
...@@ -76,9 +76,17 @@ ...@@ -76,9 +76,17 @@
<div class="panel-heading"> <div class="panel-heading">
<h1 class="panel-title"> <h1 class="panel-title">
{{ moderator_editor(('featured',item.id,'title'), item.title) }} {{ moderator_checkbox(('featured',item.id,'visible'), item.visible) }} {{ moderator_editor(('featured',item.id,'title'), item.title) }} {{ moderator_checkbox(('featured',item.id,'visible'), item.visible) }}
{% if ismod() %}
<ul class="pull-right list-inline"> <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> <li>{{ moderator_delete(['featured',item.id,'deleted']) }}</li>
</ul> </ul>
{% endif %}
</h1> </h1>
</div> </div>
{% if item.type == 'image' %} {% if item.type == 'image' %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment