Commit b2c65361 authored by Robin Sonnabend's avatar Robin Sonnabend

Filter protocols by state

parent 2f5c086f
...@@ -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, 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, 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
...@@ -351,12 +351,19 @@ def list_protocols(): ...@@ -351,12 +351,19 @@ def list_protocols():
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 = ProtocolSearchForm(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
protocol_query = Protocol.query protocol_query = Protocol.query
...@@ -391,6 +398,12 @@ def list_protocols(): ...@@ -391,6 +398,12 @@ def list_protocols():
protocol for protocol in protocols protocol for protocol in protocols
if protocol.protocoltype.id == protocoltype_id if protocol.protocoltype.id == protocoltype_id
] ]
if open is not None and open != -1:
protocol_done = bool(open)
protocols = [
protocol for protocol in protocols
if protocol.is_done() == protocol_done
]
if shall_search: if shall_search:
protocols = [ protocols = [
protocol for protocol in protocols protocol for protocol in protocols
......
...@@ -205,6 +205,9 @@ class DecisionSearchForm(SearchForm): ...@@ -205,6 +205,9 @@ class DecisionSearchForm(SearchForm):
super().__init__(protocoltypes=protocoltypes, **kwargs) super().__init__(protocoltypes=protocoltypes, **kwargs)
self.decisioncategory_id.choices = get_category_choices(categories) self.decisioncategory_id.choices = get_category_choices(categories)
class ProtocolSearchForm(SearchForm):
open = SelectField("Offen", choices=[(-1, "Alle"), (0, "Geplant"), (1, "Fertig")], 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