diff --git a/server.py b/server.py index 640a19dec06a8efdbaf582072f5f1088d907285b..6a16991456d7bb9fd31e4fc1bbf470968bba3a3d 100755 --- a/server.py +++ b/server.py @@ -24,7 +24,7 @@ from shared import db, date_filter, datetime_filter, date_filter_long, date_filt from utils import is_past, mail_manager, url_manager, get_first_unused_int, set_etherpad_text, get_etherpad_text, split_terms, optional_int_arg from decorators import db_lookup, require_public_view_right, require_private_view_right, require_modify_right, require_admin_right from models.database import ProtocolType, Protocol, DefaultTOP, TOP, Document, Todo, Decision, MeetingReminder, Error, TodoMail, DecisionDocument, TodoState, Meta, DefaultMeta, DecisionCategory -from views.forms import LoginForm, ProtocolTypeForm, DefaultTopForm, MeetingReminderForm, NewProtocolForm, DocumentUploadForm, KnownProtocolSourceUploadForm, NewProtocolSourceUploadForm, ProtocolForm, TopForm, SearchForm, DecisionSearchForm, ProtocolSearchForm, NewProtocolFileUploadForm, NewTodoForm, TodoForm, TodoMailForm, DefaultMetaForm, MetaForm, MergeTodosForm, DecisionCategoryForm +from views.forms import LoginForm, ProtocolTypeForm, DefaultTopForm, MeetingReminderForm, NewProtocolForm, DocumentUploadForm, KnownProtocolSourceUploadForm, NewProtocolSourceUploadForm, ProtocolForm, TopForm, SearchForm, DecisionSearchForm, ProtocolSearchForm, TodoSearchForm, NewProtocolFileUploadForm, NewTodoForm, TodoForm, TodoMailForm, DefaultMetaForm, MetaForm, MergeTodosForm, DecisionCategoryForm from views.tables import ProtocolsTable, ProtocolTypesTable, ProtocolTypeTable, DefaultTOPsTable, MeetingRemindersTable, ErrorsTable, TodosTable, DocumentsTable, DecisionsTable, TodoTable, ErrorTable, TodoMailsTable, DefaultMetasTable, DecisionCategoriesTable from legacy import import_old_todos, import_old_protocols, import_old_todomails @@ -447,7 +447,7 @@ def list_protocols(): end_index = (page + 1) * config.PAGE_LENGTH protocols = protocols[begin_index:end_index] protocols_table = ProtocolsTable(protocols, search_results=search_results) - return render_template("protocols-list.html", protocols=protocols, protocols_table=protocols_table, search_form=search_form, page=page, page_count=page_count, page_diff=config.PAGE_DIFF, protocoltype_id=protocoltype_id, search_term=search_term) + return render_template("protocols-list.html", protocols=protocols, protocols_table=protocols_table, search_form=search_form, page=page, page_count=page_count, page_diff=config.PAGE_DIFF, protocoltype_id=protocoltype_id, search_term=search_term, open=open) @app.route("/protocol/new", methods=["GET", "POST"]) @login_required @@ -779,12 +779,19 @@ def list_todos(): protocoltype_id = int(request.args.get("protocoltype_id")) except (ValueError, TypeError): pass + open = -1 + try: + open = int(request.args.get("open")) + except (ValueError, TypeError): + pass search_term = request.args.get("search") protocoltypes = ProtocolType.get_public_protocoltypes(user) - search_form = SearchForm(protocoltypes) + search_form = TodoSearchForm(protocoltypes) if protocoltype_id is not None: search_form.protocoltype_id.data = protocoltype_id protocoltype = ProtocolType.query.filter_by(id=protocoltype_id).first() + if open is not None: + search_form.open.data = open if search_term is not None: search_form.search.data = search_term todos = [ @@ -796,6 +803,12 @@ def list_todos(): todo for todo in todos if todo.protocoltype.id == protocoltype_id ] + if open is not None and open != -1: + todo_done = bool(open) + todos = [ + todo for todo in todos + if todo.is_done() == todo_done + ] if search_term is not None and len(search_term.strip()) > 0: todos = [ todo for todo in todos @@ -813,7 +826,7 @@ def list_todos(): end_index = (page + 1) * config.PAGE_LENGTH todos = todos[begin_index:end_index] todos_table = TodosTable(todos) - return render_template("todos-list.html", todos=todos, todos_table=todos_table, search_form=search_form, page=page, page_count=page_count, page_diff=config.PAGE_DIFF, protocoltype_id=protocoltype_id, search_term=search_term) + return render_template("todos-list.html", todos=todos, todos_table=todos_table, search_form=search_form, page=page, page_count=page_count, page_diff=config.PAGE_DIFF, protocoltype_id=protocoltype_id, search_term=search_term, open=open) @app.route("/todo/new", methods=["GET", "POST"]) @login_required @@ -970,7 +983,7 @@ def list_decisions(): end_index = (page + 1) * config.PAGE_LENGTH decisions = decisions[begin_index:end_index] decisions_table = DecisionsTable(decisions) - return render_template("decisions-list.html", decisions=decisions, decisions_table=decisions_table, search_form=search_form, page=page, page_count=page_count, page_diff=config.PAGE_DIFF, protocoltype_id=protocoltype_id, search_term=search_term) + return render_template("decisions-list.html", decisions=decisions, decisions_table=decisions_table, search_form=search_form, page=page, page_count=page_count, page_diff=config.PAGE_DIFF, protocoltype_id=protocoltype_id, search_term=search_term, decisioncategory_id=decisioncategory_id) @app.route("/document/download/<int:document_id>") @db_lookup(Document) diff --git a/templates/decisions-list.html b/templates/decisions-list.html index c62a0834ae4d9025a28f0952a8f5b8784fda297c..42e6712745f9fa7551cf0996b207344923ca39e5 100644 --- a/templates/decisions-list.html +++ b/templates/decisions-list.html @@ -3,7 +3,7 @@ {% block title %}Beschlüsse{% endblock %} {% macro page_link(page, text) %} - <a href="{{url_for(request.endpoint, page=page, protocoltype=protocoltype_id, search=search_term)}}">{{text}}</a> + <a href="{{url_for(request.endpoint, page=page, protocoltype=protocoltype_id, search=search_term, decisioncategory_id=decisioncategory_id)}}">{{text}}</a> {% endmacro %} {% block content %} diff --git a/templates/protocols-list.html b/templates/protocols-list.html index 3f8e842240d3a04cc69e005f4d7029899a5c8a4f..99f7d378d00e99da8ecc02c95ee4d86b01e4161c 100644 --- a/templates/protocols-list.html +++ b/templates/protocols-list.html @@ -3,7 +3,7 @@ {% block title %}Protokolle{% endblock %} {% macro page_link(page, text) %} - <a href="{{url_for(request.endpoint, page=page, protocoltype=protocoltype_id, search=search_term)}}">{{text}}</a> + <a href="{{url_for(request.endpoint, page=page, protocoltype=protocoltype_id, search=search_term, open=open)}}">{{text}}</a> {% endmacro %} {% block content %} diff --git a/templates/todos-list.html b/templates/todos-list.html index fefb0c6240c9bbb0a34074152f069f918acecf58..a1816bbe690cd7f170c09334c938495f887a3add 100644 --- a/templates/todos-list.html +++ b/templates/todos-list.html @@ -3,7 +3,7 @@ {% block title %}Todos{% endblock %} {% macro page_link(page, text) %} - <a href="{{url_for(request.endpoint, page=page, protocoltype=protocoltype_id, search=search_term)}}">{{text}}</a> + <a href="{{url_for(request.endpoint, page=page, protocoltype=protocoltype_id, search=search_term, open=open)}}">{{text}}</a> {% endmacro %} {% block content %} diff --git a/views/forms.py b/views/forms.py index cd5b55f1e589d821f7c7ac0b6d9443260cc1963f..f499d52ff8f8ac481335fa3a95bfe5fef2528066 100644 --- a/views/forms.py +++ b/views/forms.py @@ -208,6 +208,9 @@ class DecisionSearchForm(SearchForm): class ProtocolSearchForm(SearchForm): open = SelectField("Offen", choices=[(-1, "Alle"), (0, "Geplant"), (1, "Fertig")], coerce=int) +class TodoSearchForm(SearchForm): + open = SelectField("Offen", choices=[(-1, "Alle"), (0, "Offen"), (1, "Erledigt")], coerce=int) + class NewTodoForm(FlaskForm): protocoltype_id = SelectField("Typ", choices=[], coerce=int) who = StringField("Person", validators=[InputRequired("Bitte gib an, wer das Todo erledigen soll.")])