Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
redl
redeleitsystem
Commits
7367f736
Commit
7367f736
authored
Nov 07, 2015
by
Hinrikus Wolf
Browse files
Merge branch 'master' of git.fsmpi.rwth-aachen.de:redl/redeleitsystem
parents
3581f84d
6f6953e7
Changes
5
Hide whitespace changes
Inline
Side-by-side
migrations/versions/1f952551533_.py
0 → 100644
View file @
7367f736
"""empty message
Revision ID: 1f952551533
Revises: 53525d1450a
Create Date: 2015-11-07 23:03:51.647356
"""
# revision identifiers, used by Alembic.
revision
=
'1f952551533'
down_revision
=
'53525d1450a'
from
alembic
import
op
import
sqlalchemy
as
sa
def
upgrade
():
### commands auto generated by Alembic - please adjust! ###
op
.
add_column
(
'events'
,
sa
.
Column
(
'paused_until'
,
sa
.
DateTime
(),
nullable
=
True
))
### end Alembic commands ###
def
downgrade
():
### commands auto generated by Alembic - please adjust! ###
op
.
drop_column
(
'events'
,
'paused_until'
)
### end Alembic commands ###
migrations/versions/53525d1450a_.py
0 → 100644
View file @
7367f736
"""empty message
Revision ID: 53525d1450a
Revises: 497c76393f9
Create Date: 2015-11-07 22:26:09.145955
"""
# revision identifiers, used by Alembic.
revision
=
'53525d1450a'
down_revision
=
'497c76393f9'
from
alembic
import
op
import
sqlalchemy
as
sa
def
upgrade
():
### commands auto generated by Alembic - please adjust! ###
op
.
add_column
(
'events'
,
sa
.
Column
(
'paused'
,
sa
.
Boolean
(),
nullable
=
True
))
### end Alembic commands ###
def
downgrade
():
### commands auto generated by Alembic - please adjust! ###
op
.
drop_column
(
'events'
,
'paused'
)
### end Alembic commands ###
models/database.py
View file @
7367f736
...
...
@@ -39,12 +39,21 @@ class Event(db.Model):
__tablename__
=
"events"
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
,
unique
=
True
)
paused
=
db
.
Column
(
db
.
Boolean
)
paused_until
=
db
.
Column
(
db
.
DateTime
)
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
,
paused
=
False
):
self
.
name
=
name
self
.
paused
=
paused
self
.
paused_until
=
datetime
(
1970
,
1
,
1
)
def
__repr__
(
self
):
return
"<Event(id={}, name={})>"
.
format
(
self
.
id
,
self
.
name
)
return
"<Event(id={}, name={}, paused={}, paused_until={})>"
.
format
(
self
.
id
,
self
.
name
,
self
.
paused
,
self
.
paused_until
)
def
sorted_topics
(
self
):
return
sorted
(
self
.
topics
,
key
=
lambda
tp
:
tp
.
get_index
())
...
...
@@ -97,6 +106,13 @@ class Topic(db.Model):
if
i
>=
len
(
topics
):
i
=
-
1
return
topics
[
i
].
id
def
get_previous_index
(
self
):
topics
=
self
.
event
.
sorted_topics
()
i
=
topics
.
index
(
self
)
-
1
if
i
>=
len
(
topics
):
i
=
0
return
topics
[
i
].
id
class
Speaker
(
db
.
Model
):
__tablename__
=
"speakers"
...
...
modules/admin.py
View file @
7367f736
...
...
@@ -2,6 +2,8 @@ from flask import Blueprint, redirect, url_for, request, flash, abort, send_file
from
flask.ext.login
import
login_required
from
passlib.hash
import
pbkdf2_sha256
from
datetime
import
datetime
,
timedelta
from
models.database
import
User
,
Topic
,
Event
,
Speaker
,
Statement
from
models.forms
import
AdminUserForm
,
NewUserForm
,
NewTopicForm
,
NewEventForm
,
AddStatementForm
,
EditSpeakerForm
...
...
@@ -331,3 +333,22 @@ def statement_undo():
db
.
session
.
commit
()
return
redirect
(
url_for
(
".topic_show"
,
id
=
topic_id
))
@
admin
.
route
(
"/pause"
,
methods
=
[
"GET"
,
"POST"
])
@
login_required
@
admin_permission
.
require
()
def
pause
():
event_id
=
request
.
args
.
get
(
"id"
,
None
)
if
event_id
is
not
None
:
event
=
Event
.
query
.
filter_by
(
id
=
event_id
).
first
()
if
event
is
not
None
:
if
event
.
paused_until
==
None
:
event
.
paused_until
=
datetime
(
1970
,
1
,
1
)
event
.
paused
=
not
event
.
paused
if
event
.
paused
:
rawtime
=
float
(
request
.
form
[
"timeslider"
])
delta
=
timedelta
(
seconds
=
rawtime
)
print
(
delta
)
event
.
paused_until
+=
delta
db
.
session
.
commit
()
topic_id
=
request
.
args
.
get
(
"original"
,
None
)
return
redirect
(
url_for
(
".topic_show"
,
id
=
topic_id
))
templates/admin_topic_show.html
View file @
7367f736
...
...
@@ -57,6 +57,40 @@
{% endif %}
<li><a
href=
"{{ url_for("
.
statement_undo
")
}}"
class=
"rede-href"
><i
class=
"material-icons"
role=
"presentation"
>
undo
</i>
Previous
</a></li>
<li><a
href=
"{{ url_for("
.
topic_show
",
id=
topic.get_next_index())
}}"
><i
class=
"material-icons"
>
arrow_forward
</i>
Next Topic
</a></li>
<li><a
href=
"{{ url_for("
.
topic_show
",
id=
topic.get_previous_index())
}}"
><i
class=
"material-icons"
>
arrow_backward
</i>
Previous Topic
</a></li>
<li>
<form
action=
"{{ url_for("
.
pause
",
id=
topic.event.id,
original=
topic.id)
}}"
method=
"POST"
>
<button
class=
"mdl-button"
>
{% if topic.event.paused %}
<i
class=
"material-icons"
>
play_arrow
</i>
Resume
{% else %}
<i
class=
"material-icons"
>
pause
</i>
Pause
{% endif %}
</button>
{% if not topic.event.paused %}
<input
name=
"timeslider"
class=
"mdl-slider mdl-js-slider"
type=
"range"
min=
"0"
max=
"3600"
value=
"300"
step=
"30"
onchange=
"settimesliderresult(this);"
>
<script>
function
settimesliderresult
(
slider
)
{
var
div
=
document
.
getElementById
(
"
timesliderresult
"
);
var
time
=
slider
.
value
;
var
text
=
""
;
if
(
Math
.
floor
(
time
/
3600
)
>
0
)
{
text
+=
Math
.
floor
(
time
/
3600
)
+
"
h
"
;
time
%=
3600
;
}
if
(
Math
.
floor
(
time
/
60
)
>
0
)
{
text
+=
Math
.
floor
(
time
/
60
)
+
"
m
"
;
time
%=
60
;
}
text
+=
time
+
"
s
"
;
div
.
innerHTML
=
text
;
}
</script>
<div
id=
"timesliderresult"
></div>
{% endif %}
</li>
</ul>
</div>
</div>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment