diff --git a/config.py.example b/config.py.example index a32c533ee2dd80e6bb032434785f6655c77af265..ba879590ce763b6af8d02d6d8b4ae595bb23eb4f 100644 --- a/config.py.example +++ b/config.py.example @@ -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 # diff --git a/models/forms.py b/models/forms.py index 8dcf735db318e6d67f790ad3c372e391e01518f5..20489601e348e28585a7879f09cef1c0309469f0 100644 --- a/models/forms.py +++ b/models/forms.py @@ -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") diff --git a/modules/admin.py b/modules/admin.py index 662a8e96f0693375bbf9300dbf6791a936a90645..f92fd204f920c92a148c17aa3816ac3a80f76f35 100644 --- a/modules/admin.py +++ b/modules/admin.py @@ -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)) diff --git a/static/css/style.css b/static/css/style.css index 9f3ca6afeeb49e6a3cddec1696903e84661e55bf..ea782e1da14340f3867f13810f7b79038de19e04 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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; } diff --git a/templates/admin_topic_show.html b/templates/admin_topic_show.html index bdbd5404b106b7d4f37d524660ac5aba53295d66..0bf7acc054e2acec2eb8c1511391a2dad6bd55b9 100644 --- a/templates/admin_topic_show.html +++ b/templates/admin_topic_show.html @@ -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> diff --git a/templates/macros.html b/templates/macros.html index 4a2ac7e958bb48fbd0f285819a9c1789189c994f..907b1e4e6a405b4bf497be7c9d3575e0bb7c0145 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -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" %} diff --git a/templates/speech_content_index.html b/templates/speech_content_index.html index a0a8ac4ecf8cacd6bc8b45d476dad4f8291b7b2e..72d8e25d3c32e9bc5711946a2d997bfcfc2bff0d 100644 --- a/templates/speech_content_index.html +++ b/templates/speech_content_index.html @@ -1,37 +1,45 @@ {% 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 %}