diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-10-22 00:08:24 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-10-22 00:08:24 +0200 |
commit | 4ccbb4bef309571159c9558cca5da04987a68646 (patch) | |
tree | 3bedb956e0505accf622a6c42c94f3e613286bd6 /archaeological_operations | |
parent | 39e0c9cf302f8b468e116047eef18f42d712166e (diff) | |
download | Ishtar-4ccbb4bef309571159c9558cca5da04987a68646.tar.bz2 Ishtar-4ccbb4bef309571159c9558cca5da04987a68646.zip |
Djangoization - Major refactoring (step 15)
* works on dashboards
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/ishtar_menu.py | 13 | ||||
-rw-r--r-- | archaeological_operations/models.py | 2 | ||||
-rw-r--r-- | archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html | 510 | ||||
-rw-r--r-- | archaeological_operations/urls.py | 2 | ||||
-rw-r--r-- | archaeological_operations/views.py | 4 |
5 files changed, 528 insertions, 3 deletions
diff --git a/archaeological_operations/ishtar_menu.py b/archaeological_operations/ishtar_menu.py index faf749480..7790087d9 100644 --- a/archaeological_operations/ishtar_menu.py +++ b/archaeological_operations/ishtar_menu.py @@ -84,5 +84,16 @@ MENU_SECTIONS = [ 'change_own_operation']), ]) ]), - ) + ), + (102, SectionItem('dashboard', _(u"Dashboard"), + childs=[ + MenuItem('dashboard_main', _(u"General informations"), + model=models.File, + access_controls=['change_file', 'change_own_file']), + MenuItem('dashboard_operation', _(u"Operations"), + model=models.Operation, + access_controls=['change_operation', + 'change_own_operation']), + ]), + ), ] diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 831190342..082a0072d 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -645,6 +645,8 @@ class OperationDashboard: cost_means, cost_sums = [], [] for idx, year in enumerate(years): vals = [r_years[idx] for lbl, r_years in dct_res[res_key]] + if not vals: + continue sum_area = sum([a for a, c in vals]) sum_cost = sum([c for a, c in vals]) area_means.append(sum_area/len(vals)) diff --git a/archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html b/archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html new file mode 100644 index 000000000..28f1dd9c6 --- /dev/null +++ b/archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html @@ -0,0 +1,510 @@ +{% extends "base.html" %} +{% load i18n %} +{% load range %} +{% block extra_head %} +{{form.media}} +{% endblock %} +{% block content %} +<div class='dashboard'> + <h2>{% trans "Operations" %}</h2> + <div> + <h3>{% trans "Global informations" %}</h3> + + <div class='table'> + <table> + <caption>{% trans "Total" %}</caption> + <tr> + <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th> + </tr> + {% for lbl, nb in dashboard.total %} + <tr> + <th class='sub'>{{lbl}}</th><td>{{nb}}</td> + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Area by type of operation" %}</caption> + <tr> + <th>{% trans "Status" %}</th><th>{% trans "Area (m²)" %}</th> + </tr> + {% for surface in dashboard.surface_by_type %} + <tr> + <th class='sub'>{{surface.operation_type__label}}</th><td>{{surface.number}}</td> + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By types" %}</caption> + <tr> + <th>{% trans "State" %}</th>{%for typ in dashboard.types %}<th>{{typ.label}}</th>{% endfor %} + </tr> + {% for lbl, types in dashboard.by_type %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in types %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By year" %}</caption> + <tr> + <th>{% trans "State" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %} + </tr> + {% for lbl, years in dashboard.by_year %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By realisation year" %}</caption> + <tr> + <th>{% trans "State" %}</th>{%for yr in dashboard.realisation_years %}<th>{{yr.year}}</th>{% endfor %} + </tr> + {% for lbl, years in dashboard.by_realisation_year %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Effective operation by type and year" %}</caption> + <tr> + <th>{% trans "Type" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %} + </tr> + {% for lbl, years in dashboard.effective %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By realisation month" %}</caption> + <tr> + <th>{% trans "State" %}</th>{%for mt in dashboard.last_months %}<th>{{mt.date|date:"F Y"|capfirst}}</th>{% endfor %} + </tr> + {% for lbl, months in dashboard.by_realisation_month %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in months %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + </div> + <div> + + <h3>{% trans "Survey informations" %}</h3> + + <div class='table'> + <table> + <caption>{% trans "Total" %}</caption> + <tr> + <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th> + </tr> + {% for lbl, nb in dashboard.survey.total %} + <tr> + <th class='sub'>{{lbl}}</th><td>{{nb}}</td> + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By year" %}</caption> + <tr> + <th>{% trans "State" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %} + </tr> + {% for lbl, years in dashboard.survey.by_year %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By realisation year" %}</caption> + <tr> + <th>{% trans "State" %}</th>{%for yr in dashboard.realisation_years %}<th>{{yr.year}}</th>{% endfor %} + </tr> + {% for lbl, years in dashboard.survey.by_realisation_year %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Current year" %}</caption> + <tr> + <th>{% trans "Status" %}</th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%} + </tr> + <tr> + <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.survey.area %}<td>{{nb}}</td>{%endfor%} + </tr> + <tr> + <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.survey.manday %}<td>{{nb}}</td>{%endfor%} + </tr> + <tr> + <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.survey.mandayhect %}<td>{{nb}}</td>{%endfor%} + </tr> + </table></div> + + <p><strong>{% trans "Man-day/hectare for effective operations (current year):" %}</strong> {{dashboard.survey.mandayhect_effective}}</p> + + <div class='table'> + <table> + <caption>{% trans "Organizations (current year)" %}</caption> + <tr> + <th> </th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th> + </tr> + {% for org in dashboard.survey.org %} + <tr> + <th class='sub'>{{org.in_charge__attached_to__name}}</th><td>{{org.area}}</td><td>{{org.manday}}</td><td>{{org.mandayhect}}</td> + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Current realisation year" %}</caption> + <tr> + <th>{% trans "Status" %}</th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%} + </tr> + <tr> + <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.survey.area_realised %}<td>{{nb}}</td>{%endfor%} + </tr> + <tr> + <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.survey.manday_realised %}<td>{{nb}}</td>{%endfor%} + </tr> + <tr> + <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.survey.mandayhect_realised %}<td>{{nb}}</td>{%endfor%} + </tr> + </table></div> + + <p><strong>{% trans "Man-day/hectare for effective operations (current realisation year):" %}</strong> {{dashboard.survey.mandayhect_real_effective}}</p> + + <div class='table'> + <table> + <caption>{% trans "Organizations (current realisation year)" %}</caption> + <tr> + <th> </th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th> + </tr> + {% for org in dashboard.survey.org_realised %} + <tr> + <th class='sub'>{{org.in_charge__attached_to__name}}</th><td>{{org.area}}</td><td>{{org.manday}}</td><td>{{org.mandayhect}}</td> + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Area by organization by year" %}</caption> + <tr> + <th>{% trans "Organization" %}</th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} + </tr> + {% for org, vals in dashboard.survey.org_by_year %} + <tr> + <th class='sub'>{{org}}</th>{% for area, cost in vals %}<td>{{area}}</td>{% endfor %} + </tr> + {% endfor %} + <tr> + <th>{% trans "Mean" %}</th>{% for area in dashboard.survey.org_by_year_area_mean %}<td>{{area}}</td>{% endfor %} + </tr> + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Effective operations areas (m²)" %}</caption> + <tr> + <th> </th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} + </tr> + <tr> + <th>{% trans "Sum" %}</th>{% for nb, mean in dashboard.survey.effective %}<td>{{nb}}</td>{% endfor %} + </tr> + <tr> + <th>{% trans "Average" %}</th>{% for nb, avg in dashboard.survey.effective %}<td>{{avg}}</td>{% endfor %} + </tr> + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Man-Days/hectare by Year" %}</caption> + <tr> + <th> </th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} + </tr> + <tr> + <th>{% trans "Man-Days/hectare" %}</th>{% for nb, mean in dashboard.survey.mandayshect %}<td>{{nb}}</td>{% endfor %} + </tr> + <tr> + <th>{% trans "Average" %}</th>{% for nb, avg in dashboard.survey.mandayshect %}<td>{{avg}}</td>{% endfor %} + </tr> + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By month" %}</caption> + <tr> + <th>{% trans "State" %}</th>{%for mt in dashboard.last_months %}<th>{{mt.date|date:"F Y"|capfirst}}</th>{% endfor %} + </tr> + {% for lbl, months in dashboard.survey.by_month %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in months %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By department" %}</caption> + <tr> + <th>{% trans "Department" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %}<th>{% trans "Sum" %}</th> + </tr> + {% for lbl, years in dashboard.survey.by_dpt %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in years %}<td{%if forloop.last%} class='sub'{%endif%}>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Effective operation by department" %}</caption> + <tr> + <th rowspan='2'>{% trans "Department" %}</th>{%for yr in dashboard.years %}<th colspan='2'>{{yr}}</th>{% endfor %}<th colspan='2'>{% trans "Sum" %}</th> + </tr> + <tr> + {%for yr in dashboard.years %}<th>{%trans "Nb."%}</th><th>{%trans "Area"%}</th>{% endfor %}<th>{%trans "Nb."%}</th><th>{%trans "Area"%}</th> + </tr> + {% for lbl, years in dashboard.survey.effective_by_dpt %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb, area, cost, fnap in years %}<td{%if forloop.last%} class='sub'{%endif%}>{{nb}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{area}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Main towns by number" %}</caption> + <tr> + <th>{% trans "Town" %}</th><th>{% trans "Number" %}</th> + </tr> + {% for lbl, nb in dashboard.survey.towns %} + <tr> + <th class='sub'>{{lbl}}</th><td>{{nb}}</td> + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Main towns by surface" %}</caption> + <tr> + <th>{% trans "Town" %}</th><th>{% trans "Total surface (m²)" %}</th> + </tr> + {% for lbl, nb in dashboard.survey.towns_surface %} + <tr> + <th class='sub'>{{lbl}}</th><td>{{nb}}</td> + </tr> + {% endfor %} + </table></div> + + + </div> + <div> + + <h3>{% trans "Excavation informations" %}</h3> + + <div class='table'> + <table> + <caption>{% trans "Total" %}</caption> + <tr> + <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th> + </tr> + {% for lbl, nb in dashboard.excavation.total %} + <tr> + <th class='sub'>{{lbl}}</th><td>{{nb}}</td> + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By year" %}</caption> + <tr> + <th>{% trans "State" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %} + </tr> + {% for lbl, years in dashboard.excavation.by_year %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By realisation year" %}</caption> + <tr> + <th>{% trans "State" %}</th>{%for yr in dashboard.realisation_years %}<th>{{yr.year}}</th>{% endfor %} + </tr> + {% for lbl, years in dashboard.excavation.by_realisation_year %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Current realisation year" %}</caption> + <tr> + <th>{% trans "Status" %}</th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%} + </tr> + <tr> + <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.excavation.area_realised %}<td>{{nb}}</td>{%endfor%} + </tr> + <tr> + <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.excavation.manday_realised %}<td>{{nb}}</td>{%endfor%} + </tr> + <tr> + <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.excavation.mandayhect_realised %}<td>{{nb}}</td>{%endfor%} + </tr> + </table></div> + + <p><strong>{% trans "Man-day/hectare for effective operations (current realisation year):" %}</strong> {{dashboard.excavation.mandayhect_real_effective}}</p> + + <div class='table'> + <table> + <caption>{% trans "Organizations (current realisation year)" %}</caption> + <tr> + <th> </th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th> + </tr> + {% for org in dashboard.excavation.org_realised %} + <tr> + <th class='sub'>{{org.in_charge__attached_to__name}}</th><td>{{org.area}}</td><td>{{org.manday}}</td><td>{{org.mandayhect}}</td> + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Area by organization by year" %}</caption> + <tr> + <th>{% trans "Organization" %}</th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} + </tr> + {% for org, vals in dashboard.excavation.org_by_year %} + <tr> + <th class='sub'>{{org}}</th>{% for area, cost in vals %}<td>{{area}}</td>{% endfor %} + </tr> + {% endfor %} + <tr> + <th>{% trans "Sum" %}</th>{% for area in dashboard.excavation.org_by_year_area_sum %}<td>{{area}}</td>{% endfor %} + </tr> + <tr> + <th>{% trans "Mean" %}</th>{% for area in dashboard.excavation.org_by_year_area_mean %}<td>{{area}}</td>{% endfor %} + </tr> + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Area by organization by realisation year" %}</caption> + <tr> + <th>{% trans "Organization" %}</th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} + </tr> + {% for org, vals in dashboard.excavation.org_by_year %} + <tr> + <th class='sub'>{{org}}</th>{% for area, cost in vals %}<td>{{area}}</td>{% endfor %} + </tr> + {% endfor %} + <tr> + <th>{% trans "Sum" %}</th>{% for area in dashboard.excavation.org_by_year_area_sum %}<td>{{area}}</td>{% endfor %} + </tr> + <tr> + <th>{% trans "Mean" %}</th>{% for area in dashboard.excavation.org_by_year_area_mean %}<td>{{area}}</td>{% endfor %} + </tr> + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By month" %}</caption> + <tr> + <th>{% trans "State" %}</th>{%for mt in dashboard.last_months %}<th>{{mt.date|date:"F Y"|capfirst}}</th>{% endfor %} + </tr> + {% for lbl, months in dashboard.excavation.by_month %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in months %}<td>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "By department" %}</caption> + <tr> + <th>{% trans "Department" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %}<th>{% trans "Sum" %}</th> + </tr> + {% for lbl, years in dashboard.excavation.by_dpt %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb in years %}<td{%if forloop.last%} class='sub'{%endif%}>{{nb}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Effective operation by department" %}</caption> + <tr> + <th rowspan='2'>{% trans "Department" %}</th>{%for yr in dashboard.years %}<th colspan='3'>{{yr}}</th>{% endfor %}<th colspan='3'>{% trans "Sum" %}</th> + </tr> + <tr> + {%for yr in dashboard.years %}<th>{%trans "Nb."%}</th><th>{%trans "Cost"%}</th><th>{%trans "FNAP cost"%}</th>{% endfor %}<th>{%trans "Nb."%}</th><th>{%trans "Cost"%}</th><th>{%trans "FNAP cost"%}</th> + </tr> + {% for lbl, years in dashboard.excavation.effective_by_dpt %} + <tr> + <th class='sub'>{{lbl}}</th>{%for nb, area, cost, fnap in years %}<td{%if forloop.last%} class='sub'{%endif%}>{{nb}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{cost}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{fnap}}</td>{% endfor %} + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Main towns by number" %}</caption> + <tr> + <th>{% trans "Town" %}</th><th>{% trans "Number" %}</th> + </tr> + {% for lbl, nb in dashboard.excavation.towns %} + <tr> + <th class='sub'>{{lbl}}</th><td>{{nb}}</td> + </tr> + {% endfor %} + </table></div> + + <div class='table'> + <table> + <caption>{% trans "Main towns by cost" %}</caption> + <tr> + <th>{% trans "Town" %}</th><th>{% trans "Cost (€)" %}</th> + </tr> + {% for lbl, nb in dashboard.excavation.towns_cost %} + <tr> + <th class='sub'>{{lbl}}</th><td>{{nb}}</td> + </tr> + {% endfor %} + </table></div> + + + </div> +</div> +{% endblock %} diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py index 89e1a63fc..23632f1cf 100644 --- a/archaeological_operations/urls.py +++ b/archaeological_operations/urls.py @@ -71,4 +71,6 @@ urlpatterns += patterns('archaeological_operations.views', 'get_administrativeactop', name='get-administrativeactop'), url(r'get-operationsource/(?P<type>.+)?$', 'get_operationsource', name='get-operationsource'), + url(r'dashboard_operation/$', 'dashboard_operation', + name='dashboard-operation') ) diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index a9200cafa..502461130 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -89,12 +89,12 @@ get_administrativeactop = get_item(models.AdministrativeAct, 'act_type__intented_to':'act_type__intented_to'}) -def dashboard_operation(request, dct, obj_id=None, *args, **kwargs): +def dashboard_operation(request, *args, **kwargs): """ Operation dashboard """ dct = {'dashboard': models.OperationDashboard()} - return render_to_response('dashboard_operation.html', dct, + return render_to_response('ishtar/dashboards/dashboard_operation.html', dct, context_instance=RequestContext(request)) operation_search_wizard = SearchWizard.as_view([ |