summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-05-17 11:15:07 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-05-17 11:15:07 +0200
commite25ebecf8304b927ad8e75aefa1e1886dab2efeb (patch)
tree09c957b3837760d776657df6f517fed7898b6c5c
parent5960b5165179fa68cab83657cce6b936fcda1fc5 (diff)
downloadIshtar-e25ebecf8304b927ad8e75aefa1e1886dab2efeb.tar.bz2
Ishtar-e25ebecf8304b927ad8e75aefa1e1886dab2efeb.zip
Operation wizard: collaborators in a specific panel (refs #3595)
-rw-r--r--archaeological_operations/forms.py16
-rw-r--r--archaeological_operations/views.py2
-rw-r--r--ishtar_common/widgets.py6
3 files changed, 19 insertions, 5 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index 86bea4ed5..b9e68980f 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -759,11 +759,9 @@ class DashboardForm(forms.Form):
class OperationFormGeneral(ManageOldType, forms.Form):
form_label = _(u"General")
- base_models = ['collaborator']
file_upload = True
associated_models = {'scientist': Person,
'in_charge': Person,
- 'collaborator': Person,
'cira_rapporteur': Person,
'operator': Organization,
'operation_type': models.OperationType,
@@ -819,8 +817,6 @@ class OperationFormGeneral(ManageOldType, forms.Form):
limit={'person_types': [person_type_pk_lazy('sra_agent')]},
new=True),
validators=[valid_id(Person)], required=False)
- collaborator = widgets.Select2MultipleField(
- model=Person, label=_("Collaborators"), required=False, remote=True)
surface = forms.IntegerField(
required=False, widget=widgets.AreaWidget,
label=_(u"Total surface (m2)"),
@@ -989,6 +985,18 @@ OperationFormModifGeneral.associated_models = \
OperationFormModifGeneral.associated_models['associated_file'] = File
+class CollaboratorForm(forms.Form):
+ form_label = _(u"Collaborators")
+ base_models = ['collaborator']
+ associated_models = {'collaborator': Person, }
+ collaborator = widgets.Select2MultipleField(
+ model=Person, label=_("Collaborators"), required=False, remote=True)
+
+ def __init__(self, *args, **kwargs):
+ super(CollaboratorForm, self).__init__(*args, **kwargs)
+ self.fields['collaborator'].widget.attrs['style'] = 'width: 100%'
+
+
class OperationFormPreventive(forms.Form):
form_label = _(u"Preventive informations - excavation")
cost = forms.IntegerField(label=_(u"Cost (euros)"), required=False)
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index 9b420f594..24271bb8f 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -171,6 +171,7 @@ operation_search_wizard = SearchWizard.as_view(
wizard_steps = [
('filechoice-operation_creation', OperationFormFileChoice),
('general-operation_creation', OperationFormGeneral),
+ ('collaborators-operation_creation', CollaboratorForm),
('archaeologicalsite-operation_creation', ArchaeologicalSiteFormSet),
('preventive-operation_creation', OperationFormPreventive),
('preventivediag-operation_creation', OperationFormPreventiveDiag),
@@ -227,6 +228,7 @@ operation_creation_wizard = OperationWizard.as_view(
operation_modif_wizard_steps = [
('selec-operation_modification', OperationFormSelection),
('general-operation_modification', OperationFormModifGeneral),
+ ('collaborators-operation_modification', CollaboratorForm),
('archaeologicalsite-operation_modification', ArchaeologicalSiteFormSet),
('preventive-operation_modification', OperationFormPreventive),
('preventivediag-operation_modification', OperationFormPreventiveDiag),
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py
index b0f28a6cf..12db821c5 100644
--- a/ishtar_common/widgets.py
+++ b/ishtar_common/widgets.py
@@ -82,12 +82,16 @@ class Select2Multiple(forms.SelectMultiple):
self.remote = None
if not choices and not self.remote and self.model:
choices = self.get_choices()
+ new_attrs = self.attrs.copy()
+ new_attrs.update(attrs)
+ attrs = new_attrs
klass = attrs and attrs.get('class') or ''
klass += ' ' if klass else '' + 'js-select2'
if not attrs:
attrs = {}
attrs['class'] = klass
- attrs['style'] = "width: 370px"
+ if 'style' not in attrs:
+ attrs['style'] = "width: 370px"
options = ""
if self.remote:
options = """{