Commit fcccf7cd authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Add description to TOP, so some content can be written beforehand.

/close #14
parent 2cdf562e
"""empty message
Revision ID: ab996d2365af
Revises: a1f23743bddb
Create Date: 2017-03-01 03:27:25.199271
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ab996d2365af'
down_revision = 'a1f23743bddb'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('tops', sa.Column('description', sa.String(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('tops', 'description')
# ### end Alembic commands ###
......@@ -302,12 +302,14 @@ class TOP(db.Model):
name = db.Column(db.String)
number = db.Column(db.Integer)
planned = db.Column(db.Boolean)
description = db.Column(db.String)
def __init__(self, protocol_id, name, number, planned):
def __init__(self, protocol_id, name, number, planned, description):
self.protocol_id = protocol_id
self.name = name
self.number = number
self.planned = planned
self.description = description
def __repr__(self):
return "<TOP(id={}, protocol_id={}, name={}, number={}, planned={})>".format(
......
......@@ -5,18 +5,21 @@
#Autor;
#Ort;
{% macro render_top(top) %}
{% macro render_top(top, use_description=False) %}
{TOP {{top.name}}
{% if top.name == "Todos" %}
{% set todos=protocol.get_open_todos() %}
{% if todos|length > 0 %}
{% for todo in todos %}
{{todo.render_template()}};
{{-todo.render_template()|indent(indentfirst=True)}};
{% endfor %}
{% else %}
{% endif %}
{% else %}
{% if use_description %}
{{-top.description|indent(indentfirst=True)}}
{% endif %}
{% endif %}
}
......@@ -30,7 +33,7 @@
{% endfor %}
{% endif %}
{% for top in protocol.tops %}
{{-render_top(top)}}
{{-render_top(top, use_description=True)}}
{% endfor %}
{% if not protocol.has_nonplanned_tops() %}
{% for default_top in protocol.protocoltype.default_tops %}
......
......@@ -127,6 +127,7 @@ class ProtocolForm(FlaskForm):
class TopForm(FlaskForm):
name = StringField("TOP", validators=[InputRequired("Du musst den Namen des TOPs angeben.")])
number = IntegerField("Sortierung", validators=[InputRequired("Du musst eine Sortierung in der Reihenfolge angebene.")])
description = TextAreaField("Beschreibung")
class SearchForm(FlaskForm):
search = StringField("Suchbegriff")
......
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