From 84dda40b1969beaf70fb159eb9504e70ad09b236 Mon Sep 17 00:00:00 2001
From: Andreas <andreasv@fsmpi.rwth-aachen.de>
Date: Sat, 10 Sep 2016 01:43:55 +0200
Subject: [PATCH] made "featured" editable

---
 server.py            |  3 ++-
 templates/base.html  |  6 ++++--
 templates/index.html | 51 +++++++++++++++++++++++++++-----------------
 3 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/server.py b/server.py
index 9122ff4..48d6d48 100755
--- a/server.py
+++ b/server.py
@@ -260,7 +260,8 @@ def edit(prefix="", ignore=[]):
 				'internal', 'speaker', 'place', 'time', 'duration', 'jumplist','deleted']),
 		'videos': ('videos_data', 'id', ['visible','deleted']),
 		'chapters': ('chapters', 'id', ['time', 'text', 'visible', 'deleted']),
-		'announcements': ('announcements', 'id', ['text', 'internal', 'level', 'visible', 'deleted'])
+		'announcements': ('announcements', 'id', ['text', 'internal', 'level', 'visible', 'deleted']),
+		'featured': ('featured', 'id', ['text', 'title', 'visible', 'deleted'])
 	}
 	modify('BEGIN')
 	if request.is_json:
diff --git a/templates/base.html b/templates/base.html
index 7680654..79ef4d8 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -102,11 +102,13 @@
 					{% endfor %}
 					{% for msg in get_announcements(min_announcement_level) if (not request.cookies['alert-info-'+msg.id|string]) or ismod() %}
 					<div class="alert alert-{{announcement_levels.get(msg.level, 'info')}}" role="alert">
-						<a href="#" class="close" data-dismiss="alert" aria-label="close" onclick="Cookies.set('alert-info-{{msg.id}}', '1');">&times;</a>
+						{% if not ismod() %}
+							<a href="#" class="close" data-dismiss="alert" aria-label="close" onclick="Cookies.set('alert-info-{{msg.id}}', '1');">&times;</a>
+						{% endif %}
 						<ul class="list-unstyled">
 							<li>{{ valueeditor(('announcements',msg.id,'text'), msg.text|safe) }}</li>
-						{% if ismod() %}
 							<li class="pull-right">{{ valuedeletebtn(('announcements',msg.id,'deleted')) }}</li>
+						{% if ismod() %}
 							<li>{{ valueeditor(('announcements',msg.id,'internal'), msg.internal) }}</li>
 							<li class="pull-right">Sichtbar: {{ valuecheckbox(('announcements',msg.id,'visible'),msg.visible) }}</li>
 							<li>Level: {{ valueeditor(('announcements',msg.id,'level'), msg.level) }}</li>
diff --git a/templates/index.html b/templates/index.html
index 15609d8..9d3ef58 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -7,10 +7,10 @@
 	<div class="col-xs-12">
 		<ul class="list-inline pull-right">
 			{% if ismod() %}
-      <li style="padding-right: 0px;">
-        <a class="btn btn-default" href="{{ url_for('new_announcement', ref=request.url) }}">Neue Ankündigung</a>
-      </li>
-      {% endif %}
+				<li style="padding-right: 0px;">
+					<a class="btn btn-default" href="{{ url_for('new_announcement', ref=request.url) }}">Neue Ankündigung</a>
+				</li>
+			{% endif %}
 		</ul>
 	</div>
 </div>
@@ -30,35 +30,48 @@
 				</p>
 			</div>
 		</div>
-		{% if featured|length > 0 %}
+		{% if (featured|length > 0) or ismod() %}
 			<div class="panel panel-default">
 				<div class="panel-heading">
-					<h1 class="panel-title">Featured</h1>
+					<h1 class="panel-title">Featured
+						{% if ismod() %}
+							<a class="btn btn-default" href="{{ url_for('new_featured', ref=request.url) }}">Neue Empfehlung</a>
+						{% endif %}
+					</h1>
 				</div>
 				<div class="panel-body">
-					<div id="myCarousel" class="carousel slide" data-ride="carousel" style="background-color: #EEE; min-height: 400px;">
-						<!-- Indicators -->
+					<div id="myCarousel" class="carousel slide" data-ride="carousel" style="background-color: #EEE; min-height: 400px;" {% if ismod() %}data-interval="false"{% endif %}>
 						<ol class="carousel-indicators">
 							{% for i in featured %}
-								<li data-target="#myCarousel" data-slide-to="0" {% if loop.first %} class="active" {% endif %}></li>
+							<li data-target="#myCarousel" data-slide-to="{{ loop.index0 }}" {% if loop.first %} class="active" {% endif %}></li>
 							{% endfor %}
 						</ol>
 							<div class="carousel-inner" role="listbox">
 						{% for i in featured %}
 								<div class="item {% if loop.first %}active{% endif %}">
-									{{ i.text|safe }}
-									<div class="carousel-caption"><h1>{{ i.title }}</h1></div>
+									{% if ismod() %}
+										<div class="center-block">
+											{{ valueeditor(('featured',i.id,'text'), i.text) }}
+											{{ valueeditor(('featured',i.id,'title'), i.title) }}
+											{{ valuecheckbox(('featured',i.id,'visible'),i.visible) }}
+										</div>
+									{% else %}
+										{{i.text|safe}}
+									{% endif %}
+									<div class="carousel-caption">{{ i.title }}</div>
 								</div>
 						{% endfor %}
 							</div>
-						<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
-							<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
-							<span class="sr-only">Previous</span>
-						</a>
-						<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
-							<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
-							<span class="sr-only">Next</span>
-						</a>
+							{% if not ismod() %}
+								<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
+									<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
+									<span class="sr-only">Previous</span>
+								</a>
+								<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
+									<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
+									<span class="sr-only">Next</span>
+								</a>
+							{% endif %}
 					</div>
 				</div>
 			</div>
-- 
GitLab