diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-07-10 16:49:03 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-13 18:26:03 +0200 |
commit | 4ba53610bc58575b752d5df5a3bb7ee141df62bf (patch) | |
tree | 6c55db881e0a2b0639035a474956cd3fd6b01404 /ishtar_common | |
parent | a4cac1fcab7d033fdd3a35174c825e925c3eb4a7 (diff) | |
download | Ishtar-4ba53610bc58575b752d5df5a3bb7ee141df62bf.tar.bz2 Ishtar-4ba53610bc58575b752d5df5a3bb7ee141df62bf.zip |
Search widget: dynamic link for bookmark save
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/forms_common.py | 24 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/forms/search_query.html | 2 | ||||
-rw-r--r-- | ishtar_common/templates/widgets/search_input.html | 6 | ||||
-rw-r--r-- | ishtar_common/widgets.py | 11 |
4 files changed, 31 insertions, 12 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 397b87815..ec6f7bc96 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -338,8 +338,10 @@ class OrganizationForm(ManageOldType, NewItemForm): class OrganizationSelect(TableSelect): - search_vector = forms.CharField(label=_(u"Full text search"), - widget=widgets.SearchWidget) + search_vector = forms.CharField( + label=_(u"Full text search"), widget=widgets.SearchWidget( + 'ishtar-common', 'organization' + )) name = forms.CharField(label=_(u"Name"), max_length=300) organization_type = forms.ChoiceField(label=_(u"Type"), choices=[]) @@ -453,8 +455,10 @@ class BaseOrganizationForm(forms.ModelForm): class PersonSelect(TableSelect): - search_vector = forms.CharField(label=_(u"Full text search"), - widget=widgets.SearchWidget) + search_vector = forms.CharField( + label=_(u"Full text search"), widget=widgets.SearchWidget( + 'ishtar-common', 'person' + )) name = forms.CharField(label=_(u"Name"), max_length=200) surname = forms.CharField(label=_(u"Surname"), max_length=50) email = forms.CharField(label=_(u"Email"), max_length=75) @@ -582,8 +586,10 @@ class PersonUserFormSelection(PersonFormSelection): class IshtarUserSelect(TableSelect): - search_vector = forms.CharField(label=_(u"Full text search"), - widget=widgets.SearchWidget) + search_vector = forms.CharField( + label=_(u"Full text search"), widget=widgets.SearchWidget( + 'ishtar-common', 'ishtaruser' + )) username = forms.CharField(label=_(u"Username"), max_length=200) name = forms.CharField(label=_(u"Name"), max_length=200) surname = forms.CharField(label=_(u"Surname"), max_length=50) @@ -1172,8 +1178,10 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType): class DocumentSelect(TableSelect): - search_vector = forms.CharField(label=_(u"Full text search"), - widget=widgets.SearchWidget) + search_vector = forms.CharField( + label=_(u"Full text search"), widget=widgets.SearchWidget( + 'ishtar-common', 'document' + )) authors = forms.IntegerField( widget=widgets.JQueryAutoComplete( "/" + settings.URL_PATH + 'autocomplete-author', diff --git a/ishtar_common/templates/ishtar/forms/search_query.html b/ishtar_common/templates/ishtar/forms/search_query.html index ff51d483d..d44c61ade 100644 --- a/ishtar_common/templates/ishtar/forms/search_query.html +++ b/ishtar_common/templates/ishtar/forms/search_query.html @@ -2,7 +2,7 @@ <div class="modal-dialog modal-sm" id="save-search-div"> <div class="modal-content"> <div class="modal-header"> - <h5>{% trans "Bookmark search" %}</h5> + <h5>{% trans "Bookmark this search" %}</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> diff --git a/ishtar_common/templates/widgets/search_input.html b/ishtar_common/templates/widgets/search_input.html index 01e49e93b..7f5526b18 100644 --- a/ishtar_common/templates/widgets/search_input.html +++ b/ishtar_common/templates/widgets/search_input.html @@ -23,12 +23,12 @@ id="save-search-button" data-target="#modal-dynamic-form" data-modal-open="#modal-dynamic-form" - title="{% trans 'Bookmark save' %}" - href="{% url 'save-search-query' 'archaeological-operations' 'operation'%}"> + title="{% trans 'Bookmark this search' %}" + href="{% url 'save-search-query' app_name model %}"> <i class="fa fa-star-o" aria-hidden="true"></i> </a> <span class="input-group-text input-link disabled" - title="{% trans 'Load bookmark' %}" + title="{% trans 'Bookmarks' %}" id="load-bookmark"> <i class="fa fa-bookmark" aria-hidden="true"></i> </span> diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 8788920af..405b5d69e 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -479,6 +479,17 @@ if settings.SURFACE_UNIT == 'square-metre': class SearchWidget(forms.TextInput): template_name = 'widgets/search_input.html' + def __init__(self, app_name=None, model=None, attrs=None): + super(SearchWidget, self).__init__(attrs) + self.app_name = app_name + self.model = model + + def get_context(self, name, value, attrs): + context = super(SearchWidget, self).get_context(name, value, attrs) + context['app_name'] = self.app_name + context['model'] = self.model + return context + class ModelFieldMixin(object): def to_python(self, value): |