Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roman Karwacik
website
Commits
efe29f1a
Commit
efe29f1a
authored
8 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
campus import can now delete lectures closes #275
parent
54ae3ace
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
importer.py
+16
-5
16 additions, 5 deletions
importer.py
templates/import_campus.html
+51
-12
51 additions, 12 deletions
templates/import_campus.html
with
67 additions
and
17 deletions
importer.py
+
16
−
5
View file @
efe29f1a
...
...
@@ -106,11 +106,12 @@ def import_from(id):
except
ImportError
:
flash
(
'
python-lxml not found, campus import will not work.
'
)
uniqueevents
=
[]
# events to add
newevents
=
[]
for
i
in
events
+
lectures
:
unique
=
False
exists
=
False
for
j
in
unique
events
:
for
j
in
new
events
:
unique
=
(
i
[
'
place
'
]
==
j
[
'
place
'
])
and
(
i
[
'
time
'
]
==
j
[
'
time
'
])
and
(
i
[
'
duration
'
]
==
j
[
'
duration
'
])
if
unique
:
break
...
...
@@ -119,7 +120,17 @@ def import_from(id):
if
exists
:
break
if
(
not
unique
)
and
(
not
exists
):
i
[
'
type
'
]
=
'
import
'
uniqueevents
.
append
(
i
)
newevents
.
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
)
This diff is collapsed.
Click to expand it.
templates/import_campus.html
+
51
−
12
View file @
efe29f1a
...
...
@@ -41,7 +41,10 @@
</span>
</li>
</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>
</div>
</div>
...
...
@@ -49,15 +52,57 @@
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
style=
"height:50px"
>
<h1
class=
"panel-title"
>
Fehlende Termine
:
Termine im Campus die nicht bei uns sind
:
<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>
</ul>
</h1>
</div>
<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"
>
<span
class=
"col-xs-3"
>
Time: {{i.time}}
...
...
@@ -69,26 +114,20 @@
Place: {{i.place}}
</span>
<span
class=
"col-xs-3"
>
{% if (i.type == 'lecture') %}
<p>
{{i.comment}}
</p>
<p>
{{i.internal}}
</p>
{% endif%}
</span>
<span
class=
"pull-right"
>
{% if (i.type == 'lecture') %}
{{ 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>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endblock %}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment