diff options
| -rw-r--r-- | archaeological_warehouse/models.py | 10 | ||||
| -rw-r--r-- | archaeological_warehouse/templates/ishtar/sheet_warehouse.html | 42 | ||||
| -rw-r--r-- | ishtar_common/static/js/ishtar.js | 5 | ||||
| -rw-r--r-- | version.py | 4 | 
4 files changed, 51 insertions, 10 deletions
| diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 8bd6d2944..852b64706 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -181,8 +181,7 @@ class Warehouse(Address, DashboardFormItem, OwnPerms):              q = model.objects              cpath = []              for division, ref in path: -                lbl = u"{} {}".format(division.division, ref) -                cpath.append(lbl) +                cpath.append(ref)                  attrs = {                      division_key + "__division": division,                      division_key + "__reference": ref @@ -192,12 +191,17 @@ class Warehouse(Address, DashboardFormItem, OwnPerms):                      res[tuple(cpath)] = q.count()          res = [(k, res[k]) for k in res]          final_res, current_res, depth = [], [], 1 +        len_divisions = WarehouseDivisionLink.objects.filter( +            warehouse=self).count()          for path, nb in sorted(res, key=lambda x: (len(x[0]), x[0])):              if depth != len(path):                  final_res.append(current_res[:])                  current_res = []                  depth = len(path) -            current_res.append((u" | ".join(path), nb)) +            if path[-1] == '-': +                continue +            path = list(path) + ['' for idx in range(len_divisions - len(path))] +            current_res.append((path, nb))          final_res.append(current_res[:])          return final_res diff --git a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html index 61553b839..b3446c15a 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html +++ b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html @@ -62,13 +62,22 @@  {% if item.number_of_finds_by_place %}  <h4>{% trans "Finds by location in the warehouse" %}</h4>  {% for items in item.number_of_finds_by_place %} -<table class='table table-striped'> +<table class='table table-striped datatables' +       id="{{window_id}}-find-by-loca-{{forloop.counter}}"> +    <thead> +    <tr>{% for location_type in item.location_types %} +        <th class="text-center">{{location_type|title}}</th>{% endfor %} +        <th class="text-center">{% trans "Total" %}</th> +    </tr> +    </thead> +    <tbody>      {% for item in items %}      <tr> -        <th>{{item.0}}</th> +        {% for local in item.0 %}<td>{{local}}</td>{% endfor %}          <td class="text-right">{{item.1}}</td>      </tr>      {% endfor %} +    </tbody>  </table>  {% endfor %}  {% endif %} @@ -82,15 +91,38 @@  {% if item.number_of_containers_by_place %}  <h4>{% trans "Containers by location in the warehouse" %}</h4>  {% for items in item.number_of_containers_by_place %} -<table class='table table-striped'> +<table class='table table-striped datatables' +       id="{{window_id}}-container-by-loca-{{forloop.counter}}"> +    <thead> +    <tr>{% for location_type in item.location_types %} +        <th class="text-center">{{location_type|title}}</th>{% endfor %} +        <th class="text-center">{% trans "Total" %}</th> +    </tr> +    </thead> +    <tbody>      {% for item in items %}      <tr> -        <th>{{item.0}}</th> -        <td class="text-right">{{item.1}}</td> +        {% for local in item.0 %}<td class="text-center">{{local}}</td>{% endfor %} +        <td class="text-center">{{item.1}}</td>      </tr>      {% endfor %} +    </tbody>  </table>  {% endfor %}  {% endif %} +<script type="text/javascript"> +$(document).ready( function () { +    datatable_options = { +        "dom": 'ltip', +    }; +    $.extend(datatable_options, datatables_static_default); +    if (datatables_i18n) datatable_options['language'] = datatables_i18n; +    $('.datatables').each( +        function(){ +            $("#" + $(this).attr('id')).DataTable(datatable_options); +         }); +} ); +</script> +  {% endblock %} diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index c6f25920a..936ce4f11 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -55,6 +55,11 @@ var datatables_default = {      "scrollCollapse": true  }; +var datatables_static_default = { +    "searching": false, +    "scrollCollapse": true +}; +  var advanced_menu = false;  var shortcut_menu_hide = false;  var activate_all_search_url = '/activate-all-search/'; diff --git a/version.py b/version.py index 9c10f178a..30a113629 100644 --- a/version.py +++ b/version.py @@ -1,5 +1,5 @@ -# 2.1.dev.7 -VERSION = (2, 1, 'dev', 7) +# 2.1.dev.8 +VERSION = (2, 1, 'dev', 8)  def get_version(): | 
