Skip to content

Commit

Permalink
fix(apis_entities): add more information to autocomplete results
Browse files Browse the repository at this point in the history
A downstream project needs more information in the autocomplete result.
This is just a temporaray workaround, because this autocomplete3 module
is still used for the relations forms.
  • Loading branch information
b1rger committed Jan 31, 2024
1 parent 79d74a3 commit db1c0c7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions apis_core/apis_entities/autocomplete3.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,19 @@ def get(self, request, *args, **kwargs):
data-long="{}" class="apis-autocomplete-span"'.format(
ac_type, r.lat, r.lng
)
f["text"] = "<span {}><small>db</small> {}</span>".format(
dataclass, str(r)
)
# this is a temporary workaround and can be removed once
# we use the new custom autocomplete overrides for the relations
text = str(r)
dateend = datestart = ""
if hasattr(r, "end_date") and r.end_date is not None:
dateend = r.end_date.year
if hasattr(r, "start_date") and r.start_date is not None:
datestart = r.start_date.year
if dateend or datestart:
text += f" ({datestart} - {dateend})"
if hasattr(r, "professioncategory"):
text += f" <i>{r.professioncategory}</i>"
f["text"] = f"<span {dataclass}><small>db</small> {text}</span>"
choices.append(f)
if len(choices) < page_size:
test_db = False
Expand Down

0 comments on commit db1c0c7

Please sign in to comment.