diff options
4 files changed, 18 insertions, 8 deletions
| diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index 12e9f4949..fc0cbb35c 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -59,19 +59,21 @@ def get_warehouse_field(label=_("Warehouse"), required=True):  class SelectedDivisionForm(ManageOldType, forms.Form): -    form_label = _("Division") +    form_label = _("Default divisions")      base_model = 'associated_division'      associated_models = {'container_type': models.ContainerType,                           'associated_division': models.WarehouseDivisionLink}      container_type = forms.ChoiceField( -        label=_("Container type"), choices=(), +        label=_("Division type"), choices=(),          validators=[valid_id(models.ContainerType)]) -    order = forms.IntegerField(label=_("Order"), min_value=0, required=False) +    order = forms.IntegerField(label=_("Order"), min_value=0, +                               required=False)      def __init__(self, *args, **kwargs):          super(SelectedDivisionForm, self).__init__(*args, **kwargs)          self.fields['container_type'].choices = \              models.ContainerType.get_types( +                dct={"stationary": True},                  initial=self.init_data.get('container_type')) diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 0a05320fa..4b7201bcc 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -193,7 +193,7 @@ class Warehouse(Address, DocumentItem, GeoItem, QRCodeItem, DashboardFormItem,          self.save()      @property -    def location_types(self): +    def division_labels(self):          if not self.max_division_number:              return []          return [ @@ -202,6 +202,14 @@ class Warehouse(Address, DocumentItem, GeoItem, QRCodeItem, DashboardFormItem,          ]      @property +    def default_location_types(self): +        return [ +           wd.container_type.label +           for wd in WarehouseDivisionLink.objects.filter( +               warehouse=self).order_by('order').all() if wd.container_type +        ] + +    @property      def associated_filename(self):          return datetime.date.today().strftime('%Y-%m-%d') + '-' + \              slugify(str(self)) diff --git a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html index b6f93cc57..aec248b07 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html +++ b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html @@ -64,7 +64,7 @@              {% field_flex_detail "Person in charge" item.person_in_charge %}              {% field_flex_detail "Organization" item.organization %}              {% trans "Default divisions" as def_div_label %} -            {% field_flex def_div_label item.location_types|join:", " %} +            {% field_flex def_div_label item.default_location_types|join:", " %}              {% field_flex_full "Comment" item.comment "<pre>" "</pre>" %}              {% include "ishtar/blocks/sheet_json.html" %}          </div> @@ -136,7 +136,7 @@          <table class='table table-striped datatables'                 id="{{window_id}}-find-by-loca-{{forloop.counter}}">              <thead> -            <tr>{% for location_type in item.location_types %} +            <tr>{% for location_type in item.division_labels %}                  <th class="text-center">{{location_type|title}}</th>{% endfor %}                  <th class="text-center">{% trans "Total" %}</th>              </tr> @@ -167,7 +167,7 @@          <table class='table table-striped datatables'                 id="{{window_id}}-container-by-loca-{{forloop.counter}}">              <thead> -            <tr>{% for location_type in item.location_types %} +            <tr>{% for location_type in item.division_labels %}                  <th class="text-center">{{location_type|title}}</th>{% endfor %}                  <th class="text-center">{% trans "Total" %}</th>              </tr> diff --git a/archaeological_warehouse/templates/ishtar/wizard/wizard_warehouse_divisions.html b/archaeological_warehouse/templates/ishtar/wizard/wizard_warehouse_divisions.html index 2b11e9235..9f1e29708 100644 --- a/archaeological_warehouse/templates/ishtar/wizard/wizard_warehouse_divisions.html +++ b/archaeological_warehouse/templates/ishtar/wizard/wizard_warehouse_divisions.html @@ -3,6 +3,6 @@  {% block form_head %}  <div class="alert alert-info">    <i class="fa fa-exclamation-triangle"></i> -  {% trans "Default division for this warehouse. Theses divisions are only used for imports and statistics." %}<br/> +   {% trans "Default division for this warehouse. Theses divisions are only used to facilitate imports." %}<br/>  </div>  {% endblock %} | 
