Commit 559389cc authored by Hinrikus Wolf's avatar Hinrikus Wolf

Merge branch 'master' of git.fsmpi.rwth-aachen.de:redl/redeleitsystem

parents c5901a6a 5b682ddb
......@@ -2,5 +2,4 @@ SQLALCHEMY_DATABASE_URI = "sqlite:///example.db" # SQLAlchemy connection data
SECRET_KEY = "abcdef" #
DEBUG = False # Debug Mode
UPDATE_INDEX_INTERVAL = 1 # Time in seconds between requests
UPDATE_SHOW_INTERVAL = 1 #
UPDATE_TIME_INTERVAL = 10 #
......@@ -23,11 +23,12 @@ class AdminUserForm(Form):
roles = SelectMultipleField("User roles", choices=[(x.lower().strip(), x) for x in shared.roles])
class AddStatementForm(Form):
speaker_name = StringField("Speaker", validators=[InputRequired("Entering the speaker is required.")])
speaker_name = StringField("Speaker", validators=[InputRequired("Entering the speaker name or number is required.")])
topic = HiddenField("Topic")
class EditSpeakerForm(Form):
name = StringField("Speaker", validators=[InputRequired("Entering the speaker is required.")])
number = IntegerField("Number", validators=[Optional(), NumberRange(min=0)])
topic_id = HiddenField("Topic_id")
id = HiddenField("Speaker_id")
......
......@@ -252,10 +252,11 @@ def speaker_edit():
speaker = Speaker.query.filter_by(id=speaker_id).first()
form = EditSpeakerForm(obj=speaker)
form.topic_id.data=topic_id
if speaker is not None:
if form.validate_on_submit():
speaker.name = form.name.data
speaker.number = form.number.data
db.session.commit()
return redirect(url_for(".topic_show",id=form.topic_id.data))
else:
......@@ -330,8 +331,8 @@ def statement_delete():
@admin_permission.require()
def statement_undo():
topic_id = request.args.get("topic_id", None)
if statement_id is not None:
statement = Statement.query.filter_by(executed=True).order_by(db.desc(Statement.execution_time)).first()
if topic_id is not None:
statement = Statement.query.filter_by(executed=True, topic_id=topic_id).order_by(db.desc(Statement.execution_time)).first()
statement.undo()
db.session.commit()
return redirect(url_for(".topic_show", id=topic_id))
......
......@@ -137,6 +137,16 @@ th.rede-medium-text {
background-color: #F44335;
}
.rede-table-bg-blue {
color: white;
background-color: #448AFF;
font-weight: bold;
}
.rede-table-centered > td {
text-align: center;
}
.rede-paused-title {
margin: 0 auto;
}
......
......@@ -21,11 +21,11 @@
</thead>
<tbody>
{% for statement in topic.sorted_statements() %}
{% if statement.is_meta %}
{% if statement.is_meta %}
<tr class="rede-table-bg-red">
{% else %}
<tr>
{% endif %}
{% else %}
<tr>
{% endif %}
<td class="mdl-data-table__cell--non-numeric">{{ statement.speaker.identifier() }}</td>
<td class="mdl-data-table__cell">{{ statement.speaker.count(statement.topic) }}</td>
<td class="mdl-data-table__cell--non-numeric">
......@@ -59,7 +59,7 @@
<a href="{{ url_for(".statement_done", id=topic.sorted_statements()[0].id, topic_id=topic.id) }}" class="rede-href"><i class="material-icons" role="presentation">redo</i> Next</a>
</li>
{% 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(".statement_undo", topic_id=topic.id) }}" 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>
......
......@@ -22,6 +22,22 @@
</div>
{%- endmacro %}
{% macro render_integerfield(field) -%}
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input id="{{ field.id }}" name="{{ field.id }}" class="mdl-textfield__input" type="text" {% if field.data is not none %}value="{{ field.data }}"{% endif %} />
<label class="mdl-textfield__label" for="{{ field.id }}">{{ field.label.text }}</label>
{% if field.errors %}
{% for e in field.errors %}
<div class="mdl-card__supporting-text">
{{ e }}
</div>
{% endfor %}
{% endif %}
</div>
{%- endmacro %}
{% macro render_passwordfield(field) -%}
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input id="{{ field.id }}" name="{{ field.id }}" class="mdl-textfield__input" type="password" />
......@@ -116,6 +132,8 @@
{{ render_stringfield(f) }}
{% elif f.type == "PasswordField" %}
{{ render_passwordfield(f) }}
{% elif f.type == "IntegerField" %}
{{ render_integerfield(f) }}
{% elif f.type == "BooleanField" %}
{{ render_booleanfield(f) }}
{% elif f.type == "CSRFTokenField" %}
......
{% for event in events %}
<div class="mdl-cell mdl-cell--6-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-card mdl-shadow--2dp">
{% if not event.paused %}
{% if event.current_topic_id != -1 and event.get_current_topic() %}
<div class="mdl-card__title">
{{ event.name }}: {{ event.get_current_topic().name }}
</div>
<table class="mdl-data-table mdl-js-table" style="min-width: 100%">
<thead>
<tr>
<th class="mdl-data-table__cell--non-numeric">Speaker</th>
<th class="mdl-data-table__cell">Count</th>
</tr>
</thead>
<tbody>
{% for statement in event.get_current_topic().sorted_statements() %}
<tr>
<td class="mdl-data-table__cell--non-numeric">{{ statement.speaker.identifier() }}</td>
<td class="mdl-data-table__cell">{{ statement.speaker.count(event.current_topic) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="mdl-card__title">
{{ event.name }}: No topic set
</div>
{% endif %}
{% else %}
{% if event.paused %}
<div class="mdl-card__title rede-paused-title">
<h4 class="mdl-card__title-text rede-paused-title-text">
{{ event.name}}: Paused until {{ event.paused_until.strftime("%H:%M") }}
Paused until {{ event.paused_until.strftime("%H:%M") }}
</h4>
</div>
{% endif %}
<div class="mdl-card__title">
{{ event.name }}: {{ event.get_current_topic().name }}
</div>
<table class="mdl-data-table mdl-js-table" style="min-width: 100%">
<thead>
<tr>
<th class="mdl-data-table__cell--non-numeric">Speaker</th>
<th class="mdl-data-table__cell">Count</th>
</tr>
</thead>
<tbody>
{% for topic in event.topics %}
{% if topic.id == event.current_topic_id %}
<tr class="rede-table-bg-blue rede-table-centered">
<td colspan="2">{{ topic.name }}</td>
</tr>
{% for statement in event.get_current_topic().sorted_statements() %}
{% if statement.is_meta %}
<tr class="rede-table-bg-red">
{% else %}
<tr>
{% endif %}
<td class="mdl-data-table__cell--non-numeric">{{ statement.speaker.identifier() }}</td>
<td class="mdl-data-table__cell">{{ statement.speaker.count(event.get_current_topic()) }}</td>
</tr>
{% endfor %}
{% else %}
<tr class="rede-table-centered">
<td colspan="2">{{ topic.name }}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment