diff --git a/migrations/versions/ab996d2365af_.py b/migrations/versions/ab996d2365af_.py new file mode 100644 index 0000000000000000000000000000000000000000..1c69086bae3fa68399a4d1c2a3b0b81f985df933 --- /dev/null +++ b/migrations/versions/ab996d2365af_.py @@ -0,0 +1,28 @@ +"""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 ### diff --git a/models/database.py b/models/database.py index 1fe696c3a31eee8ef68c0ea4c44753433108085c..1bff6cd09e3fc1d7860773d36709091a27f7cfc7 100644 --- a/models/database.py +++ b/models/database.py @@ -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( diff --git a/templates/protocol-template.txt b/templates/protocol-template.txt index 13b2faf4905d53febf88f805c1b96bb847121a30..04e09c7dfb39dc4e7f9c1431b296a0b02fd2d4c9 100644 --- a/templates/protocol-template.txt +++ b/templates/protocol-template.txt @@ -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 %} diff --git a/views/forms.py b/views/forms.py index 2a9dcf02cbddc05f867211e5872ead0ad6c4d9ad..b6b7f57882adbb959b5729b01bf2df7683880d56 100644 --- a/views/forms.py +++ b/views/forms.py @@ -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")