diff options
| author | Étienne Loks <etienne.loks@proxience.com> | 2015-12-03 13:05:06 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@proxience.com> | 2015-12-03 13:05:06 +0100 | 
| commit | fd0a0165c3a06ecea377cc9a16ac2706b1dc9d40 (patch) | |
| tree | 038feacbb6eaff4d5e531ec417652009ed2f1ce5 | |
| parent | 677bc165441d508429295f476a28a966efa2ce29 (diff) | |
| download | Ishtar-fd0a0165c3a06ecea377cc9a16ac2706b1dc9d40.tar.bz2 Ishtar-fd0a0165c3a06ecea377cc9a16ac2706b1dc9d40.zip | |
Better management of raw_names for search and windows
| -rw-r--r-- | ishtar_common/forms_common.py | 5 | ||||
| -rw-r--r-- | ishtar_common/models.py | 2 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/sheet_person.html | 26 | ||||
| -rw-r--r-- | ishtar_common/views.py | 19 | 
4 files changed, 33 insertions, 19 deletions
| diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 0e6a34b74..1ff9532e9 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -258,6 +258,7 @@ class SimplePersonForm(NewItemForm):                                validators=[name_validator])      name = forms.CharField(label=_(u"Name"), max_length=30,                             validators=[name_validator]) +    raw_name = forms.CharField(label=_(u"Raw name"), max_length=255)      address = forms.CharField(label=_(u"Address"), widget=forms.Textarea,                                required=False)      address_complement = forms.CharField(label=_(u"Address complement"), @@ -278,6 +279,10 @@ class SimplePersonForm(NewItemForm):              associated_model=models.Organization, new=True),          validators=[models.valid_id(models.Organization)], required=False) +    def __init__(self, *args, **kwargs): +        super(SimplePersonForm, self).__init__(*args, **kwargs) +        self.fields['raw_name'].widget.attrs['readonly'] = True +  class BasePersonForm(forms.ModelForm):      class Meta: diff --git a/ishtar_common/models.py b/ishtar_common/models.py index e762bf67f..72b41e0cf 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1864,7 +1864,7 @@ class Person(Address, Merge, OwnPerms, ValueGetter):          ('Md', _(u'Mrs')),          ('Dr', _(u'Doctor')),      ) -    TABLE_COLS = ('name', 'surname', 'email', 'person_types_list', +    TABLE_COLS = ('name', 'surname', 'raw_name', 'email', 'person_types_list',                    'attached_to')      title = models.CharField(_(u"Title"), max_length=100, choices=TYPE,                               blank=True, null=True) diff --git a/ishtar_common/templates/ishtar/sheet_person.html b/ishtar_common/templates/ishtar/sheet_person.html index b6bf99d56..38bc39c58 100644 --- a/ishtar_common/templates/ishtar/sheet_person.html +++ b/ishtar_common/templates/ishtar/sheet_person.html @@ -1,5 +1,5 @@  {% extends "ishtar/sheet.html" %} -{% load i18n %} +{% load i18n window_field %}  {% block head_sheet %}  {{block.super}} @@ -9,18 +9,18 @@  {% block content %}  <div class='tool'>{%trans "Export as:"%} <a href='{% url show-person item.pk "odt" %}'>{%trans "OpenOffice.org file"%}</a>, <a href='{% url show-person item.pk "pdf" %}'>{%trans "PDF file"%}</a></div> -<p><label>{% trans "Name" %}</label> <span class='value'>{{item.name}}</span></p> -<p><label>{% trans "Surname" %}</label> <span class='value'>{{item.surname}}</span></p> -<p><label>{%trans "Created by:"%}</label> <span class='value'>{{ item.history_creator.ishtaruser.full_label }}</span></p> -{% if item.email %}<p><label>{% trans "Email" %}</label> <span class='value'>{{item.email}}</span></p>{% endif %} -<p><label>{% trans "Type(s)" %}</label> <span class='value'>{{item.person_types_list}}</span></p> -{% if item.address %}<p><label>{% trans "Address" %}</label> <span class='value'>{{item.address}}</span></p> {% endif %} -{% if item.address_complement %}<p><label>{% trans "Address complement" %}</label> <span class='value'>{{item.address_complement}}</span></p> {% endif %} -{% if item.postal_code %}<p><label>{% trans "Postal code" %}</label> <span class='value'>{{item.postal_code}}</span></p> {% endif %} -{% if item.town %}<p><label>{% trans "Town" %}</label> <span class='value'>{{item.town}}</span></p> {% endif %} -{% if item.phone %}<p><label>{% trans "Phone" %}</label> <span class='value'>{{item.phone}}</span></p> {% endif %} -{% if item.mobile_phone %}<p><label>{% trans "Mobile phone" %}</label> <span class='value'>{{item.mobile_phone}}</span></p> {% endif %} - +{% field "Name" item.name %} +{% field "Surname" item.surname %} +{% field "Raw name" item.raw_name %} +{% field "Created by" item.history_creator.ishtaruser.full_label %} +{% field "Email" item.email %} +{% field "Type(s)" item.person_types_list %} +{% field "Address" item.address %} +{% field "Address complement" item.address_complement %} +{% field "Postal code" item.postal_code %} +{% field "Town" item.town %} +{% field "Phone" item.phone %} +{% field "Mobile phone" item.mobile_phone %}  {% if item.organization %}<h3>{% trans "Associated organization"%}</h3>  <p><label>{% trans "Name" %}</label> <span class='value'>{{item.organization}}</span></p> diff --git a/ishtar_common/views.py b/ishtar_common/views.py index f605c4b25..819c88f32 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -356,10 +356,19 @@ def get_item(model, func_name, default_name, extra_request_keys=[],          except ValueError:              return HttpResponse('[]', mimetype='text/plain')          for k in request_keys: -            q = request_items.get(k) -            if not q: +            val = request_items.get(k) +            if not val: +                continue +            req_keys = request_keys[k] +            if type(req_keys) not in (list, tuple): +                dct[req_keys] = val                  continue -            dct[request_keys[k]] = q +            # multiple choice target +            reqs = Q(**{req_keys[0]: val}) +            for req_key in req_keys[1:]: +                q = Q(**{req_key: val}) +                reqs = reqs | q +            and_reqs.append(reqs)          if not dct and 'submited' not in request_items:              if default_name in request.session and \                 request.session[default_name]: @@ -832,8 +841,8 @@ get_person = get_item(      models.Person,      'get_person', 'person',      extra_request_keys={ -        'name': 'name__icontains', -        'surname': 'surname__icontains', +        'name': ['name__icontains', 'raw_name__icontains'], +        'surname': ['surname__icontains', 'raw_name__icontains'],          'attached_to': 'attached_to__pk',          'person_types': 'person_types__pk__in',      }) | 
