Commit 8b11e3a5 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Filter todos by state

parent b2c65361
...@@ -24,7 +24,7 @@ from shared import db, date_filter, datetime_filter, date_filter_long, date_filt ...@@ -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 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 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 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 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 from legacy import import_old_todos, import_old_protocols, import_old_todomails
...@@ -447,7 +447,7 @@ def list_protocols(): ...@@ -447,7 +447,7 @@ def list_protocols():
end_index = (page + 1) * config.PAGE_LENGTH end_index = (page + 1) * config.PAGE_LENGTH
protocols = protocols[begin_index:end_index] protocols = protocols[begin_index:end_index]
protocols_table = ProtocolsTable(protocols, search_results=search_results) 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"]) @app.route("/protocol/new", methods=["GET", "POST"])
@login_required @login_required
...@@ -779,12 +779,19 @@ def list_todos(): ...@@ -779,12 +779,19 @@ def list_todos():
protocoltype_id = int(request.args.get("protocoltype_id")) protocoltype_id = int(request.args.get("protocoltype_id"))
except (ValueError, TypeError): except (ValueError, TypeError):
pass pass
open = -1
try:
open = int(request.args.get("open"))
except (ValueError, TypeError):
pass
search_term = request.args.get("search") search_term = request.args.get("search")
protocoltypes = ProtocolType.get_public_protocoltypes(user) protocoltypes = ProtocolType.get_public_protocoltypes(user)
search_form = SearchForm(protocoltypes) search_form = TodoSearchForm(protocoltypes)
if protocoltype_id is not None: if protocoltype_id is not None:
search_form.protocoltype_id.data = protocoltype_id search_form.protocoltype_id.data = protocoltype_id
protocoltype = ProtocolType.query.filter_by(id=protocoltype_id).first() 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: if search_term is not None:
search_form.search.data = search_term search_form.search.data = search_term
todos = [ todos = [
...@@ -796,6 +803,12 @@ def list_todos(): ...@@ -796,6 +803,12 @@ def list_todos():
todo for todo in todos todo for todo in todos
if todo.protocoltype.id == protocoltype_id 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: if search_term is not None and len(search_term.strip()) > 0:
todos = [ todos = [
todo for todo in todos todo for todo in todos
...@@ -813,7 +826,7 @@ def list_todos(): ...@@ -813,7 +826,7 @@ def list_todos():
end_index = (page + 1) * config.PAGE_LENGTH end_index = (page + 1) * config.PAGE_LENGTH
todos = todos[begin_index:end_index] todos = todos[begin_index:end_index]
todos_table = TodosTable(todos) 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"]) @app.route("/todo/new", methods=["GET", "POST"])
@login_required @login_required
...@@ -970,7 +983,7 @@ def list_decisions(): ...@@ -970,7 +983,7 @@ def list_decisions():
end_index = (page + 1) * config.PAGE_LENGTH end_index = (page + 1) * config.PAGE_LENGTH
decisions = decisions[begin_index:end_index] decisions = decisions[begin_index:end_index]
decisions_table = DecisionsTable(decisions) 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>") @app.route("/document/download/<int:document_id>")
@db_lookup(Document) @db_lookup(Document)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
{% block title %}Beschlüsse{% endblock %} {% block title %}Beschlüsse{% endblock %}
{% macro page_link(page, text) %} {% 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 %} {% endmacro %}
{% block content %} {% block content %}
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
{% block title %}Protokolle{% endblock %} {% block title %}Protokolle{% endblock %}
{% macro page_link(page, text) %} {% 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 %} {% endmacro %}
{% block content %} {% block content %}
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
{% block title %}Todos{% endblock %} {% block title %}Todos{% endblock %}
{% macro page_link(page, text) %} {% 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 %} {% endmacro %}
{% block content %} {% block content %}
......
...@@ -208,6 +208,9 @@ class DecisionSearchForm(SearchForm): ...@@ -208,6 +208,9 @@ class DecisionSearchForm(SearchForm):
class ProtocolSearchForm(SearchForm): class ProtocolSearchForm(SearchForm):
open = SelectField("Offen", choices=[(-1, "Alle"), (0, "Geplant"), (1, "Fertig")], coerce=int) 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): class NewTodoForm(FlaskForm):
protocoltype_id = SelectField("Typ", choices=[], coerce=int) protocoltype_id = SelectField("Typ", choices=[], coerce=int)
who = StringField("Person", validators=[InputRequired("Bitte gib an, wer das Todo erledigen soll.")]) who = StringField("Person", validators=[InputRequired("Bitte gib an, wer das Todo erledigen soll.")])
......
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