diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-12-01 19:18:45 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-12-01 19:18:45 +0100 |
commit | 5020fb9c32b37c676f3231f0d9c40b4a782d6b5f (patch) | |
tree | f7a7b2e7f9a365e920e576e8661364e61d70061e | |
parent | b3780b230773ed408bae65fc24a92f484e04b446 (diff) | |
download | Ishtar-5020fb9c32b37c676f3231f0d9c40b4a782d6b5f.tar.bz2 Ishtar-5020fb9c32b37c676f3231f0d9c40b4a782d6b5f.zip |
Administrativ act: search by departments
-rw-r--r-- | archaeological_files/forms.py | 16 | ||||
-rw-r--r-- | archaeological_files/views.py | 2 | ||||
-rw-r--r-- | archaeological_operations/forms.py | 9 | ||||
-rw-r--r-- | archaeological_operations/views.py | 4 |
4 files changed, 31 insertions, 0 deletions
diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py index 75a794fca..a8dd99135 100644 --- a/archaeological_files/forms.py +++ b/archaeological_files/forms.py @@ -380,6 +380,9 @@ class AdministrativeActFileModifySelect(TableSelect): max_length=15) act_type = forms.ChoiceField(label=_("Act type"), choices=[]) operation__towns = get_town_field() + if settings.ISHTAR_DPTS: + operation__towns__numero_insee__startswith = forms.ChoiceField( + label=_(u"Department"), choices=[]) def __init__(self, *args, **kwargs): super(AdministrativeActFileModifySelect, self).__init__(*args, @@ -388,6 +391,11 @@ class AdministrativeActFileModifySelect(TableSelect): dct={'intented_to': 'F'}) self.fields['act_type'].help_text = ActType.get_help( dct={'intented_to': 'F'}) + if settings.ISHTAR_DPTS: + k = 'operation__towns__numero_insee__startswith' + self.fields[k].choices = [ + ('', '--')] + [(str(dpt), str(dpt)) + for dpt in settings.ISHTAR_DPTS] class AdministrativeActFileSelect(TableSelect): @@ -431,6 +439,9 @@ class AdministrativeActFileSelect(TableSelect): validators=[valid_id(Person)]) associated_file__permit_reference = forms.CharField( max_length=200, label=_("Permit reference")) + if settings.ISHTAR_DPTS: + operation__towns__numero_insee__startswith = forms.ChoiceField( + label=_(u"Department"), choices=[]) history_creator = forms.IntegerField( label=_(u"Created by"), widget=widgets.JQueryAutoComplete( @@ -446,6 +457,11 @@ class AdministrativeActFileSelect(TableSelect): dct={'intented_to': 'F'}) self.fields['act_type'].help_text = ActType.get_help( dct={'intented_to': 'F'}) + if settings.ISHTAR_DPTS: + k = 'operation__towns__numero_insee__startswith' + self.fields[k].choices = [ + ('', '--')] + [(str(dpt), str(dpt)) + for dpt in settings.ISHTAR_DPTS] class AdministrativeActFileFormSelection(AdministrativeActOpeFormSelection): diff --git a/archaeological_files/views.py b/archaeological_files/views.py index 473972d2a..3f7e0bc8b 100644 --- a/archaeological_files/views.py +++ b/archaeological_files/views.py @@ -120,6 +120,8 @@ get_administrativeactfile = get_item( 'associated_file__general_contractor__attached_to': 'associated_file__general_contractor__attached_to__pk', 'associated_file__name': 'associated_file__name__icontains', + 'operation__towns__numero_insee__startswith': + 'operation__towns__numero_insee__startswith', 'associated_file__permit_reference': 'associated_file__permit_reference__icontains'}, relative_session_names={'file': 'associated_file__pk'}) diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 6640ae7e3..06c6585d8 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -986,6 +986,9 @@ class AdministrativeActOpeSelect(TableSelect): max_length=15) act_type = forms.ChoiceField(label=_("Act type"), choices=[]) operation__towns = get_town_field() + if settings.ISHTAR_DPTS: + operation__towns__numero_insee__startswith = forms.ChoiceField( + label=_(u"Department"), choices=[]) history_creator = forms.IntegerField( label=_(u"Created by"), widget=widgets.JQueryAutoComplete( @@ -999,6 +1002,12 @@ class AdministrativeActOpeSelect(TableSelect): dct={'intented_to': 'O'}) self.fields['act_type'].help_text = models.ActType.get_help( dct={'intented_to': 'O'}) + if settings.ISHTAR_DPTS: + k = 'operation__towns__numero_insee__startswith' + self.fields[k].choices = [ + ('', '--')] + [(str(dpt), str(dpt)) + for dpt in settings.ISHTAR_DPTS] + class AdministrativeActOpeFormSelection(forms.Form): diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index d60d9da3d..7ae6063bc 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -166,6 +166,8 @@ get_administrativeactop = get_item( 'year': 'signature_date__year', 'history_creator': 'history_creator__ishtaruser__person__pk', + 'operation__towns__numero_insee__startswith': + 'operation__towns__numero_insee__startswith' }, relative_session_names={'operation': 'operation__pk'}) @@ -176,6 +178,8 @@ get_administrativeact = get_item( 'indexed': 'index__isnull', 'history_creator': 'history_creator__ishtaruser__person__pk', + 'operation__towns__numero_insee__startswith': + 'operation__towns__numero_insee__startswith', 'operation__towns': 'operation__towns__pk'}, reversed_bool_fields=['index__isnull'],) show_administrativeact = show_item(models.AdministrativeAct, |