Skip to content
Snippets Groups Projects
Commit 1e40a5c2 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Implemented pausing

parent ce185f91
No related branches found
No related tags found
No related merge requests found
"""empty message
Revision ID: 256d9df3492
Revises: bdf979c44e
Create Date: 2015-11-08 11:30:13.923165
"""
# revision identifiers, used by Alembic.
revision = '256d9df3492'
down_revision = 'bdf979c44e'
from alembic import op
import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('events', sa.Column('current_topic_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'events', 'topics', ['current_topic_id'], ['id'])
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'events', type_='foreignkey')
op.drop_column('events', 'current_topic_id')
### end Alembic commands ###
...@@ -41,11 +41,15 @@ class Event(db.Model): ...@@ -41,11 +41,15 @@ class Event(db.Model):
name = db.Column(db.String, unique=True) name = db.Column(db.String, unique=True)
paused = db.Column(db.Boolean) paused = db.Column(db.Boolean)
paused_until = db.Column(db.DateTime) paused_until = db.Column(db.DateTime)
current_topic_id = db.Column(db.Integer, db.ForeignKey("topics.id"))
def __init__(self, name, paused=False): current_topic = relationship("Topic", foreign_keys=[current_topic_id])
def __init__(self, name, paused=False, current_topic_id=None):
self.name = name self.name = name
self.paused = paused self.paused = paused
self.paused_until = datetime(1970, 1, 1) self.paused_until = datetime(1970, 1, 1)
self.current_topic_id = current_topic_id or 0
def __repr__(self): def __repr__(self):
return "<Event(id={}, name={}, paused={}, paused_until={})>".format( return "<Event(id={}, name={}, paused={}, paused_until={})>".format(
...@@ -66,7 +70,7 @@ class Topic(db.Model): ...@@ -66,7 +70,7 @@ class Topic(db.Model):
event_id = db.Column(db.Integer, db.ForeignKey("events.id"), nullable=False) event_id = db.Column(db.Integer, db.ForeignKey("events.id"), nullable=False)
index = db.Column(db.Integer) index = db.Column(db.Integer)
event = relationship("Event", backref=backref("topics",order_by=id)) event = relationship("Event", backref=backref("topics",order_by=id), foreign_keys=[event_id])
def __init__(self, name, mode, event_id): def __init__(self, name, mode, event_id):
self.name = name self.name = name
......
...@@ -143,6 +143,8 @@ def topic_show(): ...@@ -143,6 +143,8 @@ def topic_show():
topic_id = request.args.get("id", None) topic_id = request.args.get("id", None)
if topic_id is not None: if topic_id is not None:
topic = Topic.query.filter_by(id=topic_id).first() topic = Topic.query.filter_by(id=topic_id).first()
topic.event.current_topic_id = topic.id
db.session.commit()
form = AddStatementForm() form = AddStatementForm()
form.topic.data = topic.id form.topic.data = topic.id
statements = topic.sorted_statements() statements = topic.sorted_statements()
...@@ -348,7 +350,7 @@ def pause(): ...@@ -348,7 +350,7 @@ def pause():
rawtime = float(request.form["timeslider"]) rawtime = float(request.form["timeslider"])
delta = timedelta(seconds=rawtime) delta = timedelta(seconds=rawtime)
print(delta) print(delta)
event.paused_until += delta event.paused_until = datetime.now() + delta
db.session.commit() db.session.commit()
topic_id = request.args.get("original", None) topic_id = request.args.get("original", None)
return redirect(url_for(".topic_show", id=topic_id)) return redirect(url_for(".topic_show", id=topic_id))
...@@ -41,7 +41,7 @@ def query_statements(mode, topic_id): ...@@ -41,7 +41,7 @@ def query_statements(mode, topic_id):
print("unknown querying mode {}".format(mode)) print("unknown querying mode {}".format(mode))
""" """
@speech.route("/index") @speech.route("/")
def index(): def index():
topic_id = request.args.get("topic", None) topic_id = request.args.get("topic", None)
mode = request.args.get("mode", None) mode = request.args.get("mode", None)
......
...@@ -131,3 +131,20 @@ th.rede-medium-text { ...@@ -131,3 +131,20 @@ th.rede-medium-text {
.rede-list-point-normal { .rede-list-point-normal {
font-weight: normal; font-weight: normal;
} }
.rede-paused-title {
margin: 0 auto;
}
h4.rede-paused-title-text {
font-size: 48px;
text-align: center;
}
div.rede-paused-supporting {
font-size: 24px;
}
.mdl-card {
min-height: 0px;
}
...@@ -118,4 +118,13 @@ ...@@ -118,4 +118,13 @@
{% endfor %} {% endfor %}
</table> </table>
</div> </div>
{% if topic.event.paused %}
<div class="mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-card mdl-shadow--2dp">
<div class="mdl-card__title rede-paused-title">
<h4 class="mdl-card__title-text rede-paused-title-text">
Paused until {{ topic.event.paused_until.strftime("%H:%M") }}
</h4>
</div>
</div>
{% endif %}
{% endblock %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment