diff --git a/models/database.py b/models/database.py index 26b8a45a6b37992021cdda5a7b756f2bbfe39959..d557b2327f3fd55e8a8ff274910c7e526cb02cae 100644 --- a/models/database.py +++ b/models/database.py @@ -143,11 +143,14 @@ class Speaker(db.Model): return "{} ({})".format(self.name, self.number) def count(self, topic): - return len([statement for statement in self.statements if statement.topic == topic]) + return len([statement for statement in self.statements if statement.topic == topic and not statement.is_meta]) def count_active(self, topic): - return len([statement for statement in self.statements if statement.topic == topic and not statement.executed]) - + return len([statement for statement in self.statements if statement.topic == topic and not statement.executed and not statement.is_meta]) + + def count_active_meta(self, topic): + return len([statement for statement in self.statements if statement.topic == topic and not statement.executed and statement.is_meta]) + class Statement(db.Model): __tablename__ = "statements" diff --git a/modules/admin.py b/modules/admin.py index 68daa4d90d74627748aa8adb4565a9e05fa5c297..a94f27864726acef30de1668893e664a4dcb60bc 100644 --- a/modules/admin.py +++ b/modules/admin.py @@ -277,19 +277,14 @@ def statement_new(): form = AddStatementForm() if form.validate_on_submit(): statement = request.form.get("submit","add_statement") - if statement == "add_meta_statement": - topic = Topic.query.filter_by(id=form.topic.data).first() - + topic = Topic.query.filter_by(id=form.topic.data).first() + speaker = speaker_by_name_or_number(form.speaker_name.data, topic.event.id) + if topic is not None and speaker is not None: + if speaker.count_active(topic) == 0 or (statement == "add_meta_statement" and speaker.count_active_meta(topic) == 0) : + statement = Statement(speaker.id, topic.id, is_meta=(statement == "add_meta_statement")) + db.session.add(statement) + db.session.commit() return redirect(url_for(".topic_show", id=topic.id)) - else: - topic = Topic.query.filter_by(id=form.topic.data).first() - speaker = speaker_by_name_or_number(form.speaker_name.data, topic.event.id) - if topic is not None and speaker is not None: - if speaker.count_active(topic) == 0: - statement = Statement(speaker.id, topic.id) - db.session.add(statement) - db.session.commit() - return redirect(url_for(".topic_show", id=topic.id)) return render_layout("admin_statement_new.html", form=form) @admin.route("/statement/done") diff --git a/static/css/style.css b/static/css/style.css index e83d82b42755302705c069e2f18a275c962506fc..ceaf6bf8302df6c9674401a07ea011bc68a231cc 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -131,3 +131,10 @@ th.rede-medium-text { .rede-list-point-normal { font-weight: normal; } + +.rede-table-bg-red { + color: white; + background-color: #F44335; +} + +