Skip to content
Snippets Groups Projects
Commit efe29f1a authored by Andreas Valder's avatar Andreas Valder
Browse files

campus import can now delete lectures closes #275

parent 54ae3ace
No related branches found
No related tags found
No related merge requests found
...@@ -106,11 +106,12 @@ def import_from(id): ...@@ -106,11 +106,12 @@ def import_from(id):
except ImportError: except ImportError:
flash('python-lxml not found, campus import will not work.') flash('python-lxml not found, campus import will not work.')
uniqueevents = [] # events to add
newevents = []
for i in events + lectures: for i in events + lectures:
unique = False unique = False
exists = False exists = False
for j in uniqueevents: for j in newevents:
unique = (i['place'] == j['place']) and (i['time'] == j['time']) and (i['duration'] == j['duration']) unique = (i['place'] == j['place']) and (i['time'] == j['time']) and (i['duration'] == j['duration'])
if unique: if unique:
break break
...@@ -119,7 +120,17 @@ def import_from(id): ...@@ -119,7 +120,17 @@ def import_from(id):
if exists: if exists:
break break
if (not unique) and (not exists): if (not unique) and (not exists):
i['type'] = 'import' newevents.append(i)
uniqueevents.append(i)
return render_template('import_campus.html', course=courses, import_campus=import_campus, events=uniqueevents) # deleted events
deletedlectures = []
for i in lectures:
incampus = False
for j in events:
incampus = (i['place'] == j['place']) and (i['time'] == j['time']) and (i['duration'] == j['duration'])
if incampus:
break
if not incampus:
deletedlectures.append(i)
return render_template('import_campus.html', course=courses, import_campus=import_campus, newevents=newevents, deletedlectures=deletedlectures)
...@@ -41,7 +41,10 @@ ...@@ -41,7 +41,10 @@
</span> </span>
</li> </li>
</ul> </ul>
<button class="btn btn-default pull-right" type="submit">Speichern</button> <ul class="list-inline pull-right">
<li><a class="btn btn-default" href="{{url_for('import_from', id=course['id'])}}"><span class="fa fa-refresh" aria-hidden="true" ></span> Campus abfragen</button></a></li>
<li><button class="btn btn-default" type="submit">Speichern</button></li>
</ul>
</form> </form>
</div> </div>
</div> </div>
...@@ -49,15 +52,57 @@ ...@@ -49,15 +52,57 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading" style="height:50px"> <div class="panel-heading" style="height:50px">
<h1 class="panel-title"> <h1 class="panel-title">
Fehlende Termine: Termine im Campus die nicht bei uns sind:
<ul class="list-inline pull-right"> <ul class="list-inline pull-right">
<li><a class="btn btn-default" href="{{url_for('import_from', id=course['id'])}}"><span class="fa fa-refresh" aria-hidden="true" ></span> Aktualisieren</button></a>
<li><button class="btn btn-default" onclick="$('.newlecture').click(); alert('done');">alle anlegen</button></li> <li><button class="btn btn-default" onclick="$('.newlecture').click(); alert('done');">alle anlegen</button></li>
</ul> </ul>
</h1> </h1>
</div> </div>
<ul class="list-group-item"> <ul class="list-group-item">
{% for i in events|sort(attribute='time') %} {% for i in newevents|sort(attribute='time') %}
<li class="list-group-item row">
<span class="col-xs-3">
Time: {{i.time}}
</span>
<span class="col-xs-2">
Duration: {{i.duration}}
</span>
<span class="col-xs-3">
Place: {{i.place}}
</span>
<span class="col-xs-3">
</span>
<span class="pull-right">
<button class="btn btn-default newlecture" onclick="moderator.api.gethttp('{{ url_for('create', table='lectures', course_id=course.id, time=i.time, title=i.title, place=i.place) }}')">anlegen</a>
</span>
</li>
{% endfor %}
</ul>
</div>
<div class="panel panel-default">
<div class="panel-heading" style="height:50px">
<h1 class="panel-title">
Termine bei uns die nicht im Campus sind:
<ul class="list-inline pull-right">
<li><button class="btn btn-default" onclick="deleteall(); alert('done');">alle entfernen</button></li>
<script>
function deleteall() {
var req = {};
{% for i in deletedlectures|sort(attribute='time') %}
req['lectures.{{ i.id }}.deleted'] = 1;
{% endfor %}
if (confirm('Really delete all lectures that are not in campus?')) {
moderator.api.set_multi(req,false);
}
}
</script>
</ul>
</h1>
</div>
<ul class="list-group-item">
{% for i in deletedlectures|sort(attribute='time') %}
<li class="list-group-item row"> <li class="list-group-item row">
<span class="col-xs-3"> <span class="col-xs-3">
Time: {{i.time}} Time: {{i.time}}
...@@ -69,26 +114,20 @@ ...@@ -69,26 +114,20 @@
Place: {{i.place}} Place: {{i.place}}
</span> </span>
<span class="col-xs-3"> <span class="col-xs-3">
{% if (i.type == 'lecture') %}
<p> <p>
{{i.comment}} {{i.comment}}
</p> </p>
<p> <p>
{{i.internal}} {{i.internal}}
</p> </p>
{% endif%}
</span> </span>
<span class="pull-right"> <span class="pull-right">
{% if (i.type == 'lecture') %}
{{ moderator_delete(['lectures',i.id,'deleted']) }} {{ moderator_delete(['lectures',i.id,'deleted']) }}
{% endif%}
{% if (i.type == 'import') %}
<button class="btn btn-default newlecture" onclick="moderator.api.gethttp('{{ url_for('create', table='lectures', course_id=course.id, time=i.time, title=i.title, place=i.place) }}')">anlegen</a>
{% endif%}
</span> </span>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment