From 2e15f5fd3525120d22336faf10e960050aaefb67 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 16 Nov 2022 18:05:49 +0100 Subject: Remove deadcode (old dashboards) - clean css --- archaeological_operations/ishtar_menu.py | 17 - archaeological_operations/models.py | 531 --------------- .../ishtar/dashboards/dashboard_operation.html | 721 --------------------- archaeological_operations/tests.py | 18 - archaeological_operations/urls.py | 3 - archaeological_operations/views.py | 8 - 6 files changed, 1298 deletions(-) delete mode 100644 archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html (limited to 'archaeological_operations') diff --git a/archaeological_operations/ishtar_menu.py b/archaeological_operations/ishtar_menu.py index 2ad6dc259..b58fb5078 100644 --- a/archaeological_operations/ishtar_menu.py +++ b/archaeological_operations/ishtar_menu.py @@ -164,20 +164,3 @@ MENU_SECTIONS = [ ), ), ] -""" - ( - 102, SectionItem( - 'dashboard', _("Dashboard"), - css='menu-operation', - childs=[ - MenuItem( - 'dashboard_main', _("General informations"), - model=models.Operation, - access_controls=['change_operation']), - MenuItem( - 'dashboard_operation', _("Operations"), - model=models.Operation, - access_controls=['change_operation']), - ]), - ), -""" diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 9e038adeb..57f538383 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -3299,537 +3299,6 @@ class ParcelOwner(LightHistorizedItem): return self.parcel.associated_file -class OperationDashboard: - def __init__(self): - main_dashboard = Dashboard(Operation) - - self.total_number = main_dashboard.total_number - - self.filters_keys = [ - "recorded", - "effective", - "active", - "field", - "documented", - "closed", - "documented_closed", - ] - filters = { - "recorded": {}, - "effective": {"scientist__isnull": False}, - "active": {"scientist__isnull": False, "end_date__isnull": True}, - "field": {"excavation_end_date__isnull": True}, - "documented": {"documents__isnull": False}, - "documented_closed": { - "documents__isnull": False, - "end_date__isnull": False, - }, - "closed": {"end_date__isnull": False}, - } - filters_label = { - "recorded": _("Recorded"), - "effective": _("Effective"), - "active": _("Active"), - "field": _("Field completed"), - "documented": _("Associated report"), - "closed": _("Closed"), - "documented_closed": _("Documented and closed"), - } - self.filters_label = [filters_label[k] for k in self.filters_keys] - self.total = [] - for fltr_key in self.filters_keys: - fltr, lbl = filters[fltr_key], filters_label[fltr_key] - nb = Operation.objects.filter(**fltr).count() - self.total.append((lbl, nb)) - - self.surface_by_type = ( - Operation.objects.values("operation_type__label") - .annotate(number=Sum("surface")) - .order_by("-number", "operation_type__label") - ) - - self.by_type = [] - self.types = OperationType.objects.filter(available=True).all() - for fltr_key in self.filters_keys: - fltr, lbl = filters[fltr_key], filters_label[fltr_key] - type_res = ( - Operation.objects.filter(**fltr) - .values("operation_type", "operation_type__label") - .annotate(number=Count("pk")) - .order_by("operation_type") - ) - types_dct = {} - for typ in type_res.all(): - types_dct[typ["operation_type"]] = typ["number"] - types = [] - for typ in self.types: - if typ.pk in types_dct: - types.append(types_dct[typ.pk]) - else: - types.append(0) - self.by_type.append((lbl, types)) - - self.by_year = [] - self.years = [ - res["year"] - for res in Operation.objects.values("year").order_by("-year").distinct() - ] - for fltr_key in self.filters_keys: - fltr, lbl = filters[fltr_key], filters_label[fltr_key] - year_res = ( - Operation.objects.filter(**fltr) - .values("year") - .annotate(number=Count("pk")) - .order_by("year") - ) - years_dct = {} - for yr in year_res.all(): - years_dct[yr["year"]] = yr["number"] - years = [] - for yr in self.years: - if yr in years_dct: - years.append(years_dct[yr]) - else: - years.append(0) - self.by_year.append((lbl, years)) - - self.by_realisation_year = [] - self.realisation_years = [ - res["date"] - for res in Operation.objects.extra( - {"date": "date_trunc('year', start_date)"} - ) - .values("date") - .filter(start_date__isnull=False) - .order_by("-date") - .distinct() - ] - for fltr_key in self.filters_keys: - fltr, lbl = filters[fltr_key], filters_label[fltr_key] - year_res = ( - Operation.objects.filter(**fltr) - .extra({"date": "date_trunc('year', start_date)"}) - .values("date") - .values("date") - .filter(start_date__isnull=False) - .annotate(number=Count("pk")) - .order_by("-date") - ) - years_dct = {} - for yr in year_res.all(): - years_dct[yr["date"]] = yr["number"] - years = [] - for yr in self.realisation_years: - if yr in years_dct: - years.append(years_dct[yr]) - else: - years.append(0) - self.by_realisation_year.append((lbl, years)) - - self.effective = [] - for typ in self.types: - year_res = ( - Operation.objects.filter( - **{"scientist__isnull": False, "operation_type": typ} - ) - .values("year") - .annotate(number=Count("pk")) - .order_by("-year") - .distinct() - ) - years_dct = {} - for yr in year_res.all(): - years_dct[yr["year"]] = yr["number"] - years = [] - for yr in self.years: - if yr in years_dct: - years.append(years_dct[yr]) - else: - years.append(0) - self.effective.append((typ, years)) - - # TODO: by date - now = datetime.date.today() - limit = datetime.date(now.year, now.month, 1) - datetime.timedelta(365) - by_realisation_month = Operation.objects.filter( - start_date__gt=limit, start_date__isnull=False - ).extra({"date": "date_trunc('month', start_date)"}) - self.last_months = [] - date = datetime.datetime(now.year, now.month, 1) - for mt_idx in range(12): - self.last_months.append(date) - if date.month > 1: - date = datetime.datetime(date.year, date.month - 1, 1) - else: - date = datetime.datetime(date.year - 1, 12, 1) - self.by_realisation_month = [] - for fltr_key in self.filters_keys: - fltr, lbl = filters[fltr_key], filters_label[fltr_key] - month_res = ( - by_realisation_month.filter(**fltr) - .annotate(number=Count("pk")) - .order_by("-date") - ) - month_dct = {} - for mt in month_res.all(): - month_dct[mt.date] = mt.number - date = datetime.date(now.year, now.month, 1) - months = [] - for date in self.last_months: - if date in month_dct: - months.append(month_dct[date]) - else: - months.append(0) - self.by_realisation_month.append((lbl, months)) - - # survey and excavations - self.survey, self.excavation = {}, {} - for dct_res, ope_types in ( - (self.survey, ("arch_diagnostic",)), - (self.excavation, ("prev_excavation", "prog_excavation")), - ): - dct_res["total"] = [] - operation_type = {"operation_type__txt_idx__in": ope_types} - for fltr_key in self.filters_keys: - fltr, lbl = filters[fltr_key], filters_label[fltr_key] - fltr.update(operation_type) - nb = Operation.objects.filter(**fltr).count() - dct_res["total"].append((lbl, nb)) - - dct_res["by_year"] = [] - for fltr_key in self.filters_keys: - fltr, lbl = filters[fltr_key], filters_label[fltr_key] - fltr.update(operation_type) - year_res = ( - Operation.objects.filter(**fltr) - .values("year") - .annotate(number=Count("pk")) - .order_by("year") - ) - years_dct = {} - for yr in year_res.all(): - years_dct[yr["year"]] = yr["number"] - years = [] - for yr in self.years: - if yr in years_dct: - years.append(years_dct[yr]) - else: - years.append(0) - dct_res["by_year"].append((lbl, years)) - - dct_res["by_realisation_year"] = [] - for fltr_key in self.filters_keys: - fltr, lbl = filters[fltr_key], filters_label[fltr_key] - fltr.update(operation_type) - year_res = ( - Operation.objects.filter(**fltr) - .extra({"date": "date_trunc('year', start_date)"}) - .values("date") - .filter(start_date__isnull=False) - .annotate(number=Count("pk")) - .order_by("-date") - ) - years_dct = {} - for yr in year_res.all(): - years_dct[yr["date"]] = yr["number"] - years = [] - for yr in self.realisation_years: - if yr in years_dct: - years.append(years_dct[yr]) - else: - years.append(0) - dct_res["by_realisation_year"].append((lbl, years)) - - current_year_ope = Operation.objects.filter(**operation_type).filter( - year=datetime.date.today().year - ) - current_realisation_year_ope = Operation.objects.filter( - **operation_type - ).filter(start_date__year=datetime.date.today().year) - res_keys = [("area_realised", current_realisation_year_ope)] - if dct_res == self.survey: - res_keys.append(("area", current_year_ope)) - for res_key, base_ope in res_keys: - dct_res[res_key] = [] - for fltr_key in self.filters_keys: - fltr, lbl = filters[fltr_key], filters_label[fltr_key] - area_res = ( - base_ope.filter(**fltr).annotate(number=Sum("surface")).all() - ) - val = 0 - if area_res: - val = (area_res[0].number or 0) / 10000.0 - dct_res[res_key].append(val) - # TODO... - res_keys = [("manday_realised", current_realisation_year_ope)] - if dct_res == self.survey: - res_keys.append(("manday", current_year_ope)) - for res_key, base_ope in res_keys: - dct_res[res_key] = [] - for fltr_key in self.filters_keys: - dct_res[res_key].append("-") - # TODO... - res_keys = [("mandayhect_realised", current_realisation_year_ope)] - if dct_res == self.survey: - res_keys.append(("mandayhect", current_year_ope)) - for res_key, base_ope in res_keys: - dct_res[res_key] = [] - for fltr_key in self.filters_keys: - dct_res[res_key].append("-") - # TODO... - dct_res["mandayhect_real_effective"] = "-" - if dct_res == self.survey: - dct_res["mandayhect_effective"] = "-" - - res_keys = [("org_realised", current_realisation_year_ope)] - if dct_res == self.survey: - res_keys.append(("org", current_year_ope)) - for res_key, base_ope in res_keys: - org_res = ( - base_ope.filter(scientist__attached_to__isnull=False) - .values("scientist__attached_to", "scientist__attached_to__name") - .annotate(area=Sum("surface")) - .order_by("scientist__attached_to__name") - .all() - ) - # TODO: man-days, man-days/hectare - - dct_res[res_key] = [] - for vals in org_res: - vals["area"] = (vals["area"] or 0) / 10000.0 - dct_res[res_key].append(vals) - - year_ope = Operation.objects.filter(**operation_type) - res_keys = ["org_by_year"] - if dct_res == self.survey: - res_keys.append("org_by_year_realised") - q = ( - year_ope.values( - "scientist__attached_to", "scientist__attached_to__name" - ) - .filter(scientist__attached_to__isnull=False) - .order_by("scientist__attached_to__name") - .distinct() - ) - org_list = [ - (org["scientist__attached_to"], org["scientist__attached_to__name"]) - for org in q - ] - # org_list_dct = dict(org_list) - for res_key in res_keys: - dct_res[res_key] = [] - years = self.years - if res_key == "org_by_year_realised": - years = self.realisation_years - for org_id, org_label in org_list: - org_res = year_ope.filter(scientist__attached_to__pk=org_id) - key_date = "" - if res_key == "org_by_year": - org_res = org_res.values("year") - key_date = "year" - else: - org_res = ( - org_res.extra({"date": "date_trunc('year', start_date)"}) - .values("date") - .filter(start_date__isnull=False) - ) - key_date = "date" - org_res = org_res.annotate(area=Sum("surface"), cost=Sum("cost")) - years_dct = {} - for yr in org_res.all(): - area = (yr["area"] if yr["area"] else 0) / 10000.0 - cost = yr["cost"] if yr["cost"] else 0 - years_dct[yr[key_date]] = (area, cost) - r_years = [] - for yr in years: - if yr in years_dct: - r_years.append(years_dct[yr]) - else: - r_years.append((0, 0)) - dct_res[res_key].append((org_label, r_years)) - area_means, area_sums = [], [] - cost_means, cost_sums = [], [] - for idx, year in enumerate(years): - vals = [r_yars[idx] for lb, r_yars 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)) - area_sums.append(sum_area) - cost_means.append(sum_cost / len(vals)) - cost_sums.append(sum_cost) - dct_res[res_key + "_area_mean"] = area_means - dct_res[res_key + "_area_sum"] = area_sums - dct_res[res_key + "_cost_mean"] = cost_means - dct_res[res_key + "_cost_mean"] = cost_sums - - if dct_res == self.survey: - self.survey["effective"] = [] - for yr in self.years: - year_res = Operation.objects.filter( - scientist__isnull=False, - year=yr, - operation_type__txt_idx__in=ope_types, - ).annotate(number=Sum("surface"), mean=Avg("surface")) - nb = year_res[0].number if year_res.count() else 0 - nb = nb if nb else 0 - mean = year_res[0].mean if year_res.count() else 0 - mean = mean if mean else 0 - self.survey["effective"].append((nb, mean)) - - # TODO:Man-Days/hectare by Year - - # CHECK: month of realisation or month? - dct_res["by_month"] = [] - for fltr_key in self.filters_keys: - fltr, lbl = filters[fltr_key], filters_label[fltr_key] - fltr.update(operation_type) - month_res = ( - by_realisation_month.filter(**fltr) - .annotate(number=Count("pk")) - .order_by("-date") - ) - month_dct = {} - for mt in month_res.all(): - month_dct[mt.date] = mt.number - date = datetime.date(now.year, now.month, 1) - months = [] - for date in self.last_months: - if date in month_dct: - months.append(month_dct[date]) - else: - months.append(0) - dct_res["by_month"].append((lbl, months)) - - operation_type = {"operation_type__txt_idx__in": ope_types} - self.departments = [ - (fd["department__pk"], fd["department__label"]) - for fd in OperationByDepartment.objects.filter(department__isnull=False) - .values("department__label", "department__pk") - .order_by("department__label") - .distinct() - ] - dct_res["by_dpt"] = [] - for dpt_id, dpt_label in self.departments: - vals = ( - OperationByDepartment.objects.filter( - department__pk=dpt_id, - operation__operation_type__txt_idx__in=ope_types, - ) - .values("department__pk", "operation__year") - .annotate(number=Count("operation")) - .order_by("operation__year") - ) - dct_years = {} - for v in vals: - dct_years[v["operation__year"]] = v["number"] - years = [] - for y in self.years: - if y in dct_years: - years.append(dct_years[y]) - else: - years.append(0) - years.append(sum(years)) - dct_res["by_dpt"].append((dpt_label, years)) - dct_res["effective_by_dpt"] = [] - for dpt_id, dpt_label in self.departments: - vals = ( - OperationByDepartment.objects.filter( - department__pk=dpt_id, - operation__scientist__isnull=False, - operation__operation_type__txt_idx__in=ope_types, - ) - .values("department__pk", "operation__year") - .annotate( - number=Count("operation"), - area=Sum("operation__surface"), - fnap=Sum("operation__fnap_cost"), - cost=Sum("operation__cost"), - ) - .order_by("operation__year") - ) - dct_years = {} - for v in vals: - values = [] - for k in ("number", "area", "cost", "fnap"): - value = v[k] or 0 - if k == "area": - value /= 10000.0 - values.append(value) - - dct_years[v["operation__year"]] = values - years = [] - for y in self.years: - if y in dct_years: - years.append(dct_years[y]) - else: - years.append((0, 0, 0, 0)) - nbs, areas, costs, fnaps = zip(*years) - years.append((sum(nbs), sum(areas), sum(costs), sum(fnaps))) - dct_res["effective_by_dpt"].append((dpt_label, years)) - - OperationTown = Operation.towns.through - query = ( - OperationTown.objects.filter( - operation__scientist__isnull=False, - operation__operation_type__txt_idx__in=ope_types, - ) - .values("town__name", "town__departement__number") - .annotate(nb=Count("operation")) - .order_by("-nb", "town__name")[:10] - ) - dct_res["towns"] = [] - for r in query: - dct_res["towns"].append( - ( - "%s (%s)" % (r["town__name"], r["town__departement__number"]), - r["nb"], - ) - ) - - if dct_res == self.survey: - query = ( - OperationTown.objects.filter( - operation__scientist__isnull=False, - operation__operation_type__txt_idx__in=ope_types, - operation__surface__isnull=False, - ) - .values("town__name", "town__departement__number") - .annotate(nb=Sum("operation__surface")) - .order_by("-nb", "town__name")[:10] - ) - dct_res["towns_surface"] = [] - for r in query: - dct_res["towns_surface"].append( - ( - "%s (%s)" - % (r["town__name"], r["town__departement__number"]), - r["nb"], - ) - ) - else: - query = ( - OperationTown.objects.filter( - operation__scientist__isnull=False, - operation__operation_type__txt_idx__in=ope_types, - operation__cost__isnull=False, - ) - .values("town__name", "town__departement__number") - .annotate(nb=Sum("operation__cost")) - .order_by("-nb", "town__name")[:10] - ) - dct_res["towns_cost"] = [] - for r in query: - dct_res["towns_cost"].append( - ( - "%s (%s)" - % (r["town__name"], r["town__departement__number"]), - r["nb"], - ) - ) - - class OperationTypeOld(GeneralType): order = models.IntegerField(_("Order"), default=1) preventive = models.BooleanField(_("Is preventive"), default=True) diff --git a/archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html b/archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html deleted file mode 100644 index 19302cd05..000000000 --- a/archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html +++ /dev/null @@ -1,721 +0,0 @@ -{% extends "base.html" %} -{% load i18n range units humanize %} -{% block extra_head %} -{{form.media}} -{% endblock %} -{% block content %} - -

{% trans "Operations" %}

- -
-

{% trans "Global informations" %}

-
-
-

{% trans "total" %}

-
- - - - - {% for lbl, nb in dashboard.total %} - - - - {% endfor %} -
{% trans "Status" %}{% trans "Number" %}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "area by type of operation" %}

-
- - - - - {% for surface in dashboard.surface_by_type %} - - - - {% endfor %} -
{% trans "Status" %}{% trans "Area (ha)" %}
{{surface.operation_type__label}}{{surface.number|m2_to_ha|intcomma}}
- -
-

{% trans "by types" %}

-
- - - {% for typ in dashboard.types %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - - {% endfor %} - - {% for lbl, types in dashboard.by_type %} - - {%for nb in types %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% endfor %} -
{% trans "State" %}{{typ.label}}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "by year" %}

-
- - - {% for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - {% endfor %} - - {% for lbl, years in dashboard.by_year %} - - {% for nb in years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - - {% endfor %} - - {% endfor %} -
{% trans "State" %}{{yr|default_if_none:''}}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "by realisation year" %}

-
- - - {%for yr in dashboard.realisation_years %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - {% endfor %} - - {% for lbl, years in dashboard.by_realisation_year %} - - {% for nb in years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - - {% endfor %} - - {% endfor %} -
{% trans "State" %}{{yr.year|default_if_none:''}}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "effective operation by type and year" %}

-
- - {% for lbl, years in dashboard.effective %} - - {% if forloop.counter0|divisibleby:6 %} - - {%for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - {% endfor %} - - {% endif %} - - {% for nb in years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - - {% endfor %} - - {% endfor %} -
{{yr|default_if_none:''}}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "by realisation month" %}

-
- - - {%for mt in dashboard.last_months %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - {% endfor %} - - {% for lbl, months in dashboard.by_realisation_month %} - - {%for nb in months %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - - {% endfor %} - - {% endfor %} -
{% trans "State" %}{{mt.date|date:"N Y"|capfirst}}
{{lbl}}{{nb|intcomma}}
- -
- -

{% trans "Survey informations" %}

-
- -
-

{% trans "total" %}

-
- - - - - {% for lbl, nb in dashboard.survey.total %} - - - - {% endfor %} -
{% trans "Status" %}{% trans "Number" %}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "by year" %}

-
- - - {%for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - {% endfor %} - - {% for lbl, years in dashboard.survey.by_year %} - - {% for nb in years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - - {% endfor %} - - {% endfor %} -
{% trans "State" %}{{yr|default_if_none:''}}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "by realisation year" %}

-
- - - {%for yr in dashboard.realisation_years %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - {% endfor %} - - {% for lbl, years in dashboard.survey.by_realisation_year %} - - {% for nb in years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - - {% endfor %} - - {% endfor %} -
{% trans "State" %}{{yr.year|default_if_none:''}}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "current year" %}

-
- - - {% 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%} - -
{{lbl}}
{% trans "Area"%}{{nb|intcomma}}
{% trans "Man-day"%}{{nb|intcomma}}
{% trans "Man-day/hectare"%}{{nb|intcomma}}
-

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

-
-

{% trans "organizations (current year)" %}

-
- - - - - {% for org in dashboard.survey.org %} - - - - {% endfor %} -
 {% trans "Area" %}{% trans "Man-day" %}{% trans "Man-day/hectare" %}
{{org.scientist__attached_to__name}}{{org.area|intcomma}}{{org.manday|intcomma}}{{org.mandayhect|intcomma}}
- -
-

{% trans "current realisation year" %}

-
- - - {% 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 "Status" %}{{lbl}}
{% trans "Area"%}{{nb|intcomma}}
{% trans "Man-day"%}{{nb|intcomma}}
{% trans "Man-day/hectare"%}{{nb|intcomma}}
- -

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

- -
-

{% trans "organizations (current realisation year)" %}

-
- - - - - {% for org in dashboard.survey.org_realised %} - - - - {% endfor %} -
 {% trans "Area" %}{% trans "Man-day" %}{% trans "Man-day/hectare" %}
{{org.scientist__attached_to__name}}{{org.area|intcomma}}{{org.manday|intcomma}}{{org.mandayhect|intcomma}}
-
-

{% trans "area by organization by year" %}

-
- - - - {% for org, vals in dashboard.survey.org_by_year %} - {% if forloop.counter0|divisibleby:4 %} - {% for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - - {% endfor %} - {% endif %} - - - {% for area, cost in vals %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - {% endfor %} - - {% endfor %} - - {% for area in dashboard.survey.org_by_year_area_mean %} - {% if forloop.counter0|divisibleby:5 %} - {% endif%} - {% endfor %} - -
{% trans "Organization" %}{{yr|default_if_none:''}}
{{org}}{{area|intcomma}}
{% trans "Mean" %}{{area|intcomma}}
- -
-

{% trans "effective operations areas (ha)" %}

-
- - - {%for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - {% endfor %} - - - {% for nb, mean in dashboard.survey.effective %} - {% if forloop.counter0|divisibleby:5 %}{%endif%} - {% endfor %} - - - {% for nb, avg in dashboard.survey.effective %} - {% if forloop.counter0|divisibleby:5 %}{%endif%} - {% endfor %} - -
{{yr|default_if_none:''}}
{% trans "Sum" %}{{nb|m2_to_ha|intcomma}}
{% trans "Average" %}{{avg|m2_to_ha|intcomma}}
- -
-

{% trans "man-days/hectare by year" %}

-
- - - {%for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - {% endfor %} - - - {% for nb, mean in dashboard.survey.mandayshect %} - {% if forloop.counter0|divisibleby:5 %}{%endif%} - {% endfor %} - - - {% for nb, avg in dashboard.survey.mandayshect %} - {% if forloop.counter0|divisibleby:5 %} - - {%endif%} - {% endfor %} - -
{{yr|default_if_none:''}}
{% trans "Man-Days/hectare" %}{{nb|intcomma}}
{% trans "Average" %}{{avg|intcomma}}
- -
-

{% trans "by month" %}

-
- - - {% for mt in dashboard.last_months %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% for lbl, months in dashboard.survey.by_month %} - - {%for nb in months %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - - {% endfor %} - - {% endfor %} -
{% trans "State" %}{{mt.date|date:"N Y"|capfirst}}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "by department" %}

-
- - - {% for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:5 %} - - {% endif %} - {% endfor %} - - {% for lbl, years in dashboard.survey.by_dpt %} - - {% for nb in years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {{nb|intcomma}}{% endfor %} - - {% endfor %} -
{% trans "Department" %}{{yr|default_if_none:''}}{% trans "Sum" %}
{{lbl}}
- -
-

{% trans "effective operation by department" %}

-
- - - {% for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:4 %} - {% endif %} - {% endfor %} - - - {%for yr in dashboard.years %}{% endfor %} - - {% for lbl, years in dashboard.survey.effective_by_dpt %} - - {%for nb, area, cost, fnap in years %} - {% if forloop.counter0|divisibleby:4 %} - {% endif %} - {{nb|intcomma}}{{area|intcomma}}{% endfor %} - - {% endfor %} -
{% trans "Department" %}{{yr|default_if_none:''}}{% trans "Sum" %}
{%trans "Nb."%}{%trans "Area"%}{%trans "Nb."%}{%trans "Area"%}
{{lbl}}
- -
-

{% trans "main towns by number" %}

-
- - - - - {% for lbl, nb in dashboard.survey.towns %} - - - - {% endfor %} -
{% trans "Town" %}{% trans "Number" %}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "main towns by surface" %}

-
- - - - - {% for lbl, nb in dashboard.survey.towns_surface %} - - - - {% endfor %} -
{% trans "Town" %}{% trans "Total surface (ha)" %}
{{lbl}}{{nb|m2_to_ha|intcomma}}
-
- -

{% trans "Excavation informations" %}

-
-
-

{% trans "total" %}

-
- - - - - {% for lbl, nb in dashboard.excavation.total %} - - - - {% endfor %} -
{% trans "Status" %}{% trans "Number" %}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "by year" %}

-
- - - {%for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% for lbl, years in dashboard.excavation.by_year %} - - {% for nb in years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% endfor %} -
{% trans "State" %}{{yr|default_if_none:''}}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "by realisation year" %}

-
- - - {% for yr in dashboard.realisation_years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% for lbl, years in dashboard.excavation.by_realisation_year %} - - {% for nb in years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% endfor %} -
{% trans "State" %}{{yr.year}}
{{lbl}}{{nb}}
- -
-

{% trans "current realisation year" %}

-
- - - {% 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 "Status" %}{{lbl}}
{% trans "Area"%}{{nb|default_if_none:'-'|intcomma}}
{% trans "Man-day"%}{{nb|default_if_none:'-'|intcomma}}
{% trans "Man-day/hectare"%}{{nb|default_if_none:'-'|intcomma}}
- -

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

- -
-

{% trans "organizations (current realisation year)" %}

-
- - - - - {% for org in dashboard.excavation.org_realised %} - - - - {% endfor %} -
 {% trans "Area" %}{% trans "Man-day" %}{% trans "Man-day/hectare" %}
{{org.scientist__attached_to__name}}{{org.area|default_if_none:'-'|intcomma}}{{org.manday|default_if_none:'-'|intcomma}}{{org.mandayhect|default_if_none:'-'|intcomma}}
- -
-

{% trans "area by organization by year" %}

-
- - {% for org, vals in dashboard.excavation.org_by_year %} - {% if forloop.counter0|divisibleby:5 %} - - {% for yr in dashboard.years%} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% endif %} - - {% for area, cost in vals %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% endfor %} - - {% for area in dashboard.excavation.org_by_year_area_sum %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - - {% for area in dashboard.excavation.org_by_year_area_mean %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - -
{% trans "Organization" %}{{yr|default_if_none:'-'}}
{{org}}{{area|default_if_none:'-'|intcomma}}
{% trans "Sum" %}{{area|intcomma}}
{% trans "Mean" %}{{area|intcomma}}
- -
-

{% trans "area by organization by realisation year" %}

-
- - {% for org, vals in dashboard.excavation.org_by_year %} - - {% if forloop.counter0|divisibleby:5 %} - - {% for yr in dashboard.years%} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% endif %} - - - {% for area, cost in vals %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% endfor %} - - {% for area in dashboard.excavation.org_by_year_area_sum %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - - {% for area in dashboard.excavation.org_by_year_area_mean %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - -
{% trans "Organization" %}{{yr|default_if_none:'-'}}
{{org}}{{area|default_if_none:'-'|intcomma}}
{% trans "Sum" %}{{area|default_if_none:'-'|intcomma}}
{% trans "Mean" %}{{area|default_if_none:'-'|intcomma}}
- -
-

{% trans "by month" %}

-
- - - {% for mt in dashboard.last_months %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% for lbl, months in dashboard.excavation.by_month %} - - {% for nb in months %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - {% endfor %} -
{% trans "State" %}{{mt.date|date:"N Y"|capfirst}}
{{lbl}}{{nb|default_if_none:'-'|intcomma}}
- -
-

{% trans "by department" %}

-
- - - {% for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {% endfor %} - - - {% for lbl, years in dashboard.excavation.by_dpt %} - - {% for nb in years %} - {% if forloop.counter0|divisibleby:5 %} - {% endif %} - {{nb|default_if_none:'-'|intcomma}}{% endfor %} - - {% endfor %} -
{% trans "Department" %}{{yr|default_if_none:'-'}}{% trans "Sum" %}
{{lbl}}
- -
-

{% trans "effective operation by department" %}

-
- - - {% for yr in dashboard.years %} - {% if forloop.counter0|divisibleby:3 %} - {% endif %} - {% endfor %} - - - - - {% for yr in dashboard.years %}{% endfor %} - - {% for lbl, years in dashboard.excavation.effective_by_dpt %} - - {% for nb, area, cost, fnap in years %} - {% if forloop.counter0|divisibleby:3 %} - {% endif %} - {{nb|intcomma}}{{cost|intcomma}}{{fnap|intcomma}}{% endfor %} - - {% endfor %} -
{% trans "Department" %}{{yr|default_if_none:'-'}}{% trans "Department" %}{% trans "Sum" %}
{%trans "Nb."%}{%trans "Cost"%}{%trans "FNAP cost"%}{%trans "Nb."%}{%trans "Cost"%}{%trans "FNAP cost"%}
{{lbl}}
- -
-

{% trans "main towns by number" %}

-
- - - - - {% for lbl, nb in dashboard.excavation.towns %} - - - - {% endfor %} -
{% trans "Town" %}{% trans "Number" %}
{{lbl}}{{nb|intcomma}}
- -
-

{% trans "main towns by cost" %}

-
- - - - - {% for lbl, nb in dashboard.excavation.towns_cost %} - - - - {% endfor %} -
{% trans "Town" %}{% trans "Cost (euros)" %}
{{lbl}}{{nb|intcomma}}
- - -
-
- -{% endblock %} diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 148ef3ed1..9a5f35d9b 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -3390,24 +3390,6 @@ class LabelTest(TestCase, OperationInitTest): f.close() -class DashboardTest(TestCase, OperationInitTest): - fixtures = FILE_FIXTURES - - def setUp(self): - IshtarSiteProfile.objects.get_or_create(slug="default", active=True) - self.username, self.password, self.user = create_superuser() - self.orgas = self.create_orgas(self.user) - self.operations = self.create_operation(self.user, self.orgas[0]) - - def test_dashboard(self): - url = "dashboard-operation" - c = Client() - c.login(username=self.username, password=self.password) - - response = c.get(reverse(url)) - self.assertEqual(response.status_code, 200) - - def create_administrativact(user, operation): act_type, created = models.ActType.objects.get_or_create( txt_idx="act_type_O", intented_to="O" diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py index c6ecc3281..6c6a2e21c 100644 --- a/archaeological_operations/urls.py +++ b/archaeological_operations/urls.py @@ -216,9 +216,6 @@ urlpatterns = [ views.generatedoc_administrativeactop, name="generatedoc-administrativeactop", ), - url( - r"dashboard_operation/$", views.dashboard_operation, name="dashboard-operation" - ), url( r"autocomplete-administrativeact/$", views.autocomplete_administrativeact, diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index 7d83bb7e0..f15e24c43 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -191,14 +191,6 @@ get_administrativeact = get_item( show_administrativeact = show_item(models.AdministrativeAct, "administrativeact") -def dashboard_operation(request, *args, **kwargs): - """ - Operation dashboard - """ - dct = {"dashboard": models.OperationDashboard()} - return render(request, "ishtar/dashboards/dashboard_operation.html", dct) - - operation_search_wizard = wizards.OperationSearch.as_view( [("general-operation_search", forms.OperationFormSelection)], label=_("Operation search"), -- cgit v1.2.3