diff --git a/db_schema.sql b/db_schema.sql index d7ea117286d113879d83e600b77eac35f3bf236b..03ea4c23fe8cd72bfadfe11b083eaf17ddd18b6d 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 NOT NULL DEFAULT 0, + `order` INTEGER UNIQUE, `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 b7667864b128e7985fcf9daed43b69c5de21327c..d6202bfdf656f02d0fc6d4bc2ef8129329d23fee 100644 --- a/server.py +++ b/server.py @@ -326,8 +326,12 @@ def index(): JOIN courses ON courses.id = lectures.course_id WHERE streams.active AND (? OR (streams.visible AND courses.visible AND courses.listed AND lectures.visible)) ''', ismod()) - featured = query('SELECT * FROM featured WHERE NOT deleted AND (? OR visible) ORDER BY `order`', ismod()) - return render_template('index.html', latestvideos=livestreams+latestvideos, upcomming=upcomming, featured=featured) + featured = query('SELECT * FROM featured WHERE (? OR visible) ORDER BY `order`', ismod()) + newfeatured = 0 + if featured: + newfeatured = featured[-1]['order'] + 1 + featured = filter(lambda x: not x['deleted'], featured) + return render_template('index.html', latestvideos=livestreams+latestvideos, upcomming=upcomming, featured=featured, newfeatured=newfeatured) @app.route('/course') @register_navbar('Videos', icon='film') @@ -523,7 +527,7 @@ def edit(prefix='', ignore=[]): 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]), 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: return redirect(request.values['ref']) @@ -549,7 +553,7 @@ def create(table): continue assert column in tabs[table][2]+tabs[table][3] assert column not in defaults - columns.append(column) + columns.append('`'+column+'`') values.append(val) id = modify('INSERT INTO %s (%s) VALUES (%s)'%(tabs[table][0], ','.join(columns), ','.join(['?']*len(values))), *values) diff --git a/templates/index.html b/templates/index.html index e38a2e5f8ea1ec6ea31e7cb507544a10d3ff0ab0..762281f9e2623cd7a650307f2277e904a1d0ba4f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -53,6 +53,15 @@ <div class="row"> <div class="col-xs-12"> <ul class="list-inline pull-right"> + <li style="padding-right: 0px;"> + <div class="btn-group"> + <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Neues Panel <span class="caret"></span></button> + <ul class="dropdown-menu"> + <li><a href="{{ url_for('create', table='featured', title='Neues Panel', type='plain', ref=request.url, order=newfeatured) }}">Nur Text</a></li> + <li><a href="{{ url_for('create', table='featured', title='Neues Panel', type='image', ref=request.url, order=newfeatured) }}">Text mit Bild</a></li> + </ul> + </div> + </li> <li style="padding-right: 0px;"> <a class="btn btn-default" href="{{ url_for('create', table='announcements', text='Neue Ankündigung', time_publish=datetime.now().replace(hour=0, minute=0, second=0, microsecond=0), time_expire=datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)+timedelta(days=7), ref=request.url) }}">Neue Ankündigung</a> </li>