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

Generate protocol template correctly

parent 32f6cef7
No related branches found
No related tags found
No related merge requests found
......@@ -218,6 +218,12 @@ class Protocol(db.Model):
def get_originating_todos(self):
return [todo for todo in self.todos if self == todo.get_first_protocol()]
def get_open_todos(self):
return [
todo for todo in self.protocoltype.todos
if not todo.is_done()
]
def has_compiled_document(self):
candidates = [
document for document in self.documents
......@@ -472,6 +478,13 @@ class Todo(db.Model):
self.get_state_plain()
)
def render_template(self):
parts = ["todo", self.who, self.description, self.state.get_name()]
if self.state.needs_date():
parts.append(date_filter(self.state))
parts.append("id {}".format(self.get_id()))
return "[{}]".format(";".join(parts))
class TodoProtocolAssociation(db.Model):
__tablename__ = "todoprotocolassociations"
......
......@@ -8,9 +8,10 @@
{% macro render_top(top) %}
{TOP {{top.name}}
{% if top.name == "Todos" %}
{% if protocol.todos|length > 0 %}
{% for todo in protocol.todos %}
[todo;{{todo.who}};{{todo.description}};id {{todo.get_id()}}];
{% set todos=protocol.get_open_todos() %}
{% if todos|length > 0 %}
{% for todo in todos %}
{{todo.render_template()}};
{% endfor %}
{% else %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment