diff options
| -rw-r--r-- | archaeological_context_records/wizards.py | 2 | ||||
| -rw-r--r-- | archaeological_finds/models_treatments.py | 1 | ||||
| -rw-r--r-- | archaeological_operations/forms.py | 66 | ||||
| -rw-r--r-- | archaeological_operations/views.py | 11 | ||||
| -rw-r--r-- | archaeological_operations/wizards.py | 13 | 
5 files changed, 52 insertions, 41 deletions
| diff --git a/archaeological_context_records/wizards.py b/archaeological_context_records/wizards.py index c880f2a4f..8338f8b23 100644 --- a/archaeological_context_records/wizards.py +++ b/archaeological_context_records/wizards.py @@ -154,5 +154,5 @@ class RecordDeletionWizard(MultipleDeletionWizard):                'depth', 'location', 'datings', 'units', 'documentations',                'filling', 'interpretation', 'taq', 'taq_estimated', 'tpq',                'tpq_estimated'] -    filter_owns = {'selec-record_deletion': ['pk']} +    filter_owns = {'selec-record_deletion': ['pks']}      redirect_url = "record_deletion" diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 07eeef260..52db8cabe 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -68,7 +68,6 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem,                  BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):      SLUG = 'treatment'      SHOW_URL = 'show-treatment' -    DELETE_URL = 'delete-treatment'      TABLE_COLS = ('year', 'index', 'treatment_types__label',                    'treatment_state__label',                    'label', 'person__cached_label', diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 3bef38a9c..3c93b945c 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -40,9 +40,10 @@ 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, QAForm, CustomFormSearch,\ -    ManageOldType, IshtarForm, CustomForm, FieldType, FormHeader, HistorySelect +    ManageOldType, IshtarForm, CustomForm, FieldType, FormHeader, \ +    HistorySelect, LockForm, MultiSearchForm  from ishtar_common.forms_common import TownFormSet, get_town_field, TownForm -from ishtar_common.models import valid_id, Person, Town, \ +from ishtar_common.models import valid_id, valid_ids, Person, Town, \      DocumentTemplate, Organization, get_current_profile, \      person_type_pks_lazy, person_type_pk_lazy, organization_type_pks_lazy, \      organization_type_pk_lazy, SpatialReferenceSystem, Area @@ -599,7 +600,7 @@ class OperationSelect(HistorySelect):                  ('', '--')] + list(settings.ISHTAR_DPTS) -class OperationFormSelection(CustomFormSearch): +class OperationFormSelection(LockForm, CustomFormSearch):      SEARCH_AND_SELECT = True      form_label = _(u"Operation search")      associated_models = {'pk': models.Operation} @@ -612,19 +613,19 @@ class OperationFormSelection(CustomFormSearch):              source_full=reverse_lazy('get-operation-full')),          validators=[valid_id(models.Operation)]) -    def clean(self): -        cleaned_data = self.cleaned_data -        if 'pk' not in cleaned_data or not cleaned_data['pk']: -            raise forms.ValidationError(_(u"You should select an operation.")) -        pk = self.cleaned_data["pk"] -        try: -            item = models.Operation.objects.get(pk=pk) -        except models.Operation.DoesNotExist: -            raise forms.ValidationError(_("Invalid selection.")) -        if item.locked: -            raise forms.ValidationError(_("This operation is locked for " -                                          "edition.")) -        return self.cleaned_data + +class OperationFormMultiSelection(LockForm, MultiSearchForm): +    form_label = _(u"Operation search") +    associated_models = {'pks': models.Operation} +    pk_key = 'pks' +    pk = forms.CharField( +        label="", required=False, +        widget=widgets.DataTable( +            reverse_lazy('get-operation'), OperationSelect, models.Operation, +            gallery=True, map=True, +            multiple_select=True, +            source_full=reverse_lazy('get-operation-full')), +        validators=[valid_ids(models.Operation)])  class OperationCodeInput(forms.TextInput): @@ -1307,6 +1308,7 @@ ArchaeologicalSiteFormSet.extra_form_modals = ["archaeologicalsite"]  class ArchaeologicalSiteSelectionForm(IshtarForm): +    # TODO: used?      form_label = _("Associated archaeological sites")      archaeological_sites = forms.IntegerField(          widget=widgets.JQueryAutoComplete( @@ -1401,7 +1403,7 @@ class SiteSelect(HistorySelect):              self.fields.pop('drassm_number') -class SiteFormSelection(CustomFormSearch): +class SiteFormSelection(LockForm, CustomFormSearch):      SEARCH_AND_SELECT = True      associated_models = {'pk': models.ArchaeologicalSite}      currents = {'pk': models.ArchaeologicalSite} @@ -1418,19 +1420,23 @@ class SiteFormSelection(CustomFormSearch):      def form_label(cls):          return get_current_profile().get_site_label('search') -    def clean(self): -        cleaned_data = self.cleaned_data -        if 'pk' not in cleaned_data or not cleaned_data['pk']: -            raise forms.ValidationError(_(u"You should select an item.")) -        pk = self.cleaned_data["pk"] -        try: -            item = models.ArchaeologicalSite.objects.get(pk=pk) -        except models.ArchaeologicalSite.DoesNotExist: -            raise forms.ValidationError(_("Invalid selection.")) -        if item.locked: -            raise forms.ValidationError(_("This site is locked for " -                                          "edition.")) -        return self.cleaned_data + +class SiteFormMultiSelection(LockForm, MultiSearchForm): +    associated_models = {'pks': models.ArchaeologicalSite} + +    pk = forms.CharField( +        label="", required=False, +        widget=widgets.DataTable( +            reverse_lazy('get-site'), SiteSelect, +            models.ArchaeologicalSite, +            gallery=True, map=True, +            multiple_select=True, +            source_full=reverse_lazy('get-site-full')), +        validators=[valid_ids(models.ArchaeologicalSite)]) + +    @classmethod +    def form_label(cls): +        return get_current_profile().get_site_label('search')  class SiteForm(CustomForm, ManageOldType): diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index d71bd0d02..8bc805b7a 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -40,7 +40,8 @@ from archaeological_operations.forms import ArchaeologicalSiteForm, \      AdministrativeActOpeModifForm, FinalAdministrativeActDeleteForm, \      AdministrativeActRegisterFormSelection, DocumentGenerationAdminActForm, \      SiteForm, SiteTownFormset, SiteUnderwaterForm, check_underwater_module, \ -    CourtOrderedSeizureForm, SiteSelect, OperationSelect, QAOperationFormMulti +    CourtOrderedSeizureForm, SiteSelect, OperationSelect, \ +    QAOperationFormMulti, OperationFormMultiSelection, SiteFormMultiSelection  from archaeological_operations.wizards import has_associated_file, \      is_preventive, is_judiciary, OperationWizard, OperationModificationWizard, \      OperationClosingWizard, OperationDeletionWizard, SiteSearch, \ @@ -332,7 +333,7 @@ operation_closing_wizard = OperationClosingWizard.as_view(  operation_deletion_steps = [ -    ('selec-operation_deletion', OperationFormSelection), +    ('selec-operation_deletion', OperationFormMultiSelection),      ('final-operation_deletion', OperationDeletionForm)  ] @@ -349,7 +350,7 @@ def operation_delete(request, pk):      wizard_url = 'operation_deletion'      OperationDeletionWizard.session_set_value( -        request, 'selec-' + wizard_url, 'pk', pk, reset=True) +        request, 'selec-' + wizard_url, 'pks', pk, reset=True)      return redirect(reverse(wizard_url,                              kwargs={'step': 'final-' + wizard_url})) @@ -414,7 +415,7 @@ def site_modify(request, pk):  site_deletion_steps = [ -    ('selec-site_deletion', SiteFormSelection), +    ('selec-site_deletion', SiteFormMultiSelection),      ('final-site_deletion', FinalDeleteForm)  ] @@ -430,7 +431,7 @@ def site_delete(request, pk):          return HttpResponseRedirect("/")      wizard_url = 'site_deletion'      SiteDeletionWizard.session_set_value( -        request, 'selec-' + wizard_url, 'pk', pk, reset=True) +        request, 'selec-' + wizard_url, 'pks', pk, reset=True)      return redirect(reverse(wizard_url,                              kwargs={'step': 'final-' + wizard_url})) diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index 140a2a03a..d5230fa16 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -32,7 +32,7 @@ from .forms import GenerateDocForm  from ishtar_common.forms import reverse_lazy  from ishtar_common.models import get_current_profile  from ishtar_common.wizards import Wizard, ClosingWizard, DeletionWizard, \ -    SearchWizard +    SearchWizard, MultipleDeletionWizard  logger = logging.getLogger(__name__) @@ -52,6 +52,7 @@ class OperationWizard(Wizard):      multi_towns = False  # true if current town are multi valued      towns_formset = True  # true if towns are managed with formset      wizard_done_window = reverse_lazy('show-operation') +    redirect_url = "operation_modification"      def get_template_names(self):          templates = super(OperationWizard, self).get_template_names() @@ -297,10 +298,11 @@ class OperationClosingWizard(ClosingWizard):                'comment', 'towns', 'remains'] -class OperationDeletionWizard(DeletionWizard): +class OperationDeletionWizard(MultipleDeletionWizard):      model = models.Operation      fields = OperationClosingWizard.fields -    filter_owns = {'selec-operation_deletion': ['pk']} +    filter_owns = {'selec-operation_deletion': ['pks']} +    redirect_url = "operation_deletion"  class OperationAdministrativeActWizard(OperationWizard): @@ -308,6 +310,7 @@ class OperationAdministrativeActWizard(OperationWizard):      wizard_done_window = reverse_lazy('show-administrativeact')      current_obj_slug = 'administrativeactop'      ref_object_key = 'operation' +    redirect_url = "operation_administrativeactop_modification"      def get_reminder(self):          form_key = 'selec-' + self.url_name @@ -435,6 +438,7 @@ class SiteWizard(SiteLabel, Wizard):      SITE_KEY = 'new'      model = models.ArchaeologicalSite      wizard_done_window = reverse_lazy('show-site') +    redirect_url = "site_modification"  class SiteModificationWizard(SiteWizard): @@ -442,10 +446,11 @@ class SiteModificationWizard(SiteWizard):      modification = True -class SiteDeletionWizard(SiteLabel, DeletionWizard): +class SiteDeletionWizard(SiteLabel, MultipleDeletionWizard):      SITE_KEY = 'deletion'      model = models.ArchaeologicalSite      fields = models.ArchaeologicalSite.TABLE_COLS + ['operations'] +    redirect_url = "site_deletion"  class AdministrativeActDeletionWizard(ClosingWizard): | 
