diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-11-16 19:07:13 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-11-28 11:40:17 +0100 | 
| commit | 6d1beb3e0bda4786d5577a8c1498042b96421fa0 (patch) | |
| tree | f6192505b4a80cdc63a00ca6938fd2300a9a3071 | |
| parent | cce8c95c54c6d29d94a9e82acc9d54dcb4c20500 (diff) | |
| download | Ishtar-6d1beb3e0bda4786d5577a8c1498042b96421fa0.tar.bz2 Ishtar-6d1beb3e0bda4786d5577a8c1498042b96421fa0.zip  | |
Treatment n->1: base forms
| -rw-r--r-- | archaeological_finds/forms.py | 98 | ||||
| -rw-r--r-- | archaeological_finds/forms_treatments.py | 14 | ||||
| -rw-r--r-- | archaeological_finds/ishtar_menu.py | 19 | ||||
| -rw-r--r-- | archaeological_finds/urls.py | 5 | ||||
| -rw-r--r-- | archaeological_finds/views.py | 16 | ||||
| -rw-r--r-- | ishtar_common/templates/blocks/action_list.html | 4 | 
6 files changed, 143 insertions, 13 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 4df6629e1..a221247e0 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -43,7 +43,7 @@ from archaeological_finds.forms_treatments import TreatmentSelect, \      AdministrativeActTreatmentFileForm, \      AdministrativeActTreatmentFileFormSelection, \      AdministrativeActTreatmentFileModifForm, \ -    DashboardForm as DashboardTreatmentForm, \ +    DashboardForm as DashboardTreatmentForm, N1TreatmentForm,\      DashboardTreatmentFileForm, QAFindTreatmentForm  from archaeological_operations.models import Period, ArchaeologicalSite, \      RelationType as OpeRelationType @@ -82,7 +82,8 @@ __all__ = [      'FindDeletionForm', 'UpstreamFindFormSelection', 'NewFindBasketForm',      'SelectFindBasketForm', 'DeleteFindBasketForm', 'FindBasketAddItemForm',      'QAFindFormSingle', 'QAFindFormMulti', 'QAFindBasketForm', -    'QAFindTreatmentForm' +    'QAFindTreatmentForm', +    'N1TreatmentForm', 'ResultingFindForm'  ]  logger = logging.getLogger(__name__) @@ -319,6 +320,99 @@ class FindForm(CustomForm, ManageOldType):          return self.cleaned_data +class ResultingFindForm(CustomForm, ManageOldType): +    file_upload = True +    form_label = _("Resulting find") +    form_admin_name = _(u"Treatment n-1 - 030 - General") +    form_slug = "treatmentn1-030-general" + +    base_models = ['object_type', 'material_type', 'communicabilitie'] +    associated_models = { +        'material_type': models.MaterialType, +        'object_type': models.ObjectType, +        'communicabilitie': models.CommunicabilityType, +        'material_type_quality': models.MaterialTypeQualityType, +        'object_type_quality': models.ObjectTypeQualityType, +        'checked_type': models.CheckedType, +    } +    HEADERS = {} +    HEADERS['label'] = FormHeader(_(u"Identification")) + +    label = forms.CharField( +        label=_(u"Free ID"), +        validators=[validators.MaxLengthValidator(60)]) +    denomination = forms.CharField(label=_(u"Denomination"), required=False) +    previous_id = forms.CharField(label=_("Previous ID"), required=False) +    museum_id = forms.CharField(label=_(u"Museum ID"), required=False) +    seal_number = forms.CharField(label=_(u"Seal number"), required=False) +    mark = forms.CharField(label=_(u"Mark"), required=False) + +    HEADERS['description'] = FormHeader(_(u"Description")) +    description = forms.CharField(label=_(u"Description"), +                                  widget=forms.Textarea, required=False) +    is_complete = forms.NullBooleanField(label=_(u"Is complete?"), +                                         required=False) +    material_type = widgets.Select2MultipleField( +        label=_(u"Material types"), required=False +    ) +    material_type_quality = forms.ChoiceField( +        label=_(u"Material type quality"), required=False, choices=[]) +    object_type = widgets.Select2MultipleField( +        label=_(u"Object types"), required=False, +    ) +    object_type_quality = forms.ChoiceField( +        label=_(u"Object type quality"), required=False, choices=[]) +    find_number = forms.IntegerField(label=_(u"Find number"), required=False) +    min_number_of_individuals = forms.IntegerField( +        label=_(u"Minimum number of individuals (MNI)"), required=False) + +    decoration = forms.CharField(label=_(u"Decoration"), widget=forms.Textarea, +                                 required=False) +    inscription = forms.CharField(label=_(u"Inscription"), +                                  widget=forms.Textarea, required=False) +    manufacturing_place = forms.CharField( +        label=_(u"Manufacturing place"), required=False) +    communicabilitie = widgets.Select2MultipleField( +        label=_(u"Communicability"), required=False +    ) +    comment = forms.CharField(label=_(u"Comment"), required=False, +                              widget=forms.Textarea) +    dating_comment = forms.CharField( +        label=_(u"Comment on dating"), required=False, widget=forms.Textarea) + +    HEADERS['length'] = FormHeader(_(u"Dimensions")) +    length = FloatField(label=_(u"Length (cm)"), required=False) +    width = FloatField(label=_(u"Width (cm)"), required=False) +    height = FloatField(label=_(u"Height (cm)"), required=False) +    diameter = FloatField(label=_(u"Diameter (cm)"), required=False) +    thickness = FloatField(label=_(u"Thickness (cm)"), required=False) +    volume = FloatField(label=_(u"Volume (l)"), required=False) +    weight = FloatField(label=_(u"Weight (g)"), required=False) +    clutter_long_side = FloatField( +        label=_(u"Clutter long side (cm)"), required=False) +    clutter_short_side = FloatField( +        label=_(u"Clutter short side (cm)"), required=False) +    clutter_height = FloatField( +        label=_(u"Clutter height (cm)"), required=False) +    dimensions_comment = forms.CharField( +        label=_(u"Dimensions comment"), required=False, widget=forms.Textarea) + +    HEADERS['checked_type'] = FormHeader(_(u"Sheet")) +    checked_type = forms.ChoiceField(label=_(u"Check"), required=False) +    check_date = forms.DateField( +        initial=get_now, label=_(u"Check date"), widget=DatePicker) + +    TYPES = [ +        FieldType('material_type', models.MaterialType, is_multiple=True), +        FieldType('material_type_quality', models.MaterialTypeQualityType), +        FieldType('object_type', models.ObjectType, is_multiple=True), +        FieldType('object_type_quality', models.ObjectTypeQualityType), +        FieldType('communicabilitie', models.CommunicabilityType, +                  is_multiple=True), +        FieldType('checked_type', models.CheckedType, is_multiple=True), +    ] + +  class QAFindFormMulti(QAForm):      form_admin_name = _(u"Find - Quick action - Modify")      form_slug = "find-quickaction-modify" diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py index 248b1ef7d..99a685825 100644 --- a/archaeological_finds/forms_treatments.py +++ b/archaeological_finds/forms_treatments.py @@ -230,6 +230,20 @@ class BaseTreatmentForm(CustomForm, ManageOldType):          """ +class N1TreatmentForm(BaseTreatmentForm): +    form_label = _(u"Base treatment") +    form_admin_name = _(u"Treatment n-1 - 020 - General") +    form_slug = "treatmentn1-020-general" + +    TYPES = [ +        FieldType('treatment_state', models.TreatmentState), +        FieldType( +            'treatment_type', models.TreatmentType, is_multiple=True, +            extra_args={'dct': {'upstream_is_many': True, +                                'downstream_is_many': False}}) +    ] + +  class TreatmentModifyForm(BaseTreatmentForm):      index = forms.IntegerField(_(u"Index"))      id = forms.IntegerField(' ', widget=forms.HiddenInput, required=False) diff --git a/archaeological_finds/ishtar_menu.py b/archaeological_finds/ishtar_menu.py index 19d300fbc..cd7ed19b7 100644 --- a/archaeological_finds/ishtar_menu.py +++ b/archaeological_finds/ishtar_menu.py @@ -153,11 +153,20 @@ MENU_SECTIONS = [                        model=models.Treatment,                        access_controls=['view_treatment',                                         'view_own_treatment']), -             MenuItem('treatment_creation', -                      _(u"Simple treatment - creation"), -                      model=models.Treatment, -                      access_controls=['change_treatment', -                                       'change_own_treatment']), +             MenuItem( +                 'treatment_creation', +                 _(u"Treatment " +                   u"1 <i class='fa fa-arrows-h' aria-hidden='true'></i> 1 " +                   u"- creation"), +                 model=models.Treatment, +                 access_controls=['change_find', 'change_own_find']), +             MenuItem( +                 'treatment_creation_n1', +                 _(u"Treatment " +                   u"n <i class='fa fa-arrows-h' aria-hidden='true'></i> 1 " +                   u"- creation"), +                 model=models.Treatment, +                 access_controls=['change_find', 'change_own_find']),               MenuItem('treatment_modification',                        _(u"Modification"),                        model=models.Treatment, diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py index 588c8d520..b9f4d8b6c 100644 --- a/archaeological_finds/urls.py +++ b/archaeological_finds/urls.py @@ -100,10 +100,13 @@ urlpatterns = [              views.QAFindTreatmentFormView.as_view()),          name='find-qa-packaging'), -      url(r'^treatment_creation/(?P<step>.+)?$',          check_rights(['change_find', 'change_own_find'])(              views.treatment_creation_wizard), name='treatment_creation'), +    url(r'^treatment_creation_n1/(?P<step>.+)?$', +        check_rights(['change_find', 'change_own_find'])( +            views.treatment_creation_n1_wizard), name='treatment_creation_n1'), +      url(r'^treatment_modification/(?P<step>.+)?$',          check_rights(['change_find', 'change_own_find'])(              views.treatment_modification_wizard), diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index c4dbe0d3d..789c420de 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -408,9 +408,6 @@ treatment_wizard_steps = [      ('selecfind-treatment_creation', UpstreamFindFormSelection),      ('file-treatment_creation', TreatmentFormFileChoice),      ('basetreatment-treatment_creation', BaseTreatmentForm), -    # ('selecbasket-treatment_creation', SelectFindBasketForm), -    # ('resultfind-treatment_creation', ResultFindForm), -    # ('resultfinds-treatment_creation', ResultFindFormSet),      ('final-treatment_creation', FinalForm)  ] @@ -444,6 +441,19 @@ treatment_creation_wizard = TreatmentWizard.as_view(      label=_(u"New treatment"),      url_name='treatment_creation',) +treatment_n1_wizard_steps = [ +    ('selecfind-treatment_creation_n1', UpstreamFindFormSelection), +    ('file-treatment_creation_n1', TreatmentFormFileChoice), +    ('basetreatment-treatment_creation_n1', N1TreatmentForm), +    ('resultingfind-treatment_creation_n1', ResultingFindForm), +    ('final-treatment_creation_n1', FinalForm) +] + +treatment_creation_n1_wizard = TreatmentWizard.as_view( +    treatment_n1_wizard_steps, +    label=_(u"New treatment"), +    url_name='treatment_creation_n1',) +  treatment_modification_wizard = TreatmentModificationWizard.as_view(      [('selec-treatment_modification', TreatmentFormSelection),       ('file-treatment_modification', TreatmentFormFileChoice), diff --git a/ishtar_common/templates/blocks/action_list.html b/ishtar_common/templates/blocks/action_list.html index 50a6554c4..384082ad4 100644 --- a/ishtar_common/templates/blocks/action_list.html +++ b/ishtar_common/templates/blocks/action_list.html @@ -1,12 +1,12 @@  <li class="nav-item dropdown">      <a class="nav-link dropdown-toggle"         data-toggle="dropdown" href="#" role="button" aria-haspopup="true" -       aria-expanded="false">{{section_label}}</a> +       aria-expanded="false">{{section_label|safe}}</a>      <div class="dropdown-menu">          {% for label, url, has_children in sections %}          <a class="dropdown-item{% if has_children%} font-weight-bold{%endif%}" href="{{url}}"> -            {{ label }} +            {{ label|safe }}          </a>{% endfor %}      </div>  </li>  | 
