diff --git a/models/database.py b/models/database.py index 928b9cc2fdfbff4f5928ea5cae20fb90ef3f8d5d..9c19723d2c74122c26da09f2d8cf01d83ca3c5ce 100644 --- a/models/database.py +++ b/models/database.py @@ -259,7 +259,6 @@ class Todo(db.Model): description = db.Column(db.String) tags = db.Column(db.String) done = db.Column(db.Boolean) - is_id_fixed = db.Column(db.Boolean, default=False) protocols = relationship("Protocol", secondary="todoprotocolassociations", backref="todos") diff --git a/server.py b/server.py index 51f75ca04c21c30f0b1759a72cbef698a2fdb8da..0279cfc9038e8e33cea3d9a159d9bc56a9e72eac 100755 --- a/server.py +++ b/server.py @@ -538,35 +538,28 @@ def _get_page(): except ValueError: return 0 -@app.route("/todos/list", methods=["GET", "POST"]) +@app.route("/todos/list") def list_todos(): is_logged_in = check_login() user = current_user() protocoltype = None protocoltype_id = None try: - protocoltype_id = int(request.args.get("type_id")) + protocoltype_id = int(request.args.get("protocoltype")) except (ValueError, TypeError): pass search_term = request.args.get("search") protocoltypes = ProtocolType.get_available_protocoltypes(user) search_form = SearchForm(protocoltypes) - if search_form.validate_on_submit(): - if search_form.search.data is not None: - search_term = search_form.search.data.strip() - if search_form.protocoltype.data is not None: - protocoltype_id = search_form.protocoltype.data - else: - if protocoltype_id is not None: - search_form.protocoltype.data = protocoltype_id - if search_term is not None: - search_form.search.data = search_term if protocoltype_id is not None: + print(protocoltype_id) + search_form.protocoltype.data = protocoltype_id protocoltype = ProtocolType.query.filter_by(id=protocoltype_id).first() - base_query = Todo.query + if search_term is not None: + search_form.search.data = search_term + base_query = Todo.query.order_by(Todo.done).order_by(Todo.number.desc()) if protocoltype_id is not None and protocoltype_id != -1: base_query = base_query.filter(ProtocolType.id == protocoltype_id) - print(search_term) if search_term is not None and len(search_term.strip()) > 0: base_query = base_query.filter(Todo.description.match("%{}%".format(search_term))) page = _get_page() diff --git a/templates/macros.html b/templates/macros.html index 0a790ce530a20356a342f41195843264e05cae74..6898077ecace3a383fc642466842132b738256b1 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -87,10 +87,10 @@ to not render a label for the CRSFTokenField --> action_text - text of submit button class_ - sets a class for form #} -{% macro render_form(form, action_url='', action_text='Submit', class_='', btn_class='btn btn-default', enctype=None, labels_visible=True) -%} +{% macro render_form(form, action_url='', action_text='Submit', class_='', btn_class='btn btn-default', enctype=None, labels_visible=True, method="POST") -%} - <form method="POST" action="{{ action_url }}" role="form" class="{{ class_ }}"{% if enctype is not none %}enctype="{{enctype}}"{% endif %}> - {{ form.hidden_tag() if form.hidden_tag }} + <form method="{{method}}" action="{{ action_url }}" role="form" class="{{ class_ }}"{% if enctype is not none %}enctype="{{enctype}}"{% endif %}> + {#{{ form.hidden_tag() if form.hidden_tag }}#} {% if caller %} {{ caller() }} {% else %} @@ -104,7 +104,7 @@ to not render a label for the CRSFTokenField --> {% endif %} {% endfor %} {% endif %} - <button type="submit" class="{{ btn_class }}">{{ action_text }} </button> + <button type="submit" class="{{btn_class}}">{{action_text}}</button> </form> {%- endmacro %} diff --git a/templates/todos-list.html b/templates/todos-list.html index 841b96976706bab73b991301670492a568399722..c663b0c968bd3f9e32a3693e6165bc6d872e5462 100644 --- a/templates/todos-list.html +++ b/templates/todos-list.html @@ -3,12 +3,12 @@ {% block title %}Todos{% endblock %} {% macro page_link(page, text) %} - <a href="{{url_for(request.endpoint, page=page, type_id=protocoltype_id, search=search_term)}}">{{text}}</a> + <a href="{{url_for(request.endpoint, page=page, protocoltype=protocoltype_id, search=search_term)}}">{{text}}</a> {% endmacro %} {% block content %} <div class="container"> - {{render_form(search_form, class_="form-inline", labels_visible=False)}} + {{render_form(search_form, class_="form-inline", action_url=url_for("list_todos"), action_text="Suchen", labels_visible=False, method="GET")}} {{render_table(todos_table)}} <div class="centered"> {% if page > page_diff %}