diff --git a/app.py b/app.py index e342803..f6e1864 100644 --- a/app.py +++ b/app.py @@ -5,7 +5,7 @@ from flask_sqlalchemy import SQLAlchemy from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.orm import joinedload from sqlalchemy.sql import asc, func -from sqlalchemy import and_ +from sqlalchemy import and_, or_ from flask_security import Security, current_user, auth_required, roles_required, hash_password, SQLAlchemySessionUserDatastore from flask_security.utils import FsPermNeed from flask_babelex import Babel, gettext, lazy_gettext, format_datetime, to_user_timezone @@ -1477,6 +1477,7 @@ def widget(): date_to = date_set_end_of_day(today + relativedelta(days=7)) date_from_str = form_input_from_date(date_from) date_to_str = form_input_from_date(date_to) + keyword = '' if request.method == 'POST': date_from_str = request.form['date_from'] @@ -1484,10 +1485,21 @@ def widget(): date_from = form_input_to_date(date_from_str) date_to = form_input_to_date(date_to_str, 23, 59, 59) - dates = EventDate.query.filter(and_(EventDate.start >= date_from, EventDate.start < date_to)).order_by(EventDate.start).all() + if 'keyword' in request.form: + keyword = request.form['keyword'] + + date_filter = and_(EventDate.start >= date_from, EventDate.start < date_to) + + if keyword: + like_keyword = '%' + keyword + '%' + dates = EventDate.query.join(Event).filter(date_filter).filter(or_(Event.name.ilike(like_keyword), Event.description.ilike(like_keyword), Event.tags.ilike(like_keyword))).order_by(EventDate.start).all() + else: + dates = EventDate.query.join(Event).filter(date_filter).order_by(EventDate.start).all() + return render_template('widget/read.html', date_from_str=date_from_str, date_to_str=date_to_str, + keyword=keyword, dates=dates) if __name__ == '__main__': diff --git a/templates/widget/read.html b/templates/widget/read.html index 04f8a6b..71e63d0 100644 --- a/templates/widget/read.html +++ b/templates/widget/read.html @@ -23,6 +23,13 @@ +
+
+ {{ _('Keyword') }} +
+ +
+ diff --git a/translations/de/LC_MESSAGES/messages.mo b/translations/de/LC_MESSAGES/messages.mo index fab7c5f..bac774b 100644 Binary files a/translations/de/LC_MESSAGES/messages.mo and b/translations/de/LC_MESSAGES/messages.mo differ diff --git a/translations/de/LC_MESSAGES/messages.po b/translations/de/LC_MESSAGES/messages.po index 3a3a7d4..4c71821 100644 --- a/translations/de/LC_MESSAGES/messages.po +++ b/translations/de/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2020-07-19 15:53+0200\n" +"POT-Creation-Date: 2020-07-19 17:19+0200\n" "PO-Revision-Date: 2020-06-07 18:51+0200\n" "Last-Translator: FULL NAME \n" "Language: de\n" @@ -619,7 +619,11 @@ msgstr "Von" msgid "to" msgstr "bis" -#: templates/widget/read.html:26 +#: templates/widget/read.html:28 +msgid "Keyword" +msgstr "Stichwort" + +#: templates/widget/read.html:33 msgid "Find" msgstr "Finden"