mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 00:07:22 +00:00
keyword search
This commit is contained in:
parent
57d4c6f03b
commit
297a77753b
16
app.py
16
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__':
|
||||
|
||||
@ -23,6 +23,13 @@
|
||||
<input type="text" id="date_to" name="date_to" value="{{ date_to_str }}" class="form-control datepicker" />
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-2 mr-sm-2">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">{{ _('Keyword') }}</span>
|
||||
</div>
|
||||
<input type="text" name="keyword" value="{{ keyword }}" class="form-control" />
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary mb-2">{{ _('Find') }}</button>
|
||||
</form>
|
||||
|
||||
|
||||
Binary file not shown.
@ -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 <EMAIL@ADDRESS>\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"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user