diff options
| -rw-r--r-- | archaeological_operations/forms.py | 26 | ||||
| -rw-r--r-- | archaeological_operations/models.py | 11 | ||||
| -rw-r--r-- | archaeological_operations/urls.py | 9 | ||||
| -rw-r--r-- | archaeological_operations/views.py | 9 | ||||
| -rw-r--r-- | ishtar_common/forms.py | 11 | 
5 files changed, 57 insertions, 9 deletions
| diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index f9bf8607c..55a9541ff 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -39,7 +39,7 @@ from archaeological_operations.utils import parse_parcels  from bootstrap_datepicker.widgets import DateField  from ishtar_common import widgets  from ishtar_common.forms import FinalForm, FormSet, get_now, \ -    reverse_lazy, TableSelect, get_data_from_formset, \ +    reverse_lazy, TableSelect, get_data_from_formset, QAForm, CustomFormSearch,\      ManageOldType, IshtarForm, CustomForm, FieldType, FormHeader, HistorySelect  from ishtar_common.forms_common import TownFormSet, get_town_field, TownForm  from ishtar_common.models import valid_id, Person, Town, \ @@ -597,7 +597,7 @@ class OperationSelect(HistorySelect):                  ('', '--')] + list(settings.ISHTAR_DPTS) -class OperationFormSelection(IshtarForm): +class OperationFormSelection(CustomFormSearch):      SEARCH_AND_SELECT = True      form_label = _(u"Operation search")      associated_models = {'pk': models.Operation} @@ -1745,3 +1745,25 @@ class AdministrativeActRegisterFormSelection(IshtarForm):              raise forms.ValidationError(                  _(u"You should select an administrative act."))          return cleaned_data + + +class QAOperationFormMulti(QAForm): +    form_admin_name = _(u"Operation - Quick action - Modify") +    form_slug = "operation-quickaction-modify" +    base_models = ['qa_operation_type'] +    associated_models = { +        'qa_operation_type': models.OperationType, +    } + +    MULTI = True +    REPLACE_FIELDS = [ +        'qa_operation_type', +    ] +    qa_operation_type = forms.ChoiceField( +        label=_(u"Operation type"), required=False +    ) + +    TYPES = [ +        FieldType('qa_operation_type', models.OperationType), +    ] + diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 996ede679..e54720771 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -39,7 +39,7 @@ from ishtar_common.models import BaseHistorizedItem, Dashboard, \      post_delete_record_relation, post_save_cache, RelationItem, \      ShortMenuItem, SourceType, Town, ValueGetter, get_current_profile, \      document_attached_changed, HistoryModel, SearchAltName, \ -    GeoItem, QRCodeItem, SearchVectorConfig, DocumentItem +    GeoItem, QRCodeItem, SearchVectorConfig, DocumentItem, QuickAction, MainItem  from ishtar_common.utils import cached_label_changed, \      force_cached_label_changed, mode, m2m_historization_changed, post_save_geo @@ -516,7 +516,7 @@ class OperationManager(models.GeoManager):  class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem, -                GeoItem, OwnPerms, ValueGetter, ShortMenuItem, +                GeoItem, OwnPerms, ValueGetter, MainItem,                  DashboardFormItem, RelationItem):      SLUG = 'operation'      APP = "archaeological-operations" @@ -782,6 +782,13 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,              'drassm_code__iexact'          ),      } +    QA_EDIT = QuickAction( +        url="operation-qa-bulk-update", icon_class="fa fa-pencil", +        text=_(u"Bulk update"), target="many", +        rights=['change_operation', 'change_own_operation']) +    QUICK_ACTIONS = [ +        QA_EDIT +    ]      UP_MODEL_QUERY = {          "site": (pgettext_lazy("key for text search", u"site"), diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py index fe2480940..1cb66de6f 100644 --- a/archaeological_operations/urls.py +++ b/archaeological_operations/urls.py @@ -167,4 +167,13 @@ urlpatterns = [      url(r'operation_administrativeact_document/$',          views.administrativeactfile_document,          name='operation-administrativeact-document'), + +    url(r'^operation-qa-bulk-update/(?P<pks>[0-9-]+)?/$', +        check_rights(['change_operation', 'change_own_operation'])( +            views.QAOperationForm.as_view()), +        name='operation-qa-bulk-update'), +    url(r'^operation-qa-bulk-update/(?P<pks>[0-9-]+)?/confirm/$', +        check_rights(['change_operation', 'change_own_operation'])( +            views.QAOperationForm.as_view()), +        name='operation-qa-bulk-update-confirm', kwargs={"confirm": True}),  ] diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index 5cf53fcbe..b7ff857b4 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -40,7 +40,7 @@ from archaeological_operations.forms import ArchaeologicalSiteForm, \      AdministrativeActOpeModifForm, FinalAdministrativeActDeleteForm, \      AdministrativeActRegisterFormSelection, DocumentGenerationAdminActForm, \      SiteForm, SiteTownFormset, SiteUnderwaterForm, check_underwater_module, \ -    CourtOrderedSeizureForm, SiteSelect, OperationSelect +    CourtOrderedSeizureForm, SiteSelect, OperationSelect, QAOperationFormMulti  from archaeological_operations.wizards import has_associated_file, \      is_preventive, is_judiciary, OperationWizard, OperationModificationWizard, \      OperationClosingWizard, OperationDeletionWizard, SiteSearch, \ @@ -52,7 +52,7 @@ from ishtar_common.forms import ClosingDateFormSelection, FinalForm, \  from ishtar_common.models import get_current_profile, IshtarSiteProfile, \      DocumentTemplate  from ishtar_common.utils import put_session_message, check_rights_condition -from ishtar_common.views import gen_generate_doc +from ishtar_common.views import gen_generate_doc, QAItemEditForm  from ishtar_common.views_item import get_item, show_item, revert_item, new_item  from ishtar_common.wizards import SearchWizard @@ -552,3 +552,8 @@ def reset_wizards(request):              (AdministrativeActDeletionWizard,               'operation_administrativeactop_deletion'),):          wizard_class.session_reset(request, url_name) + + +class QAOperationForm(QAItemEditForm): +    model = models.Operation +    form_class = QAOperationFormMulti diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index c7e3fe38c..cfdd531d9 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -824,10 +824,15 @@ class QAForm(CustomForm, ManageOldType):                      elif hasattr(self.fields[k], "choices"):                          values = []                          for v in kwargs['data'].getlist(k): -                            dct_choices = dict(self.fields[k].choices) -                            if v in dct_choices: +                            dct_choices = {} +                            for key, value in self.fields[k].choices: +                                if isinstance(value, (list, tuple)): +                                    dct_choices.update(value) +                                else: +                                    dct_choices[key] = value +                            if v in list(dct_choices.keys()):                                  values.append(unicode(dct_choices[v])) -                            elif int(v) in dct_choices: +                            elif int(v) in list(dct_choices.keys()):                                  values.append(unicode(dct_choices[int(v)]))                          self.fields[k].rendered_value = mark_safe(                              u" ; ".join(values)) | 
