From 5b773f6a3cc454e26693b83169760369cf0a0b62 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 22 Oct 2012 00:08:24 +0200 Subject: Djangoization - Major refactoring (step 15) * works on dashboards --- archaeological_context_records/models.py | 5 +- archaeological_files/ishtar_menu.py | 30 +- archaeological_files/models.py | 4 +- .../ishtar/dashboards/dashboard_file.html | 215 +++++++++ archaeological_files/urls.py | 1 + archaeological_files/views.py | 4 +- archaeological_finds/models.py | 5 +- archaeological_operations/ishtar_menu.py | 13 +- archaeological_operations/models.py | 2 + .../ishtar/dashboards/dashboard_operation.html | 510 +++++++++++++++++++++ archaeological_operations/urls.py | 2 + archaeological_operations/views.py | 4 +- ishtar_common/menus.py | 30 +- ishtar_common/models.py | 1 + ishtar_common/templates/dashboard_file.html | 215 --------- ishtar_common/templates/dashboard_main.html | 82 ---- ishtar_common/templates/dashboard_operation.html | 510 --------------------- .../ishtar/dashboards/dashboard_main.html | 82 ++++ ishtar_common/urls.py | 6 +- ishtar_common/views.py | 23 +- 20 files changed, 893 insertions(+), 851 deletions(-) create mode 100644 archaeological_files/templates/ishtar/dashboards/dashboard_file.html create mode 100644 archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html delete mode 100644 ishtar_common/templates/dashboard_file.html delete mode 100644 ishtar_common/templates/dashboard_main.html delete mode 100644 ishtar_common/templates/dashboard_operation.html create mode 100644 ishtar_common/templates/ishtar/dashboards/dashboard_main.html diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 64772627b..c558587aa 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -169,8 +169,9 @@ class ContextRecord(BaseHistorizedItem, OwnPerms): def get_years(cls): years = set() for res in list(cls.objects.values('operation__start_date')): - yr = res['operation__start_date'].year - years.add(yr) + if res['operation__start_date']: + yr = res['operation__start_date'].year + years.add(yr) return list(years) @classmethod diff --git a/archaeological_files/ishtar_menu.py b/archaeological_files/ishtar_menu.py index 398b43f4b..236c47776 100644 --- a/archaeological_files/ishtar_menu.py +++ b/archaeological_files/ishtar_menu.py @@ -61,5 +61,33 @@ MENU_SECTIONS = [ access_controls=['delete_file', 'delete_own_file']), ],), ]), - ) + ), + (100, SectionItem('dashboard', _(u"Dashboard"), + childs=[ + MenuItem('dashboard_main', _(u"General informations"), + model=models.File, + access_controls=['change_file', 'change_own_file']), + MenuItem('dashboard_file', _(u"Archaeological files"), + model=models.File, + access_controls=['change_file', 'change_own_file']), + ]), + ), ] +""" + SectionItem('dashboard', _(u"Dashboard"), + childs=[ + MenuItem('dashboard_main', _(u"General informations"), + model=models.File, + access_controls=['change_file', 'change_own_file']), + MenuItem('dashboard_file', _(u"Archaeological files"), + model=models.File, + access_controls=['change_file', 'change_own_file']), + #MenuItem('dashboard_treatment', _(u"Treatments"), + # model=models.Treatment, + # access_controls=['change_treatment',]), + #MenuItem('dashboard_warehouse', _(u"Warehouses"), + # model=models.Warehouse, + # access_controls=['change_warehouse',]), + ]), + ] +""" diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 0b95c021a..a91f6ed69 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -180,6 +180,7 @@ class FileByDepartment(models.Model): class FileDashboard: def __init__(self): + from archaeological_operations.models import AdministrativeAct main_dashboard = Dashboard(File) self.total_number = main_dashboard.total_number @@ -266,7 +267,8 @@ class FileDashboard: self.rescue['with_associated_operation'] = rescues\ .filter(operations__isnull=False).count() - self.rescue['with_associated_operation_percent'] = round( + if self.rescue['total_number']: + self.rescue['with_associated_operation_percent'] = round( float(self.rescue['with_associated_operation'])\ /self.rescue['total_number']*100, 2) diff --git a/archaeological_files/templates/ishtar/dashboards/dashboard_file.html b/archaeological_files/templates/ishtar/dashboards/dashboard_file.html new file mode 100644 index 000000000..cebd147f4 --- /dev/null +++ b/archaeological_files/templates/ishtar/dashboards/dashboard_file.html @@ -0,0 +1,215 @@ +{% extends "base.html" %} +{% load i18n %} +{% load range %} +{% block extra_head %} +{{form.media}} +{% endblock %} +{% block content %} +
+

{% trans "Archaeological files" %}

+
+

{% trans "Global informations" %}

+ +

{% trans "Total:" %} {{dashboard.total_number}}

+ {% for type in dashboard.types %} +

{{type.file_type__label}}{% trans ":"%} {{type.number}}

+ {% endfor %} +
+ + + + {% for year in dashboard.by_year %}{% endfor %} + + + {% for year in dashboard.by_year %}{% endfor%} + +
{% trans "By year"%}
{{year.date.year}}
{{year.number}}
+
+ +
+ + + + {% for month in dashboard.by_month %}{% endfor %} + + + {% for month in dashboard.by_month %}{% endfor%} + +
{% trans "By month"%}
{{month.date|date:"F Y"|capfirst}}
{{month.number}}
+
+ +
+
+ +

{% trans "Research archaeology" %}

+ +

{% trans "Total:" %} {{dashboard.research.total_number}}

+
+ + + + {% for year in dashboard.research.by_year %}{% endfor %} + + + {% for year in dashboard.research.by_year %}{% endfor%} + +
{% trans "By year"%}
{{year.date.year}}
{{year.number}}
+
+ +
+ + + + {% for month in dashboard.research.by_month %}{% endfor %} + + + {% for month in dashboard.research.by_month %}{% endfor%} + +
{% trans "By month"%}
{{month.date|date:"F Y"|capfirst}}
{{month.number}}
+
+ +
+ + + + {% for dpt in dashboard.research.by_dpt %}{% endfor %} + + + {% for dpt in dashboard.research.by_dpt %}{% endfor%} + +
{% trans "By department"%}
{{dpt.department__label}}
{{dpt.number}}
+
+ +
+ + + + {% for town in dashboard.research.towns %}{% endfor %} + + + {% for town in dashboard.research.towns %}{% endfor%} + +
{% trans "Main towns"%}
{{town.town__name}}
{{town.number}}
+
+ +
+
+ +

{% trans "Rescue archaeology" %}

+ +

{% trans "Total:" %} {{dashboard.rescue.total_number}}

+ +
+ + + + {% for saisine in dashboard.rescue.saisine %}{% endfor %} + + + {% for saisine in dashboard.rescue.saisine %}{% endfor%} + +
{% trans "By saisine type"%}
{{saisine.saisine_type__label}}
{{saisine.number}}
+
+ +
+ + + + {% for act in dashboard.rescue.administrative_act %}{% endfor %} + + + {% for act in dashboard.rescue.administrative_act %}{% endfor%} + +
{% trans "By administrative act"%}
{{act.act_type__label}}
{{act.number}}
+
+ +
+ + + + {% for year in dashboard.rescue.by_year %}{% endfor %} + + + {% for year in dashboard.rescue.by_year %}{% endfor%} + +
{% trans "By year"%}
{{year.date.year}}
{{year.number}}
+
+ +
+ + + + {% for month in dashboard.rescue.by_month %}{% endfor %} + + + {% for month in dashboard.rescue.by_month %}{% endfor%} + +
{% trans "By month"%}
{{month.date|date:"F Y"|capfirst}}
{{month.number}}
+
+ +

{% trans "Archaeological files linked to at least one operation:" %} {{dashboard.rescue.with_associated_operation}}

+

{% trans "Archaeological files linked to at least one operation (%):" %} {{dashboard.rescue.with_associated_operation_percent}}

+ +
+ + + + {% for year in dashboard.rescue.operational_by_year %}{% endfor %} + + + {% for year in dashboard.rescue.operational_by_year %}{% endfor%} + +
{% trans "Archaeological files linked to at least one operation (%)"%}
{{year.date.year}}
{{year.number}}
+
+ +
+ + + + {% for dpt in dashboard.rescue.by_dpt %}{% endfor %} + + + {% for dpt in dashboard.rescue.by_dpt %}{% endfor%} + +
{% trans "By department"%}
{{dpt.department__label}}
{{dpt.number}}
+
+ +
+ + + + {% for dpt in dashboard.rescue.surface_by_dpt %}{% endfor %} + + + {% for dpt in dashboard.rescue.surface_by_dpt %}{% endfor%} + +
{% trans "Surface by department (m²)"%}
{{dpt.department__label}}
{{dpt.number}}
+
+ +
+ + + + {% for town in dashboard.rescue.towns %}{% endfor %} + + + {% for town in dashboard.rescue.towns %}{% endfor%} + +
{% trans "Main towns by number"%}
{{town.town__name}}
{{town.number}}
+
+ +
+ + + + {% for town in dashboard.rescue.surface_by_town %}{% endfor %} + + + {% for town in dashboard.rescue.surface_by_town %}{% endfor%} + +
{% trans "Main towns by surface (m²)"%}
{{town.town__name}}
{{town.number}}
+
+ +
+
+{% endblock %} diff --git a/archaeological_files/urls.py b/archaeological_files/urls.py index 4c5d923a2..72a6e2df7 100644 --- a/archaeological_files/urls.py +++ b/archaeological_files/urls.py @@ -59,4 +59,5 @@ urlpatterns += patterns('archaeological_files.views', 'show_file', name='show-historized-file'), url(r'revert-file/(?P.+)/(?P.+)$', 'revert_file', name='revert-file'), + url(r'dashboard_file/$', 'dashboard_file', name='dashboard-file') ) diff --git a/archaeological_files/views.py b/archaeological_files/views.py index 84ee84136..3ef8c0f28 100644 --- a/archaeological_files/views.py +++ b/archaeological_files/views.py @@ -70,12 +70,12 @@ get_administrativeactfile = get_item(AdministrativeAct, 'operation__towns':'operation__towns__pk', 'act_type__intented_to':'act_type__intented_to'}) -def dashboard_file(request, dct, obj_id=None, *args, **kwargs): +def dashboard_file(request, *args, **kwargs): """ Main dashboard """ dct = {'dashboard': models.FileDashboard()} - return render_to_response('dashboard_file.html', dct, + return render_to_response('ishtar/dashboards/dashboard_file.html', dct, context_instance=RequestContext(request)) file_search_wizard = SearchWizard.as_view( diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index cb305a93a..a02cb4402 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -140,8 +140,9 @@ class Find(BaseHistorizedItem, OwnPerms): if not bi: continue bi = bi[0] - yr = bi.context_record.operation.start_date.year - years.add(yr) + if bi.context_record.operation.start_date: + yr = bi.context_record.operation.start_date.year + years.add(yr) return list(years) @classmethod 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 %} +
+

{% trans "Operations" %}

+
+

{% trans "Global informations" %}

+ +
+ + + + + + {% for lbl, nb in dashboard.total %} + + + + {% endfor %} +
{% trans "Total" %}
{% trans "Status" %}{% trans "Number" %}
{{lbl}}{{nb}}
+ +
+ + + + + + {% for surface in dashboard.surface_by_type %} + + + + {% endfor %} +
{% trans "Area by type of operation" %}
{% trans "Status" %}{% trans "Area (m²)" %}
{{surface.operation_type__label}}{{surface.number}}
+ +
+ + + + {%for typ in dashboard.types %}{% endfor %} + + {% for lbl, types in dashboard.by_type %} + + {%for nb in types %}{% endfor %} + + {% endfor %} +
{% trans "By types" %}
{% trans "State" %}{{typ.label}}
{{lbl}}{{nb}}
+ +
+ + + + {%for yr in dashboard.years %}{% endfor %} + + {% for lbl, years in dashboard.by_year %} + + {%for nb in years %}{% endfor %} + + {% endfor %} +
{% trans "By year" %}
{% trans "State" %}{{yr}}
{{lbl}}{{nb}}
+ +
+ + + + {%for yr in dashboard.realisation_years %}{% endfor %} + + {% for lbl, years in dashboard.by_realisation_year %} + + {%for nb in years %}{% endfor %} + + {% endfor %} +
{% trans "By realisation year" %}
{% trans "State" %}{{yr.year}}
{{lbl}}{{nb}}
+ +
+ + + + {%for yr in dashboard.years %}{% endfor %} + + {% for lbl, years in dashboard.effective %} + + {%for nb in years %}{% endfor %} + + {% endfor %} +
{% trans "Effective operation by type and year" %}
{% trans "Type" %}{{yr}}
{{lbl}}{{nb}}
+ +
+ + + + {%for mt in dashboard.last_months %}{% endfor %} + + {% for lbl, months in dashboard.by_realisation_month %} + + {%for nb in months %}{% endfor %} + + {% endfor %} +
{% trans "By realisation month" %}
{% trans "State" %}{{mt.date|date:"F Y"|capfirst}}
{{lbl}}{{nb}}
+ +
+
+ +

{% trans "Survey informations" %}

+ +
+ + + + + + {% for lbl, nb in dashboard.survey.total %} + + + + {% endfor %} +
{% trans "Total" %}
{% trans "Status" %}{% trans "Number" %}
{{lbl}}{{nb}}
+ +
+ + + + {%for yr in dashboard.years %}{% endfor %} + + {% for lbl, years in dashboard.survey.by_year %} + + {%for nb in years %}{% endfor %} + + {% endfor %} +
{% trans "By year" %}
{% trans "State" %}{{yr}}
{{lbl}}{{nb}}
+ +
+ + + + {%for yr in dashboard.realisation_years %}{% endfor %} + + {% for lbl, years in dashboard.survey.by_realisation_year %} + + {%for nb in years %}{% endfor %} + + {% endfor %} +
{% trans "By realisation year" %}
{% trans "State" %}{{yr.year}}
{{lbl}}{{nb}}
+ +
+ + + + {% for lbl in dashboard.filters_label %}{%endfor%} + + + {% for nb in dashboard.survey.area %}{%endfor%} + + + {% for nb in dashboard.survey.manday %}{%endfor%} + + + {% for nb in dashboard.survey.mandayhect %}{%endfor%} + +
{% trans "Current year" %}
{% trans "Status" %}{{lbl}}
{% trans "Area"%}{{nb}}
{% trans "Man-day"%}{{nb}}
{% trans "Man-day/hectare"%}{{nb}}
+ +

{% trans "Man-day/hectare for effective operations (current year):" %} {{dashboard.survey.mandayhect_effective}}

+ +
+ + + + + + {% for org in dashboard.survey.org %} + + + + {% endfor %} +
{% trans "Organizations (current year)" %}
 {% trans "Area" %}{% trans "Man-day" %}{% trans "Man-day/hectare" %}
{{org.in_charge__attached_to__name}}{{org.area}}{{org.manday}}{{org.mandayhect}}
+ +
+ + + + {% for lbl in dashboard.filters_label %}{%endfor%} + + + {% for nb in dashboard.survey.area_realised %}{%endfor%} + + + {% for nb in dashboard.survey.manday_realised %}{%endfor%} + + + {% for nb in dashboard.survey.mandayhect_realised %}{%endfor%} + +
{% trans "Current realisation year" %}
{% trans "Status" %}{{lbl}}
{% trans "Area"%}{{nb}}
{% trans "Man-day"%}{{nb}}
{% trans "Man-day/hectare"%}{{nb}}
+ +

{% trans "Man-day/hectare for effective operations (current realisation year):" %} {{dashboard.survey.mandayhect_real_effective}}

+ +
+ + + + + + {% for org in dashboard.survey.org_realised %} + + + + {% endfor %} +
{% trans "Organizations (current realisation year)" %}
 {% trans "Area" %}{% trans "Man-day" %}{% trans "Man-day/hectare" %}
{{org.in_charge__attached_to__name}}{{org.area}}{{org.manday}}{{org.mandayhect}}
+ +
+ + + + {% for yr in dashboard.years%}{% endfor %} + + {% for org, vals in dashboard.survey.org_by_year %} + + {% for area, cost in vals %}{% endfor %} + + {% endfor %} + + {% for area in dashboard.survey.org_by_year_area_mean %}{% endfor %} + +
{% trans "Area by organization by year" %}
{% trans "Organization" %}{{yr}}
{{org}}{{area}}
{% trans "Mean" %}{{area}}
+ +
+ + + + {% for yr in dashboard.years%}{% endfor %} + + + {% for nb, mean in dashboard.survey.effective %}{% endfor %} + + + {% for nb, avg in dashboard.survey.effective %}{% endfor %} + +
{% trans "Effective operations areas (m²)" %}
 {{yr}}
{% trans "Sum" %}{{nb}}
{% trans "Average" %}{{avg}}
+ +
+ + + + {% for yr in dashboard.years%}{% endfor %} + + + {% for nb, mean in dashboard.survey.mandayshect %}{% endfor %} + + + {% for nb, avg in dashboard.survey.mandayshect %}{% endfor %} + +
{% trans "Man-Days/hectare by Year" %}
 {{yr}}
{% trans "Man-Days/hectare" %}{{nb}}
{% trans "Average" %}{{avg}}
+ +
+ + + + {%for mt in dashboard.last_months %}{% endfor %} + + {% for lbl, months in dashboard.survey.by_month %} + + {%for nb in months %}{% endfor %} + + {% endfor %} +
{% trans "By month" %}
{% trans "State" %}{{mt.date|date:"F Y"|capfirst}}
{{lbl}}{{nb}}
+ +
+ + + + {%for yr in dashboard.years %}{% endfor %} + + {% for lbl, years in dashboard.survey.by_dpt %} + + {%for nb in years %}{{nb}}{% endfor %} + + {% endfor %} +
{% trans "By department" %}
{% trans "Department" %}{{yr}}{% trans "Sum" %}
{{lbl}}
+ +
+ + + + {%for yr in dashboard.years %}{% endfor %} + + + {%for yr in dashboard.years %}{% endfor %} + + {% for lbl, years in dashboard.survey.effective_by_dpt %} + + {%for nb, area, cost, fnap in years %}{{nb}}{{area}}{% endfor %} + + {% endfor %} +
{% trans "Effective operation by department" %}
{% trans "Department" %}{{yr}}{% trans "Sum" %}
{%trans "Nb."%}{%trans "Area"%}{%trans "Nb."%}{%trans "Area"%}
{{lbl}}
+ +
+ + + + + + {% for lbl, nb in dashboard.survey.towns %} + + + + {% endfor %} +
{% trans "Main towns by number" %}
{% trans "Town" %}{% trans "Number" %}
{{lbl}}{{nb}}
+ +
+ + + + + + {% for lbl, nb in dashboard.survey.towns_surface %} + + + + {% endfor %} +
{% trans "Main towns by surface" %}
{% trans "Town" %}{% trans "Total surface (m²)" %}
{{lbl}}{{nb}}
+ + +
+
+ +

{% trans "Excavation informations" %}

+ +
+ + + + + + {% for lbl, nb in dashboard.excavation.total %} + + + + {% endfor %} +
{% trans "Total" %}
{% trans "Status" %}{% trans "Number" %}
{{lbl}}{{nb}}
+ +
+ + + + {%for yr in dashboard.years %}{% endfor %} + + {% for lbl, years in dashboard.excavation.by_year %} + + {%for nb in years %}{% endfor %} + + {% endfor %} +
{% trans "By year" %}
{% trans "State" %}{{yr}}
{{lbl}}{{nb}}
+ +
+ + + + {%for yr in dashboard.realisation_years %}{% endfor %} + + {% for lbl, years in dashboard.excavation.by_realisation_year %} + + {%for nb in years %}{% endfor %} + + {% endfor %} +
{% trans "By realisation year" %}
{% trans "State" %}{{yr.year}}
{{lbl}}{{nb}}
+ +
+ + + + {% for lbl in dashboard.filters_label %}{%endfor%} + + + {% for nb in dashboard.excavation.area_realised %}{%endfor%} + + + {% for nb in dashboard.excavation.manday_realised %}{%endfor%} + + + {% for nb in dashboard.excavation.mandayhect_realised %}{%endfor%} + +
{% trans "Current realisation year" %}
{% trans "Status" %}{{lbl}}
{% trans "Area"%}{{nb}}
{% trans "Man-day"%}{{nb}}
{% trans "Man-day/hectare"%}{{nb}}
+ +

{% trans "Man-day/hectare for effective operations (current realisation year):" %} {{dashboard.excavation.mandayhect_real_effective}}

+ +
+ + + + + + {% for org in dashboard.excavation.org_realised %} + + + + {% endfor %} +
{% trans "Organizations (current realisation year)" %}
 {% trans "Area" %}{% trans "Man-day" %}{% trans "Man-day/hectare" %}
{{org.in_charge__attached_to__name}}{{org.area}}{{org.manday}}{{org.mandayhect}}
+ +
+ + + + {% for yr in dashboard.years%}{% endfor %} + + {% for org, vals in dashboard.excavation.org_by_year %} + + {% for area, cost in vals %}{% endfor %} + + {% endfor %} + + {% for area in dashboard.excavation.org_by_year_area_sum %}{% endfor %} + + + {% for area in dashboard.excavation.org_by_year_area_mean %}{% endfor %} + +
{% trans "Area by organization by year" %}
{% trans "Organization" %}{{yr}}
{{org}}{{area}}
{% trans "Sum" %}{{area}}
{% trans "Mean" %}{{area}}
+ +
+ + + + {% for yr in dashboard.years%}{% endfor %} + + {% for org, vals in dashboard.excavation.org_by_year %} + + {% for area, cost in vals %}{% endfor %} + + {% endfor %} + + {% for area in dashboard.excavation.org_by_year_area_sum %}{% endfor %} + + + {% for area in dashboard.excavation.org_by_year_area_mean %}{% endfor %} + +
{% trans "Area by organization by realisation year" %}
{% trans "Organization" %}{{yr}}
{{org}}{{area}}
{% trans "Sum" %}{{area}}
{% trans "Mean" %}{{area}}
+ +
+ + + + {%for mt in dashboard.last_months %}{% endfor %} + + {% for lbl, months in dashboard.excavation.by_month %} + + {%for nb in months %}{% endfor %} + + {% endfor %} +
{% trans "By month" %}
{% trans "State" %}{{mt.date|date:"F Y"|capfirst}}
{{lbl}}{{nb}}
+ +
+ + + + {%for yr in dashboard.years %}{% endfor %} + + {% for lbl, years in dashboard.excavation.by_dpt %} + + {%for nb in years %}{{nb}}{% endfor %} + + {% endfor %} +
{% trans "By department" %}
{% trans "Department" %}{{yr}}{% trans "Sum" %}
{{lbl}}
+ +
+ + + + {%for yr in dashboard.years %}{% endfor %} + + + {%for yr in dashboard.years %}{% endfor %} + + {% for lbl, years in dashboard.excavation.effective_by_dpt %} + + {%for nb, area, cost, fnap in years %}{{nb}}{{cost}}{{fnap}}{% endfor %} + + {% endfor %} +
{% trans "Effective operation by department" %}
{% trans "Department" %}{{yr}}{% trans "Sum" %}
{%trans "Nb."%}{%trans "Cost"%}{%trans "FNAP cost"%}{%trans "Nb."%}{%trans "Cost"%}{%trans "FNAP cost"%}
{{lbl}}
+ +
+ + + + + + {% for lbl, nb in dashboard.excavation.towns %} + + + + {% endfor %} +
{% trans "Main towns by number" %}
{% trans "Town" %}{% trans "Number" %}
{{lbl}}{{nb}}
+ +
+ + + + + + {% for lbl, nb in dashboard.excavation.towns_cost %} + + + + {% endfor %} +
{% trans "Main towns by cost" %}
{% trans "Town" %}{% trans "Cost (€)" %}
{{lbl}}{{nb}}
+ + +
+
+{% 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.+)?$', '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([ diff --git a/ishtar_common/menus.py b/ishtar_common/menus.py index 4802a369d..77dcabcd3 100644 --- a/ishtar_common/menus.py +++ b/ishtar_common/menus.py @@ -37,7 +37,7 @@ for app in settings.INSTALLED_APPS: # sort __section_items = [menu for order, menu in sorted(_extra_menus, - key=lambda x:x[0])] + key=lambda x:x[0])] # regroup menus _section_items, __keys = [], [] for section_item in __section_items: @@ -45,29 +45,11 @@ for section_item in __section_items: __keys.append(section_item.idx) _section_items.append(section_item) continue - _section_items[__keys.index(section_item.idx)].childs += section_item.childs -""" - SectionItem('dashboard', _(u"Dashboard"), - childs=[ - MenuItem('dashboard_main', _(u"General informations"), - model=models.File, - access_controls=['change_file', 'change_own_file']), - MenuItem('dashboard_file', _(u"Archaeological files"), - 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']), - #MenuItem('dashboard_treatment', _(u"Treatments"), - # model=models.Treatment, - # access_controls=['change_treatment',]), - #MenuItem('dashboard_warehouse', _(u"Warehouses"), - # model=models.Warehouse, - # access_controls=['change_warehouse',]), - ]), - ] -""" + section_childs = _section_items[__keys.index(section_item.idx)].childs + childs_idx = [child.idx for child in section_childs] + for child in section_item.childs: + if child.idx not in childs_idx: + section_childs.append(child) class Menu: childs = _section_items diff --git a/ishtar_common/models.py b/ishtar_common/models.py index d8d3c3213..cff55ea5b 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -407,6 +407,7 @@ class Dashboard: last_ids = history_model.objects.values('id')\ .annotate(hd=Max('history_date')) last_ids = last_ids.filter(history_type=modif_type) + from archaeological_finds.models import Find if self.model == Find: last_ids = last_ids.filter(downstream_treatment_id__isnull=True) if modif_type == '+': diff --git a/ishtar_common/templates/dashboard_file.html b/ishtar_common/templates/dashboard_file.html deleted file mode 100644 index cebd147f4..000000000 --- a/ishtar_common/templates/dashboard_file.html +++ /dev/null @@ -1,215 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load range %} -{% block extra_head %} -{{form.media}} -{% endblock %} -{% block content %} -
-

{% trans "Archaeological files" %}

-
-

{% trans "Global informations" %}

- -

{% trans "Total:" %} {{dashboard.total_number}}

- {% for type in dashboard.types %} -

{{type.file_type__label}}{% trans ":"%} {{type.number}}

- {% endfor %} -
- - - - {% for year in dashboard.by_year %}{% endfor %} - - - {% for year in dashboard.by_year %}{% endfor%} - -
{% trans "By year"%}
{{year.date.year}}
{{year.number}}
-
- -
- - - - {% for month in dashboard.by_month %}{% endfor %} - - - {% for month in dashboard.by_month %}{% endfor%} - -
{% trans "By month"%}
{{month.date|date:"F Y"|capfirst}}
{{month.number}}
-
- -
-
- -

{% trans "Research archaeology" %}

- -

{% trans "Total:" %} {{dashboard.research.total_number}}

-
- - - - {% for year in dashboard.research.by_year %}{% endfor %} - - - {% for year in dashboard.research.by_year %}{% endfor%} - -
{% trans "By year"%}
{{year.date.year}}
{{year.number}}
-
- -
- - - - {% for month in dashboard.research.by_month %}{% endfor %} - - - {% for month in dashboard.research.by_month %}{% endfor%} - -
{% trans "By month"%}
{{month.date|date:"F Y"|capfirst}}
{{month.number}}
-
- -
- - - - {% for dpt in dashboard.research.by_dpt %}{% endfor %} - - - {% for dpt in dashboard.research.by_dpt %}{% endfor%} - -
{% trans "By department"%}
{{dpt.department__label}}
{{dpt.number}}
-
- -
- - - - {% for town in dashboard.research.towns %}{% endfor %} - - - {% for town in dashboard.research.towns %}{% endfor%} - -
{% trans "Main towns"%}
{{town.town__name}}
{{town.number}}
-
- -
-
- -

{% trans "Rescue archaeology" %}

- -

{% trans "Total:" %} {{dashboard.rescue.total_number}}

- -
- - - - {% for saisine in dashboard.rescue.saisine %}{% endfor %} - - - {% for saisine in dashboard.rescue.saisine %}{% endfor%} - -
{% trans "By saisine type"%}
{{saisine.saisine_type__label}}
{{saisine.number}}
-
- -
- - - - {% for act in dashboard.rescue.administrative_act %}{% endfor %} - - - {% for act in dashboard.rescue.administrative_act %}{% endfor%} - -
{% trans "By administrative act"%}
{{act.act_type__label}}
{{act.number}}
-
- -
- - - - {% for year in dashboard.rescue.by_year %}{% endfor %} - - - {% for year in dashboard.rescue.by_year %}{% endfor%} - -
{% trans "By year"%}
{{year.date.year}}
{{year.number}}
-
- -
- - - - {% for month in dashboard.rescue.by_month %}{% endfor %} - - - {% for month in dashboard.rescue.by_month %}{% endfor%} - -
{% trans "By month"%}
{{month.date|date:"F Y"|capfirst}}
{{month.number}}
-
- -

{% trans "Archaeological files linked to at least one operation:" %} {{dashboard.rescue.with_associated_operation}}

-

{% trans "Archaeological files linked to at least one operation (%):" %} {{dashboard.rescue.with_associated_operation_percent}}

- -
- - - - {% for year in dashboard.rescue.operational_by_year %}{% endfor %} - - - {% for year in dashboard.rescue.operational_by_year %}{% endfor%} - -
{% trans "Archaeological files linked to at least one operation (%)"%}
{{year.date.year}}
{{year.number}}
-
- -
- - - - {% for dpt in dashboard.rescue.by_dpt %}{% endfor %} - - - {% for dpt in dashboard.rescue.by_dpt %}{% endfor%} - -
{% trans "By department"%}
{{dpt.department__label}}
{{dpt.number}}
-
- -
- - - - {% for dpt in dashboard.rescue.surface_by_dpt %}{% endfor %} - - - {% for dpt in dashboard.rescue.surface_by_dpt %}{% endfor%} - -
{% trans "Surface by department (m²)"%}
{{dpt.department__label}}
{{dpt.number}}
-
- -
- - - - {% for town in dashboard.rescue.towns %}{% endfor %} - - - {% for town in dashboard.rescue.towns %}{% endfor%} - -
{% trans "Main towns by number"%}
{{town.town__name}}
{{town.number}}
-
- -
- - - - {% for town in dashboard.rescue.surface_by_town %}{% endfor %} - - - {% for town in dashboard.rescue.surface_by_town %}{% endfor%} - -
{% trans "Main towns by surface (m²)"%}
{{town.town__name}}
{{town.number}}
-
- -
-
-{% endblock %} diff --git a/ishtar_common/templates/dashboard_main.html b/ishtar_common/templates/dashboard_main.html deleted file mode 100644 index e710dbe16..000000000 --- a/ishtar_common/templates/dashboard_main.html +++ /dev/null @@ -1,82 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load range %} -{% block extra_head %} -{{form.media}} -{% endblock %} -{% block content %} -
-{% for lbl, dashboard in items %} -
-

{{lbl}}

-

{% trans "Numbers" %}

-

{% trans "Total:" %} {{dashboard.total_number}}

-
- - {% for idx, lbl, values in dashboard.values %} - - - {% for value in values %}{% endfor%} - - {% endfor%} -
{{lbl}}{{value}}
-
- {% if dashboard.years %} -

{% trans "By years" %}

-
    -
  • {% trans "Average:" %} {{dashboard.average}}
  • -
  • {% trans "Variance:" %} {{dashboard.variance}}
  • -
  • {% trans "Standard deviation:" %} {{dashboard.standard_deviation}}
  • -
  • {% trans "Median:" %} {{dashboard.median}}
  • -
  • {% trans "Mode:" %} {{dashboard.mode}}
  • -
- {% endif %} - {% if dashboard.operation_average %} -

{% trans "By operations" %}

-
    -
  • {% trans "Average:" %} {{dashboard.operation_average}}
  • -
  • {% trans "Variance:" %} {{dashboard.operation_variance}}
  • -
  • {% trans "Standard deviation:" %} {{dashboard.operation_standard_deviation}}
  • -
  • {% trans "Median:" %} {{dashboard.operation_median}}
  • -
  • {% trans "Mode:" %} {{dashboard.operation_mode}}
  • -
- {% endif %} -

{% trans "Created last" %}

-
- - - {% for item in dashboard.lasts %} - - - - {% endfor %} -
{{lbl}}{% trans "Created" %}
{{item}}{{item.history_date}}{% if item.get_show_url %}{%trans "Show"%}{%endif%}
-
-

{% trans "Recent changes" %}

-
- - - {% for item in dashboard.recents %} - - - - {% endfor %} -
{{lbl}}{% trans "Modified" %}
{{item}}{{item.history_date}}{% if item.get_show_url %}{%trans "Show"%}{%endif%}
-
-
-{% endfor%} -
-

{% trans "Users" %}

-
- - - {% for user_type in ishtar_users.types %} - - - - - {% endfor%} -
{% trans "User type" %}{% trans "Number" %}
{{user_type.person__person_type__label}}{{user_type.number}}
-
-
-{% endblock %} diff --git a/ishtar_common/templates/dashboard_operation.html b/ishtar_common/templates/dashboard_operation.html deleted file mode 100644 index 28f1dd9c6..000000000 --- a/ishtar_common/templates/dashboard_operation.html +++ /dev/null @@ -1,510 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load range %} -{% block extra_head %} -{{form.media}} -{% endblock %} -{% block content %} -
-

{% trans "Operations" %}

-
-

{% trans "Global informations" %}

- -
- - - - - - {% for lbl, nb in dashboard.total %} - - - - {% endfor %} -
{% trans "Total" %}
{% trans "Status" %}{% trans "Number" %}
{{lbl}}{{nb}}
- -
- - - - - - {% for surface in dashboard.surface_by_type %} - - - - {% endfor %} -
{% trans "Area by type of operation" %}
{% trans "Status" %}{% trans "Area (m²)" %}
{{surface.operation_type__label}}{{surface.number}}
- -
- - - - {%for typ in dashboard.types %}{% endfor %} - - {% for lbl, types in dashboard.by_type %} - - {%for nb in types %}{% endfor %} - - {% endfor %} -
{% trans "By types" %}
{% trans "State" %}{{typ.label}}
{{lbl}}{{nb}}
- -
- - - - {%for yr in dashboard.years %}{% endfor %} - - {% for lbl, years in dashboard.by_year %} - - {%for nb in years %}{% endfor %} - - {% endfor %} -
{% trans "By year" %}
{% trans "State" %}{{yr}}
{{lbl}}{{nb}}
- -
- - - - {%for yr in dashboard.realisation_years %}{% endfor %} - - {% for lbl, years in dashboard.by_realisation_year %} - - {%for nb in years %}{% endfor %} - - {% endfor %} -
{% trans "By realisation year" %}
{% trans "State" %}{{yr.year}}
{{lbl}}{{nb}}
- -
- - - - {%for yr in dashboard.years %}{% endfor %} - - {% for lbl, years in dashboard.effective %} - - {%for nb in years %}{% endfor %} - - {% endfor %} -
{% trans "Effective operation by type and year" %}
{% trans "Type" %}{{yr}}
{{lbl}}{{nb}}
- -
- - - - {%for mt in dashboard.last_months %}{% endfor %} - - {% for lbl, months in dashboard.by_realisation_month %} - - {%for nb in months %}{% endfor %} - - {% endfor %} -
{% trans "By realisation month" %}
{% trans "State" %}{{mt.date|date:"F Y"|capfirst}}
{{lbl}}{{nb}}
- -
-
- -

{% trans "Survey informations" %}

- -
- - - - - - {% for lbl, nb in dashboard.survey.total %} - - - - {% endfor %} -
{% trans "Total" %}
{% trans "Status" %}{% trans "Number" %}
{{lbl}}{{nb}}
- -
- - - - {%for yr in dashboard.years %}{% endfor %} - - {% for lbl, years in dashboard.survey.by_year %} - - {%for nb in years %}{% endfor %} - - {% endfor %} -
{% trans "By year" %}
{% trans "State" %}{{yr}}
{{lbl}}{{nb}}
- -
- - - - {%for yr in dashboard.realisation_years %}{% endfor %} - - {% for lbl, years in dashboard.survey.by_realisation_year %} - - {%for nb in years %}{% endfor %} - - {% endfor %} -
{% trans "By realisation year" %}
{% trans "State" %}{{yr.year}}
{{lbl}}{{nb}}
- -
- - - - {% for lbl in dashboard.filters_label %}{%endfor%} - - - {% for nb in dashboard.survey.area %}{%endfor%} - - - {% for nb in dashboard.survey.manday %}{%endfor%} - - - {% for nb in dashboard.survey.mandayhect %}{%endfor%} - -
{% trans "Current year" %}
{% trans "Status" %}{{lbl}}
{% trans "Area"%}{{nb}}
{% trans "Man-day"%}{{nb}}
{% trans "Man-day/hectare"%}{{nb}}
- -

{% trans "Man-day/hectare for effective operations (current year):" %} {{dashboard.survey.mandayhect_effective}}

- -
- - - - - - {% for org in dashboard.survey.org %} - - - - {% endfor %} -
{% trans "Organizations (current year)" %}
 {% trans "Area" %}{% trans "Man-day" %}{% trans "Man-day/hectare" %}
{{org.in_charge__attached_to__name}}{{org.area}}{{org.manday}}{{org.mandayhect}}
- -
- - - - {% for lbl in dashboard.filters_label %}{%endfor%} - - - {% for nb in dashboard.survey.area_realised %}{%endfor%} - - - {% for nb in dashboard.survey.manday_realised %}{%endfor%} - - - {% for nb in dashboard.survey.mandayhect_realised %}{%endfor%} - -
{% trans "Current realisation year" %}
{% trans "Status" %}{{lbl}}
{% trans "Area"%}{{nb}}
{% trans "Man-day"%}{{nb}}
{% trans "Man-day/hectare"%}{{nb}}
- -

{% trans "Man-day/hectare for effective operations (current realisation year):" %} {{dashboard.survey.mandayhect_real_effective}}

- -
- - - - - - {% for org in dashboard.survey.org_realised %} - - - - {% endfor %} -
{% trans "Organizations (current realisation year)" %}
 {% trans "Area" %}{% trans "Man-day" %}{% trans "Man-day/hectare" %}
{{org.in_charge__attached_to__name}}{{org.area}}{{org.manday}}{{org.mandayhect}}
- -
- - - - {% for yr in dashboard.years%}{% endfor %} - - {% for org, vals in dashboard.survey.org_by_year %} - - {% for area, cost in vals %}{% endfor %} - - {% endfor %} - - {% for area in dashboard.survey.org_by_year_area_mean %}{% endfor %} - -
{% trans "Area by organization by year" %}
{% trans "Organization" %}{{yr}}
{{org}}{{area}}
{% trans "Mean" %}{{area}}
- -
- - - - {% for yr in dashboard.years%}{% endfor %} - - - {% for nb, mean in dashboard.survey.effective %}{% endfor %} - - - {% for nb, avg in dashboard.survey.effective %}{% endfor %} - -
{% trans "Effective operations areas (m²)" %}
 {{yr}}
{% trans "Sum" %}{{nb}}
{% trans "Average" %}{{avg}}
- -
- - - - {% for yr in dashboard.years%}{% endfor %} - - - {% for nb, mean in dashboard.survey.mandayshect %}{% endfor %} - - - {% for nb, avg in dashboard.survey.mandayshect %}{% endfor %} - -
{% trans "Man-Days/hectare by Year" %}
 {{yr}}
{% trans "Man-Days/hectare" %}{{nb}}
{% trans "Average" %}{{avg}}
- -
- - - - {%for mt in dashboard.last_months %}{% endfor %} - - {% for lbl, months in dashboard.survey.by_month %} - - {%for nb in months %}{% endfor %} - - {% endfor %} -
{% trans "By month" %}
{% trans "State" %}{{mt.date|date:"F Y"|capfirst}}
{{lbl}}{{nb}}
- -
- - - - {%for yr in dashboard.years %}{% endfor %} - - {% for lbl, years in dashboard.survey.by_dpt %} - - {%for nb in years %}{{nb}}{% endfor %} - - {% endfor %} -
{% trans "By department" %}
{% trans "Department" %}{{yr}}{% trans "Sum" %}
{{lbl}}
- -
- - - - {%for yr in dashboard.years %}{% endfor %} - - - {%for yr in dashboard.years %}{% endfor %} - - {% for lbl, years in dashboard.survey.effective_by_dpt %} - - {%for nb, area, cost, fnap in years %}{{nb}}{{area}}{% endfor %} - - {% endfor %} -
{% trans "Effective operation by department" %}
{% trans "Department" %}{{yr}}{% trans "Sum" %}
{%trans "Nb."%}{%trans "Area"%}{%trans "Nb."%}{%trans "Area"%}
{{lbl}}
- -
- - - - - - {% for lbl, nb in dashboard.survey.towns %} - - - - {% endfor %} -
{% trans "Main towns by number" %}
{% trans "Town" %}{% trans "Number" %}
{{lbl}}{{nb}}
- -
- - - - - - {% for lbl, nb in dashboard.survey.towns_surface %} - - - - {% endfor %} -
{% trans "Main towns by surface" %}
{% trans "Town" %}{% trans "Total surface (m²)" %}
{{lbl}}{{nb}}
- - -
-
- -

{% trans "Excavation informations" %}

- -
- - - - - - {% for lbl, nb in dashboard.excavation.total %} - - - - {% endfor %} -
{% trans "Total" %}
{% trans "Status" %}{% trans "Number" %}
{{lbl}}{{nb}}
- -
- - - - {%for yr in dashboard.years %}{% endfor %} - - {% for lbl, years in dashboard.excavation.by_year %} - - {%for nb in years %}{% endfor %} - - {% endfor %} -
{% trans "By year" %}
{% trans "State" %}{{yr}}
{{lbl}}{{nb}}
- -
- - - - {%for yr in dashboard.realisation_years %}{% endfor %} - - {% for lbl, years in dashboard.excavation.by_realisation_year %} - - {%for nb in years %}{% endfor %} - - {% endfor %} -
{% trans "By realisation year" %}
{% trans "State" %}{{yr.year}}
{{lbl}}{{nb}}
- -
- - - - {% for lbl in dashboard.filters_label %}{%endfor%} - - - {% for nb in dashboard.excavation.area_realised %}{%endfor%} - - - {% for nb in dashboard.excavation.manday_realised %}{%endfor%} - - - {% for nb in dashboard.excavation.mandayhect_realised %}{%endfor%} - -
{% trans "Current realisation year" %}
{% trans "Status" %}{{lbl}}
{% trans "Area"%}{{nb}}
{% trans "Man-day"%}{{nb}}
{% trans "Man-day/hectare"%}{{nb}}
- -

{% trans "Man-day/hectare for effective operations (current realisation year):" %} {{dashboard.excavation.mandayhect_real_effective}}

- -
- - - - - - {% for org in dashboard.excavation.org_realised %} - - - - {% endfor %} -
{% trans "Organizations (current realisation year)" %}
 {% trans "Area" %}{% trans "Man-day" %}{% trans "Man-day/hectare" %}
{{org.in_charge__attached_to__name}}{{org.area}}{{org.manday}}{{org.mandayhect}}
- -
- - - - {% for yr in dashboard.years%}{% endfor %} - - {% for org, vals in dashboard.excavation.org_by_year %} - - {% for area, cost in vals %}{% endfor %} - - {% endfor %} - - {% for area in dashboard.excavation.org_by_year_area_sum %}{% endfor %} - - - {% for area in dashboard.excavation.org_by_year_area_mean %}{% endfor %} - -
{% trans "Area by organization by year" %}
{% trans "Organization" %}{{yr}}
{{org}}{{area}}
{% trans "Sum" %}{{area}}
{% trans "Mean" %}{{area}}
- -
- - - - {% for yr in dashboard.years%}{% endfor %} - - {% for org, vals in dashboard.excavation.org_by_year %} - - {% for area, cost in vals %}{% endfor %} - - {% endfor %} - - {% for area in dashboard.excavation.org_by_year_area_sum %}{% endfor %} - - - {% for area in dashboard.excavation.org_by_year_area_mean %}{% endfor %} - -
{% trans "Area by organization by realisation year" %}
{% trans "Organization" %}{{yr}}
{{org}}{{area}}
{% trans "Sum" %}{{area}}
{% trans "Mean" %}{{area}}
- -
- - - - {%for mt in dashboard.last_months %}{% endfor %} - - {% for lbl, months in dashboard.excavation.by_month %} - - {%for nb in months %}{% endfor %} - - {% endfor %} -
{% trans "By month" %}
{% trans "State" %}{{mt.date|date:"F Y"|capfirst}}
{{lbl}}{{nb}}
- -
- - - - {%for yr in dashboard.years %}{% endfor %} - - {% for lbl, years in dashboard.excavation.by_dpt %} - - {%for nb in years %}{{nb}}{% endfor %} - - {% endfor %} -
{% trans "By department" %}
{% trans "Department" %}{{yr}}{% trans "Sum" %}
{{lbl}}
- -
- - - - {%for yr in dashboard.years %}{% endfor %} - - - {%for yr in dashboard.years %}{% endfor %} - - {% for lbl, years in dashboard.excavation.effective_by_dpt %} - - {%for nb, area, cost, fnap in years %}{{nb}}{{cost}}{{fnap}}{% endfor %} - - {% endfor %} -
{% trans "Effective operation by department" %}
{% trans "Department" %}{{yr}}{% trans "Sum" %}
{%trans "Nb."%}{%trans "Cost"%}{%trans "FNAP cost"%}{%trans "Nb."%}{%trans "Cost"%}{%trans "FNAP cost"%}
{{lbl}}
- -
- - - - - - {% for lbl, nb in dashboard.excavation.towns %} - - - - {% endfor %} -
{% trans "Main towns by number" %}
{% trans "Town" %}{% trans "Number" %}
{{lbl}}{{nb}}
- -
- - - - - - {% for lbl, nb in dashboard.excavation.towns_cost %} - - - - {% endfor %} -
{% trans "Main towns by cost" %}
{% trans "Town" %}{% trans "Cost (€)" %}
{{lbl}}{{nb}}
- - -
-
-{% endblock %} diff --git a/ishtar_common/templates/ishtar/dashboards/dashboard_main.html b/ishtar_common/templates/ishtar/dashboards/dashboard_main.html new file mode 100644 index 000000000..e710dbe16 --- /dev/null +++ b/ishtar_common/templates/ishtar/dashboards/dashboard_main.html @@ -0,0 +1,82 @@ +{% extends "base.html" %} +{% load i18n %} +{% load range %} +{% block extra_head %} +{{form.media}} +{% endblock %} +{% block content %} +
+{% for lbl, dashboard in items %} +
+

{{lbl}}

+

{% trans "Numbers" %}

+

{% trans "Total:" %} {{dashboard.total_number}}

+
+ + {% for idx, lbl, values in dashboard.values %} + + + {% for value in values %}{% endfor%} + + {% endfor%} +
{{lbl}}{{value}}
+
+ {% if dashboard.years %} +

{% trans "By years" %}

+
    +
  • {% trans "Average:" %} {{dashboard.average}}
  • +
  • {% trans "Variance:" %} {{dashboard.variance}}
  • +
  • {% trans "Standard deviation:" %} {{dashboard.standard_deviation}}
  • +
  • {% trans "Median:" %} {{dashboard.median}}
  • +
  • {% trans "Mode:" %} {{dashboard.mode}}
  • +
+ {% endif %} + {% if dashboard.operation_average %} +

{% trans "By operations" %}

+
    +
  • {% trans "Average:" %} {{dashboard.operation_average}}
  • +
  • {% trans "Variance:" %} {{dashboard.operation_variance}}
  • +
  • {% trans "Standard deviation:" %} {{dashboard.operation_standard_deviation}}
  • +
  • {% trans "Median:" %} {{dashboard.operation_median}}
  • +
  • {% trans "Mode:" %} {{dashboard.operation_mode}}
  • +
+ {% endif %} +

{% trans "Created last" %}

+
+ + + {% for item in dashboard.lasts %} + + + + {% endfor %} +
{{lbl}}{% trans "Created" %}
{{item}}{{item.history_date}}{% if item.get_show_url %}{%trans "Show"%}{%endif%}
+
+

{% trans "Recent changes" %}

+
+ + + {% for item in dashboard.recents %} + + + + {% endfor %} +
{{lbl}}{% trans "Modified" %}
{{item}}{{item.history_date}}{% if item.get_show_url %}{%trans "Show"%}{%endif%}
+
+
+{% endfor%} +
+

{% trans "Users" %}

+
+ + + {% for user_type in ishtar_users.types %} + + + + + {% endfor%} +
{% trans "User type" %}{% trans "Number" %}
{{user_type.person__person_type__label}}{{user_type.number}}
+
+
+{% endblock %} diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index cebea1dbe..597327379 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -48,8 +48,8 @@ actions = r"|".join(actions) # other views urlpatterns += patterns('ishtar_common.views', # General - url(r'(?P' + actions + r')/$', 'action', - name='action'), + url(r'dashboard-main/$', 'dashboard_main', + name='dashboard-main'), url(r'update-current-item/$', 'update_current_item', name='update-current-item'), url(r'new-person/(?P.+)?/$', @@ -66,4 +66,6 @@ urlpatterns += patterns('ishtar_common.views', 'new_organization', name='new-organization'), url(r'autocomplete-organization/([0-9_]+)?$', 'autocomplete_organization', name='autocomplete-organization'), + url(r'(?P' + actions + r')/$', 'action', + name='action'), ) diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 6c682c932..d0a5af7b7 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -535,6 +535,7 @@ def action(request, action_slug, obj_id=None, *args, **kwargs): associated_wizard = action_slug + '_wizard' dct = {} globals_dct = globals() + print action_slug if action_slug in globals_dct: return globals_dct[action_slug](request, dct, obj_id, *args, **kwargs) elif hasattr(ishtar_forms, action_slug + "_wizard"): @@ -547,12 +548,20 @@ def dashboard_main(request, dct, obj_id=None, *args, **kwargs): """ Main dashboard """ - dct = {'items':[ - (_(u"Archaeological files"), models.Dashboard(models.File)), - (_(u"Operations"), models.Dashboard(models.Operation)), - (_(u"Context records"), models.Dashboard(models.ContextRecord)), - (_(u"Archaeological items"), models.Dashboard(models.Item)), - ], + items = [] + if 'archaeological_files' in settings.INSTALLED_APPS: + from archaeological_files.models import File + items.append((_(u"Archaeological files"), + models.Dashboard(File))) + from archaeological_operations.models import Operation + items.append((_(u"Operations"), models.Dashboard(Operation))) + if 'archaeological_context_records' in settings.INSTALLED_APPS: + from archaeological_context_records.models import ContextRecord + items.append((_(u"Context records"), models.Dashboard(ContextRecord))) + if 'archaeological_finds' in settings.INSTALLED_APPS: + from archaeological_finds.models import Find + items.append((_(u"Context records"), models.Dashboard(Find))) + dct = {'items':items, 'ishtar_users':models.UserDashboard()} - return render_to_response('dashboard_main.html', dct, + return render_to_response('ishtar/dashboards/dashboard_main.html', dct, context_instance=RequestContext(request)) -- cgit v1.2.3