Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ogc 508 replace elastic search by postgres text search #918

Open
wants to merge 207 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 185 commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
759e4e3
Adding psql index columns and re-index functionality for users and at…
Tschuppi81 Apr 17, 2023
0c4159a
Disable ES, make user search working using postgresql
Tschuppi81 May 23, 2023
5e89675
Adding fts index functions to create, drop index as well as db upgrad…
Tschuppi81 May 23, 2023
4ad864e
Adding fts index functions to create, drop index as well as db upgrad…
Tschuppi81 May 23, 2023
8fcf1e9
Switch from ES app to psql app
Tschuppi81 May 23, 2023
b208736
Switch from ES app to psql app
Tschuppi81 May 23, 2023
41f3111
Initial move from es to psql search for town6
Tschuppi81 May 23, 2023
942141c
Core: Fix a lot bugbear warnings.
msom Apr 7, 2023
db272dc
Org: Prioritize Events in search, and sort chronologically.
cyrillkuettel Apr 11, 2023
128e988
Core: Enable flake8 bugbear.
msom Apr 13, 2023
fcd44b3
agency: Adding many more fields for agencies and people
Tschuppi81 Apr 14, 2023
80c09c6
Release release-2023.15
cyrillkuettel Apr 14, 2023
85b7f7e
Town6: Small Fixes
BreathingFlesh Apr 17, 2023
de479b1
Feriennet: New banners and logo
BreathingFlesh Apr 17, 2023
0d5fdcd
Town6: Make color inversion on icon links possible
BreathingFlesh Apr 17, 2023
60b8a6a
Feriennet: E-mail notifications on registration for activity
BreathingFlesh Apr 18, 2023
a729ec6
Org: Add more options to "further information" on directories
BreathingFlesh Apr 18, 2023
a77bf28
Town6: External event url
BreathingFlesh Apr 18, 2023
1ef6587
Feriennet: Invoice Items payment with dates
BreathingFlesh Apr 18, 2023
6d32013
Release release-2023.16
cyrillkuettel Apr 19, 2023
a710d57
Town6: Fixes news not being displayed if it's the first item.
cyrillkuettel Apr 22, 2023
81b1563
Town6: Remove "Onegov Cloud Team" in mail-footer
BreathingFlesh Apr 24, 2023
8ae0716
Feriennet: Edit email text
BreathingFlesh Apr 24, 2023
a582271
Release release-2023.17
BreathingFlesh Apr 24, 2023
0995031
Town6: Make image preview visible
BreathingFlesh Apr 25, 2023
29e4b5e
Feriennet: Make form more robust if field is missing
cyrillkuettel Apr 25, 2023
48e39a5
Release release-2023.18
BreathingFlesh Apr 25, 2023
cefd094
Ballot: Fixes file constraints.
msom Apr 30, 2023
fb6f106
Release release-2023.19
msom Apr 30, 2023
44513c9
Org: Small Adjustments
BreathingFlesh May 1, 2023
d82dd5c
Town6: Add option for a testimonial slider
BreathingFlesh May 2, 2023
53a6af9
Core: Indicate hash useage.
msom May 2, 2023
0a10833
Form: Add security hint for yaml loading.
msom May 2, 2023
7842724
Core: Validate URL used in PostThread.
msom May 2, 2023
5df2a27
Core: Add requests timeouts.
msom May 2, 2023
cf76426
Feriennet: Edit email text
BreathingFlesh May 2, 2023
310b7f8
Org: Minor code improvement
Tschuppi81 May 4, 2023
e1bae14
Core: Pin reportlab.
msom May 5, 2023
0d5e4b6
Org: Indent check only activated for new and edit forms but not for d…
Tschuppi81 May 5, 2023
9f92a4d
Town6: Fixes E-mail template
treinhard May 5, 2023
87a09c5
Swissvotes: Fixes button text for adding pages.
msom May 7, 2023
01bc9d0
Core: Log execeptions instead of silenty ignoring them.
msom May 7, 2023
138bc8c
Core: Use either secrets for random or indicate non-cryptographic usage.
msom May 7, 2023
8fe84d0
Core: Indicate safe hardcoded password values.
msom May 7, 2023
3b3a8da
Add bandit configuration [skip ci]
msom May 7, 2023
0428fa8
Exclude upgrade steps from bandit [skip ci]
msom May 7, 2023
aaba435
Core: Harden SQL code.
msom May 8, 2023
290567d
Core: Enable bandit.
msom May 8, 2023
a0c8edb
Fix bandi config [skip ci]
msom May 8, 2023
ce400bf
Town6: Display previous and next entries
BreathingFlesh May 8, 2023
8fdceca
Translator directory: Extend search filters.
cyrillkuettel May 8, 2023
e0b43a9
Translator directory: Display the forms in a two-column layout.
cyrillkuettel May 8, 2023
b1ede73
Translator directory: Open the mail client to send email to all trans…
cyrillkuettel May 8, 2023
b8ba06f
Translator directory: Display hometown and hide drive distance.
cyrillkuettel May 8, 2023
d64498e
Translator directory: Adds support for docx mail templates.
cyrillkuettel May 8, 2023
e990920
Release release-2023.20
cyrillkuettel May 8, 2023
62e8b00
Election Day: Add conditional widgets for majority types.
msom May 9, 2023
13e1833
Add freezgun hint to checklist [skip ci]
msom May 9, 2023
5707561
api: Every items of an API answer has now a 'modified' field
Tschuppi81 May 9, 2023
79701a2
Change the way the mailto link is rendered
cyrillkuettel May 9, 2023
f659933
Feriennet: Invoice item dates bug
BreathingFlesh May 9, 2023
358c4fc
Winterthur: Include events in iframe resizing
BreathingFlesh May 9, 2023
5de8311
Feriennet: Fix number of unlucky atteendees on dashboard
BreathingFlesh May 9, 2023
0d602e5
Change namespace to path on server [skip ci]
BreathingFlesh May 10, 2023
bf7cef6
Translator directory: Several minor fixes.
cyrillkuettel May 10, 2023
9bb940d
Translator directory: Minor adjustments.
cyrillkuettel May 10, 2023
7619bfe
api: Adding geo location to agency api
Tschuppi81 May 12, 2023
826e29e
Translator direcory: Use distinct adresses in mailto link.
cyrillkuettel May 12, 2023
d9a6956
Translator directory: Make font slightly smaller in translator view.
cyrillkuettel May 12, 2023
7c30aaa
Translator directory: Don't cache templates so they can be swapped out.
cyrillkuettel May 12, 2023
0dc7fec
Landsgemeinde: Add landsgemeinde app.
msom May 12, 2023
1029e9a
Release release-2023.21
msom May 12, 2023
a00a227
FSI: Add Organisation name to choice field
BreathingFlesh May 15, 2023
36100f7
Feriennet: Add political municipality fields to wishlist bookings export
BreathingFlesh May 16, 2023
7dec46b
Mypy: Adds static type checking to CI/pre-commit (#828)
Daverball May 16, 2023
dd80591
Org: Fix exception in hidden directory entries for logged out users
Daverball May 16, 2023
55c5830
mypy: Adds stubs for onegov.core.orm
Daverball May 17, 2023
292fd5b
Adding missing translations for org
Tschuppi81 May 19, 2023
a62f190
Revert "Adding missing translations for org"
Tschuppi81 May 19, 2023
b3a473b
org: Adding missing translations
Tschuppi81 May 19, 2023
e085245
api: Adding search capabilities to agency api (staka)
Tschuppi81 May 19, 2023
5a28c16
Landsgemeinde: Add vota.
msom May 19, 2023
74004bf
Release release-2023.22
msom May 19, 2023
7bdac63
Core: Remove readline from shell, add commit.
msom May 19, 2023
710d5fa
mypy: Adds type annotations to onegov.core.crypto/onegov.core.security
Daverball May 20, 2023
5ca96a7
Org: Set the .zip extension for directory export.
cyrillkuettel May 23, 2023
38ca069
mypy: Adds type annotations for onegov.core.cache
Daverball May 23, 2023
64838b3
Feriennet: Translation Fix
BreathingFlesh May 23, 2023
6faa027
Pdf: Use Source Sans 3 instead of Helvetica.
msom May 24, 2023
2ff994c
Adds a slightly faster CI workflow that will be used most of the time
Daverball May 24, 2023
5a9b8dc
Adds a file for GitHub actions so we can test on a branch [skip-ci]
Daverball May 24, 2023
aac0032
Adds some minimal stuff to workflow for testing [skip-ci]
Daverball May 24, 2023
6585a6d
Election Day: Adds compatibility with abraxas voting wabstic format.
msom May 24, 2023
53de35d
Switches from pytest-test-groups to pytest-split on CI
Daverball May 24, 2023
bbefb45
Election Day: Adds further compatibility with abraxas voting wabstic …
msom May 25, 2023
bb5f637
Adds a dummy file for a new GitHub actions workflow [skip-ci]
Daverball May 25, 2023
96edba9
agency: Extract address from portrait field
Tschuppi81 May 25, 2023
9d82495
Move tests to GitHub Actions
Daverball May 25, 2023
5420a1f
Add test badge to readme [skip ci]
msom May 25, 2023
ef9343b
Org: Improve presentation of context-specific function.
cyrillkuettel May 25, 2023
85963fa
Disable ES, make user search working using postgresql
Tschuppi81 May 23, 2023
e43bff0
Initial move from es to psql search for town6
Tschuppi81 May 23, 2023
a4f1a36
Rework upgrade and re-indexing for users
Tschuppi81 Jun 19, 2023
43f8cf6
Adding fts index to events, move add/drop column function to utils
Tschuppi81 Jun 19, 2023
74c9d80
Adding fts index to Page (topics, news)
Tschuppi81 Jun 19, 2023
43dba69
Adding fts index to Person
Tschuppi81 Jun 19, 2023
46c261a
Adding fts index to Tickets
Tschuppi81 Jun 20, 2023
d61c7e2
Adding fts index to Directories
Tschuppi81 Jun 20, 2023
af63a5d
Generalize index creation in mixin, simplify search
Tschuppi81 Jun 20, 2023
e7acaed
Introduce separate view for psql search, extend reindex to index es a…
Tschuppi81 Jun 22, 2023
c1025b4
Adding fts index to File
Tschuppi81 Jun 22, 2023
f9fb612
Adding fts index to Filesets
Tschuppi81 Jun 22, 2023
f965c22
Adding fts index to Directory Entries and Newsletter
Tschuppi81 Jun 22, 2023
ebaaa82
Fix index creation for Person
Tschuppi81 Jun 22, 2023
dc6345b
Adding fts index to Agency and Forms
Tschuppi81 Jun 22, 2023
d7b0f3d
Adding fts index to Agency Memberships and External Links
Tschuppi81 Jun 22, 2023
73feb59
Adding fts index to Activities
Tschuppi81 Jun 22, 2023
7de7fc5
Adding fts index to Attendees
Tschuppi81 Jun 22, 2023
f5dd8a9
Adding fts index to fsi courses, attendees and events
Tschuppi81 Jun 22, 2023
1c928db
Adding fts index to landsgemeinde
Tschuppi81 Jun 22, 2023
b7811ea
Cleanup
Tschuppi81 Jun 23, 2023
ad1522b
Adding fts index to Translators
Tschuppi81 Jun 23, 2023
82ca4cb
Cleanup upgrade fts index
Tschuppi81 Jun 26, 2023
f77ec8f
Add multi lingual index to all tables (in one single index)
Tschuppi81 Jun 26, 2023
ad061b0
Adding separate postgres sugguest app
Tschuppi81 Jun 27, 2023
2bef9ac
Minor changes
Tschuppi81 Jun 27, 2023
b24f46c
Introduce search score for searchables
Tschuppi81 Jun 27, 2023
2a3e293
Measure psql and es indexing
Tschuppi81 Jun 27, 2023
8d4915a
Rework search and suggestion
Tschuppi81 Jun 27, 2023
925efdb
Finalize generic and hashtag search for postgres
Tschuppi81 Jul 6, 2023
4257aa7
Add ranking to generic search
Tschuppi81 Jul 7, 2023
b199afb
Search template to use model.load_batch_results
Tschuppi81 Jul 7, 2023
6a9745b
Rework search results for generic and hashtag search
Tschuppi81 Jul 7, 2023
6c1b161
Search template to use model.load_batch_results
Tschuppi81 Jul 7, 2023
60b1d40
Fix result count
Tschuppi81 Jul 7, 2023
3ddee8a
Fix typo
Tschuppi81 Jul 7, 2023
5b33138
Ensure postgres remains with it
Tschuppi81 Jul 7, 2023
7c4fe20
Adds postgres search view to agency
Tschuppi81 Jul 7, 2023
13060ff
Adds postgres search view to Fsi
Tschuppi81 Jul 7, 2023
d0e29c6
Minor changes
Tschuppi81 Jul 7, 2023
5269b04
Cleanup
Tschuppi81 Jul 7, 2023
f7dd958
Rename to SearchApp (technology independent)
Tschuppi81 Jul 7, 2023
7377b3b
Resovle todo's
Tschuppi81 Jul 7, 2023
3eb8ed6
Cleanup
Tschuppi81 Jul 10, 2023
160489e
Resolve Merge Conflics
Tschuppi81 Jul 11, 2023
4ea8bba
Revert renaming of var
Tschuppi81 Jul 11, 2023
6b1bdbf
Removing duplicates
Tschuppi81 Jul 11, 2023
418031a
Resolve merge conflicts
Tschuppi81 Jul 13, 2023
0db74a1
Revert changing CHANGES.md
Tschuppi81 Jul 13, 2023
4a028ec
Fix wrong resolving merge conflicts
Tschuppi81 Jul 13, 2023
ec1c929
Extend doc for get_fts_index_languages
Tschuppi81 Jul 13, 2023
df0034d
Extracs function for multi language tsvector
Tschuppi81 Jul 17, 2023
30e9264
Deactivatte psql search tests
Tschuppi81 Jul 17, 2023
7dddff7
Only define fts column, removing index definition for all searchable …
Tschuppi81 Jul 17, 2023
c2a3c83
Remove reportlab pinning
Tschuppi81 Jul 20, 2023
55fb336
Move fts index from Activity to VactionActivity
Tschuppi81 Jul 20, 2023
6f16ae1
Fix type check
Tschuppi81 Jul 20, 2023
b804e8a
Remove unused commit
Tschuppi81 Jul 20, 2023
31372e4
Resovle merge conflicts
Tschuppi81 Jul 20, 2023
6d42052
Prevent tables get indexed multiple times
Tschuppi81 Jul 20, 2023
90f7fec
Remove duplicated code
Tschuppi81 Jul 20, 2023
8697a70
Revert to master
Tschuppi81 Jul 20, 2023
d9ef346
Move tsvector generation almost entirely to mixins
Tschuppi81 Jul 21, 2023
5ab1328
Remove upgrade step for ts index column as reindexing uses the same f…
Tschuppi81 Jul 21, 2023
44de655
Add upgrade step for column renaming tickets.group
Tschuppi81 Jul 21, 2023
7a45daa
Reset back to master
Tschuppi81 Jul 21, 2023
be6e0e5
Revert to master
Tschuppi81 Jul 24, 2023
8263549
Revert "Add upgrade step for column renaming tickets.group"
Tschuppi81 Jul 24, 2023
66c3790
Revert column renaming
Tschuppi81 Jul 24, 2023
073d11d
Resolve merge conflicts
Tschuppi81 Jul 24, 2023
cbc3e12
Merge branch 'master' into feature/ogc-508-replace-elastic-search-by-…
Tschuppi81 Jul 25, 2023
d379db3
Revert to master
Tschuppi81 Jul 25, 2023
6d0129f
Move psql tsvector string generation to mixin
Tschuppi81 Jul 25, 2023
5709ff5
Fix tsvector generation for tickets as 'group' is a reserved word in …
Tschuppi81 Jul 25, 2023
25c3544
Revert "Fix tsvector generation for tickets as 'group' is a reserved …
Tschuppi81 Jul 25, 2023
f11a32d
Commit column name in tsvector string in case of keyword like group
Tschuppi81 Jul 25, 2023
2840efe
Improve search results score/sorting
Tschuppi81 Jul 27, 2023
c48734f
Prioritize events over pages
Tschuppi81 Jul 27, 2023
5134f22
Fix typo
Tschuppi81 Jul 27, 2023
79c9d90
Move full text search column to mixin
Tschuppi81 Jul 28, 2023
716c450
Resolve merge conflicts
Tschuppi81 Jul 31, 2023
f8854ba
Resolve merge conflicts
Tschuppi81 Jul 31, 2023
07ec6bb
Adjust tsvector string to support hybrid_properties
Tschuppi81 Jul 31, 2023
f14bf7d
Re-enable all properties
Tschuppi81 Jul 31, 2023
761ff34
Simplify tsvector string generation by making use of dict_property ac…
Tschuppi81 Jul 31, 2023
b9c9286
Adding additional test
Tschuppi81 Aug 3, 2023
f87d524
Resolve merge conflicts
Tschuppi81 Aug 4, 2023
dfb7ee9
Rework search mixin to use expressions
Tschuppi81 Aug 17, 2023
0589cf9
Extend upgrade context by has_index function
Tschuppi81 Aug 17, 2023
1773dd4
Improve collecting index properties
Tschuppi81 Aug 17, 2023
86cebc2
Rework index creation taking into account the property type
Tschuppi81 Aug 17, 2023
a312b45
Remove dependency to onegov.org
Tschuppi81 Sep 12, 2023
9aac0d0
Resolve merge conflicts
Tschuppi81 Sep 12, 2023
21e87ff
Switch hybrid to regular properties to make re-index work
Tschuppi81 Sep 13, 2023
c81a188
Via property the directory id with type uuid can now be indexed
Tschuppi81 Sep 13, 2023
59a478c
Add search score
Tschuppi81 Sep 13, 2023
400865e
Revert "Switch hybrid to regular properties to make re-index work"
Tschuppi81 Nov 9, 2023
308a7de
Revert "Via property the directory id with type uuid can now be indexed"
Tschuppi81 Nov 9, 2023
2bd99c3
Merge master
Tschuppi81 Nov 9, 2023
64a9655
Adds hybrid properties for search index properties
Tschuppi81 Nov 17, 2023
90bc8a9
Removing filter keywords as we also do not index the event tags
Tschuppi81 Nov 17, 2023
2b311e9
Merge branch 'master' into feature/ogc-508-replace-elastic-search-by-…
Tschuppi81 Nov 17, 2023
ccc6c0c
Adds hybrid properties for search index properties
Tschuppi81 Nov 17, 2023
eae5dcd
Adds directory id to fts index
Tschuppi81 Nov 22, 2023
e6fcdb1
DEV ONLY Issue to join data from other table in hybrid expression in …
Tschuppi81 Nov 27, 2023
ccbf117
Revert "DEV ONLY Issue to join data from other table in hybrid expres…
Tschuppi81 Nov 28, 2023
9e454e3
Fix hybrid properties and add expressions for Pages
Tschuppi81 Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ all the necessary book keeping for traces and profiles

##### Improve ticker code.

Adds fallback to ticker in case of websocket server shutdown and add
Adds fallback to ticker in case of websocket server shutdown and add
timestamp to HEAD request to avoid being browser-cached.

`Bugfix` | [093fdf43af](https://github.com/onegov/onegov-cloud/commit/093fdf43af92fb4ecc2de84f815db5a48a08f13a)
Expand Down Expand Up @@ -681,7 +681,7 @@ Removes reference to deleted 'sender' mail macro from mail template.

##### Fixes news not being displayed if it's the first item.

Fix root-level page interpretation bug for news,
Fix root-level page interpretation bug for news,
which was mistakenly being treated as falsy (index 0).

`Bugfix` | [OGC-863](https://linear.app/onegovcloud/issue/OGC-863) | [dc42c72bf3](https://github.com/onegov/onegov-cloud/commit/dc42c72bf3229270ff262b2c38a58d61cb41cfcb)
Expand Down Expand Up @@ -818,8 +818,8 @@ Displays "access denied" instead of "page not found" if Invoice exists.

##### Don't use deferral on timestamp columns.

Timestamps don't add a lot of data to queries but accessing them will
lead to a lot of additional queries. Also, nobody expects these
Timestamps don't add a lot of data to queries but accessing them will
lead to a lot of additional queries. Also, nobody expects these
timestamps to be deferred in the first place.

`Bugfix` | [6288609773](https://github.com/onegov/onegov-cloud/commit/6288609773ffc7cc447db2dd267e7dd433c00ff1)
Expand Down Expand Up @@ -1312,7 +1312,7 @@ Documents = *.pdf (multiple)

##### Add content security policy tween.

Allows to optionally add a websocket endpoint to the connect-src content
Allows to optionally add a websocket endpoint to the connect-src content
security policy.

`Feature` | [OGC-935](https://linear.app/onegovcloud/issue/OGC-935) | [9b2a006baf](https://github.com/onegov/onegov-cloud/commit/9b2a006baf374b7514a871bae18ddabf66326c8e)
Expand Down Expand Up @@ -2401,7 +2401,7 @@ Also cleanup the documentation.

`Bugfix` | [OGC-589](https://linear.app/onegovcloud/issue/OGC-589) | [fb904c42d3](https://github.com/onegov/onegov-cloud/commit/fb904c42d33f08f8212215819a666912523f4260)

### Core
### Core

##### Use autoapi for documentation.

Expand Down
10 changes: 5 additions & 5 deletions src/onegov/activity/models/attendee.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import date

from onegov.activity.models.booking import Booking
from onegov.core.orm import Base
from onegov.core.orm.mixins import TimestampMixin
Expand All @@ -11,7 +12,6 @@
from sqlalchemy import Date
from sqlalchemy import Float
from sqlalchemy import ForeignKey
from sqlalchemy import Index
from sqlalchemy import Integer
from sqlalchemy import Numeric
from sqlalchemy import Text
Expand Down Expand Up @@ -43,6 +43,10 @@ class Attendee(Base, TimestampMixin, ORMSearchable):
}
es_public = False

@property
def search_score(self):
return 3

@property
def es_suggestion(self):
return self.name
Expand Down Expand Up @@ -179,7 +183,3 @@ def happiness(cls, period_id):
order_by='Booking.created',
backref='attendee'
)

__table_args__ = (
Index('unique_child_name', 'username', 'name', unique=True),
)
2 changes: 0 additions & 2 deletions src/onegov/agency/models/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def es_public(self):
'title': {'type': 'text'},
'function': {'type': 'localized'},
'email': {'type': 'text'},
'phone_internal': {'type': 'text'},
'phone_es': {'type': 'text'}
}

@property
Expand Down
14 changes: 12 additions & 2 deletions src/onegov/agency/views/search.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
from onegov.agency import AgencyApp
from onegov.agency.layout import AgencySearchLayout
from onegov.core.security import Public
from onegov.org.models import Search
from onegov.org.models import Search, SearchPostgres
from onegov.org.views.search import search as search_view
from onegov.org.views.search import search_postgres as search_postgres_view


@AgencyApp.html(model=Search, template='search.pt', permission=Public)
def search(self, request):
def agency_search(self, request):
data = search_view(self, request)
if isinstance(data, dict):
data['layout'] = AgencySearchLayout(self, request)
return data


@AgencyApp.html(model=SearchPostgres, template='search_postgres.pt',
permission=Public)
def agency_search_postgres(self, request):
data = search_postgres_view(self, request)
if isinstance(data, dict):
data['layout'] = AgencySearchLayout(self, request)
return data
8 changes: 5 additions & 3 deletions src/onegov/directory/models/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
from onegov.file.utils import as_fileintent
from onegov.form import flatten_fieldsets, parse_formcode, parse_form
from onegov.search import SearchableContent
from sqlalchemy import Column
from sqlalchemy import Column, Text, Integer
from sqlalchemy import func, exists, and_
from sqlalchemy import Integer
from sqlalchemy import Text
from sqlalchemy.orm import object_session
from sqlalchemy.orm import relationship
from sqlalchemy.orm.attributes import InstrumentedAttribute
Expand Down Expand Up @@ -103,6 +101,10 @@ def count(self):
backref='directory'
)

@property
def search_score(self):
return 7

@property
def entry_cls_name(self):
return 'DirectoryEntry'
Expand Down
4 changes: 3 additions & 1 deletion src/onegov/directory/models/directory_entry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from sqlalchemy.ext.hybrid import hybrid_property

from onegov.core.orm import Base
from onegov.core.orm.mixins import ContentMixin
from onegov.core.orm.mixins import TimestampMixin
Expand Down Expand Up @@ -98,7 +100,7 @@ def keywords(self):
def keywords(self, value):
self._keywords = {k: '' for k in value} if value else None

@property
@hybrid_property
def text(self):
return self.directory.configuration.extract_searchable(self.values)

Expand Down
5 changes: 5 additions & 0 deletions src/onegov/event/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from icalendar import Calendar as vCalendar
from icalendar import Event as vEvent
from icalendar import vRecur

from onegov.core.orm import Base
from onegov.core.orm.abstract import associated
from onegov.core.orm.mixins import content_property
Expand Down Expand Up @@ -106,6 +107,10 @@ class Event(Base, OccurrenceMixin, ContentMixin, TimestampMixin,
EventFile, 'pdf', 'one-to-one', uselist=False, backref_suffix='pdf'
)

@property
def search_score(self):
return 1

def set_image(self, content, filename=None):
self.set_blob('image', content, filename)

Expand Down
9 changes: 8 additions & 1 deletion src/onegov/feriennet/models/activity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from functools import cached_property

from sqlalchemy.ext.hybrid import hybrid_property

from onegov.activity import Activity, ActivityCollection, Occasion
from onegov.activity import PublicationRequestCollection
from onegov.activity.models import DAYS
Expand All @@ -24,6 +27,10 @@ class VacationActivity(Activity, CoordinatesExtension, SearchableContent):
'organiser': {'type': 'text'}
}

@property
def search_score(self):
return 1

@property
def es_public(self):
return self.state == 'accepted'
Expand All @@ -32,7 +39,7 @@ def es_public(self):
def es_skip(self):
return self.state == 'preview'

@property
@hybrid_property
def organiser(self):
organiser = [
self.user.username,
Expand Down
2 changes: 1 addition & 1 deletion src/onegov/feriennet/templates/mail_booking_accepted.pt
Tschuppi81 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<tal:b tal:content="structure bookings_link"></tal:b>
</p>
<br>
<p i18n:translate>Best regards</p>
<p i18n:translate>Best regards</p>
<metal:b use-macro="layout.macros['sender']|nothing" />
</tal:b>
</div>
2 changes: 1 addition & 1 deletion src/onegov/feriennet/templates/mail_booking_canceled.pt
Tschuppi81 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<tal:b tal:content="structure bookings_link"></tal:b>
</p>
<br>
<p i18n:translate>Best regards</p>
<p i18n:translate>Best regards</p>
<metal:b use-macro="layout.macros['sender']|nothing" />
</tal:b>
</div>
5 changes: 5 additions & 0 deletions src/onegov/file/models/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from contextlib import contextmanager
from collections import defaultdict
from depot.fields.sqlalchemy import UploadedFileField as UploadedFileFieldBase

from onegov.core.crypto import random_token
from onegov.core.orm import Base
from onegov.core.orm.abstract import Associable
Expand Down Expand Up @@ -257,6 +258,10 @@ class File(Base, Associable, TimestampMixin):
Index('files_by_type_and_order', 'type', 'order'),
)

@property
def search_score(self) -> int:
return 10

@hybrid_property
def signature_timestamp(self) -> 'datetime | None':
if self.signed:
Expand Down
1 change: 1 addition & 0 deletions src/onegov/file/models/fileset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


from typing import TYPE_CHECKING

if TYPE_CHECKING:
from .file import File

Expand Down
4 changes: 4 additions & 0 deletions src/onegov/form/models/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ class FormDefinition(Base, ContentMixin, TimestampMixin, Extendable):
'polymorphic_identity': 'generic'
}

@property
def search_score(self):
return 7

@property
def form_class(self):
""" Parses the form definition and returns a form class. """
Expand Down
5 changes: 5 additions & 0 deletions src/onegov/fsi/models/course.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from arrow import utcnow

from onegov.core.html import html_to_text
from onegov.core.orm import Base
from onegov.core.orm.types import UUID
Expand Down Expand Up @@ -32,6 +33,10 @@ class Course(Base, ORMSearchable):
# hides the course in the collection for non-admins
hidden_from_public = Column(Boolean, nullable=False, default=False)

@property
def search_score(self):
return 2

@property
def title(self):
return self.name
Expand Down
6 changes: 4 additions & 2 deletions src/onegov/fsi/models/course_attendee.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from sqlalchemy.ext.hybrid import hybrid_property

from onegov.core.orm import Base
from onegov.core.orm.types import UUID, JSON
from sqlalchemy import Boolean
Expand Down Expand Up @@ -107,7 +109,7 @@ def __str__(self):
cascade='all, delete-orphan'
)

@property
@hybrid_property
def title(self):
return ' '.join((
p for p in (
Expand All @@ -131,7 +133,7 @@ def role(self):
return 'member'
return self.user.role

@property
@hybrid_property
def email(self):
"""Needs a switch for external users"""
if not self.user_id:
Expand Down
12 changes: 7 additions & 5 deletions src/onegov/fsi/models/course_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
from onegov.fsi.models.course_subscription import subscription_table
from onegov.search import ORMSearchable


from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .course import Course
from .course_notification_template import (
CancellationTemplate, CourseNotificationTemplate, InfoTemplate,
ReminderTemplate, SubscriptionTemplate
CancellationTemplate,
CourseNotificationTemplate,
InfoTemplate,
ReminderTemplate,
SubscriptionTemplate
)

COURSE_EVENT_STATUSES = ('created', 'confirmed', 'canceled', 'planned')
Expand Down Expand Up @@ -83,7 +85,7 @@ def es_public(self):
def title(self):
return str(self)

@property
@hybrid_property
def name(self):
return self.course.name

Expand All @@ -95,7 +97,7 @@ def lead(self):
f'{self.presenter_company}'
)

@property
@hybrid_property
def description(self):
return self.course.description

Expand Down
16 changes: 15 additions & 1 deletion src/onegov/fsi/views/search.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
from onegov.core.security import Personal
from onegov.fsi import FsiApp
from onegov.org.models import Search
from onegov.org.models import Search, SearchPostgres
from onegov.org.views.search import search as search_view
from onegov.org.views.search import search_postgres as search_postgres_view
from onegov.org.views.search import suggestions as suggestions_view
from onegov.org.views.search import suggestions_postgres as \
suggestions_postgres_view


@FsiApp.html(model=Search, template='search.pt', permission=Personal)
def search(self, request):
return search_view(self, request)


@FsiApp.html(model=SearchPostgres, template='search_postgres.pt',
permission=Personal)
def search_postgres(self, request):
return search_postgres_view(self, request)


@FsiApp.json(model=Search, name='suggest', permission=Personal)
def suggestions(self, request):
return suggestions_view(self, request)


@FsiApp.json(model=SearchPostgres, name='suggest', permission=Personal)
def suggestions_postgres(self, request):
return suggestions_postgres_view(self, request)
1 change: 1 addition & 0 deletions src/onegov/landsgemeinde/views/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

@LandsgemeindeApp.html(model=Search, template='search.pt', permission=Public)
def landsgemeinde_search(self, request):
# TODO: switch to postgres search
return search(self, request, DefaultLayout(self, request))
3 changes: 3 additions & 0 deletions src/onegov/newsletter/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def validate_name(self, key: str, name: str) -> str:
back_populates='newsletters')

@property
def search_score(self) -> int:
return 6

def open_recipients(self) -> tuple['Recipient', ...]:
received = select([newsletter_recipients.c.recipient_id]).where(
newsletter_recipients.c.newsletter_id == self.name)
Expand Down
4 changes: 2 additions & 2 deletions src/onegov/onboarding/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from onegov.file import DepotApp
from onegov.onboarding.theme import OnboardingTheme
from onegov.reservation import LibresIntegration
from onegov.search import ElasticsearchApp
from onegov.search import SearchApp


class OnboardingApp(Framework, LibresIntegration, DepotApp, ElasticsearchApp):
class OnboardingApp(Framework, LibresIntegration, DepotApp, SearchApp):

serve_static_files = True

Expand Down
Loading
Loading