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_files/models.py | 148 ----- .../ishtar/dashboards/dashboard_file.html | 251 ------- archaeological_files/tests.py | 18 - archaeological_files/urls.py | 1 - archaeological_files/views.py | 8 - 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 - ishtar_common/static/media/style.css | 141 +--- 12 files changed, 8 insertions(+), 1857 deletions(-) delete mode 100644 archaeological_files/templates/ishtar/dashboards/dashboard_file.html delete mode 100644 archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 9b878ab35..c2992935b 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -1354,154 +1354,6 @@ class FileByDepartment(models.Model): return "{} - {}".format(self.file, self.department) -class FileDashboard: - def __init__(self): - from archaeological_operations.models import AdministrativeAct - - main_dashboard = Dashboard(File) - - self.total_number = main_dashboard.total_number - - types = File.objects.values("file_type", "file_type__label") - self.types = types.annotate(number=Count("pk")).order_by("file_type") - - by_year = File.objects.extra({"date": "date_trunc('year', creation_date)"}) - self.by_year = ( - by_year.values("date").annotate(number=Count("pk")).order_by("-date") - ) - - now = datetime.date.today() - limit = datetime.date(now.year, now.month, 1) - datetime.timedelta(365) - by_month = File.objects.filter(creation_date__gt=limit).extra( - {"date": "date_trunc('month', creation_date)"} - ) - self.by_month = ( - by_month.values("date").annotate(number=Count("pk")).order_by("-date") - ) - - # research - self.research = {} - prog_type = FileType.objects.get(txt_idx="prog") - researchs = File.objects.filter(file_type=prog_type) - self.research["total_number"] = researchs.count() - by_year = researchs.extra({"date": "date_trunc('year', creation_date)"}) - self.research["by_year"] = ( - by_year.values("date").annotate(number=Count("pk")).order_by("-date") - ) - by_month = researchs.filter(creation_date__gt=limit).extra( - {"date": "date_trunc('month', creation_date)"} - ) - self.research["by_month"] = ( - by_month.values("date").annotate(number=Count("pk")).order_by("-date") - ) - - self.research["by_dpt"] = ( - FileByDepartment.objects.filter( - file__file_type=prog_type, department__isnull=False - ) - .values("department__label") - .annotate(number=Count("file")) - .order_by("department__label") - ) - FileTown = File.towns.through - self.research["towns"] = ( - FileTown.objects.filter(file__file_type=prog_type) - .values("town__name") - .annotate(number=Count("file")) - .order_by("-number", "town__name")[:10] - ) - - # rescue - rescue_type = FileType.objects.get(txt_idx="preventive") - rescues = File.objects.filter(file_type=rescue_type) - self.rescue = {} - self.rescue["total_number"] = rescues.count() - self.rescue["saisine"] = ( - rescues.values("saisine_type__label") - .annotate(number=Count("pk")) - .order_by("saisine_type__label") - ) - self.rescue["administrative_act"] = ( - AdministrativeAct.objects.filter(associated_file__isnull=False) - .values("act_type__label") - .annotate(number=Count("pk")) - .order_by("act_type__pk") - ) - - by_year = rescues.extra({"date": "date_trunc('year', creation_date)"}) - self.rescue["by_year"] = ( - by_year.values("date").annotate(number=Count("pk")).order_by("-date") - ) - by_month = rescues.filter(creation_date__gt=limit).extra( - {"date": "date_trunc('month', creation_date)"} - ) - self.rescue["by_month"] = ( - by_month.values("date").annotate(number=Count("pk")).order_by("-date") - ) - - self.rescue["by_dpt"] = ( - FileByDepartment.objects.filter( - file__file_type=rescue_type, department__isnull=False - ) - .values("department__label") - .annotate(number=Count("file")) - .order_by("department__label") - ) - self.rescue["towns"] = ( - FileTown.objects.filter(file__file_type=rescue_type) - .values("town__name") - .annotate(number=Count("file")) - .order_by("-number", "town__name")[:10] - ) - - self.rescue["with_associated_operation"] = rescues.filter( - operations__isnull=False - ).count() - - if self.rescue["total_number"]: - self.rescue["with_associated_operation_percent"] = round( - float(self.rescue["with_associated_operation"]) - / self.rescue["total_number"] - * 100, - 2, - ) - - by_year_operationnal = rescues.filter(operations__isnull=False).extra( - {"date": "date_trunc('year', " '"archaeological_files_file".creation_date)'} - ) - by_year_operationnal = ( - by_year_operationnal.values("date") - .annotate(number=Count("pk")) - .order_by("-date") - ) - percents, idx = [], 0 - for dct in self.rescue["by_year"]: - if idx >= len(by_year_operationnal): - break - if by_year_operationnal[idx]["date"] != dct["date"] or not dct["number"]: - continue - val = round( - float(by_year_operationnal[idx]["number"]) / dct["number"] * 100, 2 - ) - percents.append({"date": dct["date"], "number": val}) - self.rescue["operational_by_year"] = percents - - self.rescue["surface_by_town"] = ( - FileTown.objects.filter(file__file_type=rescue_type) - .values("town__name") - .annotate(number=Sum("file__total_surface")) - .order_by("-number", "town__name")[:10] - ) - self.rescue["surface_by_dpt"] = ( - FileByDepartment.objects.filter( - file__file_type=rescue_type, department__isnull=False - ) - .values("department__label") - .annotate(number=Sum("file__total_surface")) - .order_by("department__label") - ) - - class ManDays(models.Model): man_by_day_planned = models.FloatField( _("Man by day - planned"), null=True, blank=True diff --git a/archaeological_files/templates/ishtar/dashboards/dashboard_file.html b/archaeological_files/templates/ishtar/dashboards/dashboard_file.html deleted file mode 100644 index 127c9f2f8..000000000 --- a/archaeological_files/templates/ishtar/dashboards/dashboard_file.html +++ /dev/null @@ -1,251 +0,0 @@ -{% extends "base.html" %} -{% load i18n range units humanize %} -{% block extra_head %} -{{form.media}} -{% endblock %} -{% block content %} -

{% trans "Archaeological files" %}

-
- -

{% trans "Global informations" %}

-
- - - - - - {% for type in dashboard.types %} - - - - - {% endfor %} -
{% trans "Total" %}{{dashboard.total_number|intcomma}}
{{type.file_type__label}}{{type.number|intcomma}}
- -
-

{% trans "by year"%}

-
- - - {% for year in dashboard.by_year %}{% endfor %} - - - {% for year in dashboard.by_year %}{% endfor%} - -
{% if year.date.year %}{{year.date.year}}{% else %}{% trans "no year" %}{% endif %}
{{year.number|intcomma}}
-
-
- -
-

{% trans "by month"%}

- - - {% for month in dashboard.by_month %}{% endfor %} - - - {% for month in dashboard.by_month %}{% endfor%} - -
{{month.date|date:"N Y"|capfirst}}
{{month.number|intcomma}}
-
- -
- -

{% trans "Research archaeology" %}

-
-

{{dashboard.research.total_number|intcomma}}

-
-

{% trans "by year"%}

- - - {% for year in dashboard.research.by_year %}{% endfor %} - - - {% for year in dashboard.research.by_year %}{% endfor%} - -
{{year.date.year}}
{{year.number|intcomma}}
-
- -
-

{% trans "by month"%}

- - - {% for month in dashboard.research.by_month %}{% endfor %} - - - {% for month in dashboard.research.by_month %}{% endfor%} - -
{{month.date|date:"F Y"|capfirst}}
{{month.number|intcomma}}
-
- -
-

{% trans "by department"%}

- - - {% for dpt in dashboard.research.by_dpt %}{% endfor %} - - - {% for dpt in dashboard.research.by_dpt %}{% endfor%} - -
{{dpt.department__label}}
{{dpt.number|intcomma}}
-
- -
-

{% trans "main towns"%}

-
- - - {% for town in dashboard.research.towns %}{% endfor %} - - - {% for town in dashboard.research.towns %}{% endfor%} - -
{{town.town__name}}
{{town.number|intcomma}}
-
-
- -
- -

{% trans "Rescue archaeology" %}

-
-

{{dashboard.rescue.total_number|intcomma}}

- -
-

{% trans "by saisine type"%}

-
- - - {% for saisine in dashboard.rescue.saisine %}{% endfor %} - - - {% for saisine in dashboard.rescue.saisine %}{% endfor%} - -
{{saisine.saisine_type__label}}
{{saisine.number|intcomma}}
-
-
- -
-

{% trans "by administrative act"%}

-
- - - {% for act in dashboard.rescue.administrative_act %}{% endfor %} - - - {% for act in dashboard.rescue.administrative_act %}{% endfor%} - -
{{act.act_type__label}}
{{act.number|intcomma}}
-
-
- -
-

{% trans "by year"%}

-
- - - {% for year in dashboard.rescue.by_year %}{% endfor %} - - - {% for year in dashboard.rescue.by_year %}{% endfor%} - -
{{year.date.year}}
{{year.number|intcomma}}
-
-
- -
-

{% trans "by month"%}

-
- - - {% for month in dashboard.rescue.by_month %}{% endfor %} - - - {% for month in dashboard.rescue.by_month %}{% endfor%} - -
{{month.date|date:"F Y"|capfirst}}
{{month.number|intcomma}}
-
-
- -

{{dashboard.rescue.with_associated_operation|intcomma}}

-

{{dashboard.rescue.with_associated_operation_percent|intcomma}}

- -
-

{% trans "archaeological files linked to at least one operation (%)"%}

-
- - - {% for year in dashboard.rescue.operational_by_year %}{% endfor %} - - - {% for year in dashboard.rescue.operational_by_year %}{% endfor%} - -
{{year.date.year}}
{{year.number|intcomma}}
-
-
- -
-

{% trans "by department"%}

-
- - - {% for dpt in dashboard.rescue.by_dpt %}{% endfor %} - - - {% for dpt in dashboard.rescue.by_dpt %}{% endfor%} - -
{{dpt.department__label}}
{{dpt.number|intcomma}}
-
-
- -
-

{% trans "surface by department (ha)"%}

-
- - - {% for dpt in dashboard.rescue.surface_by_dpt %}{% endfor %} - - - {% for dpt in dashboard.rescue.surface_by_dpt %}{% endfor%} - -
{{dpt.department__label}}
{{dpt.number|m2_to_ha|intcomma}}
-
-
- -
-

{% trans "main towns by number"%}

-
- - - {% for town in dashboard.rescue.towns %}{% endfor %} - - - {% for town in dashboard.rescue.towns %}{% endfor%} - -
{{town.town__name}}
{{town.number|intcomma}}
-
-
- -
-

{% trans "main towns by surface (ha)"%}

-
- - - {% for town in dashboard.rescue.surface_by_town %}{% endfor %} - - - {% for town in dashboard.rescue.surface_by_town %}{% endfor%} - -
{{town.town__name}}
{{town.number|m2_to_ha|intcomma}}
-
-
- -
-
- -{% endblock %} diff --git a/archaeological_files/tests.py b/archaeological_files/tests.py index f0684c756..75a6ca7cd 100644 --- a/archaeological_files/tests.py +++ b/archaeological_files/tests.py @@ -729,24 +729,6 @@ class FileOperationTest(TestCase, OperationInitTest, FileInit): self.assertEqual(q.count(), 1) -class DashboardTest(TestCase, FileInit): - fixtures = FILE_TOWNS_FIXTURES - model = models.File - - def setUp(self): - self.username, self.password, self.user = create_superuser() - IshtarSiteProfile.objects.create() - self.create_file() - - def test_dashboard(self): - url = "dashboard-file" - c = Client() - c.login(username=self.username, password=self.password) - - response = c.get(reverse(url)) - self.assertEqual(response.status_code, 200) - - class AutocompleteTest(AutocompleteTestBase, TestCase): fixtures = FILE_TOWNS_FIXTURES models = [ diff --git a/archaeological_files/urls.py b/archaeological_files/urls.py index fd2059bbe..0d1ae7632 100644 --- a/archaeological_files/urls.py +++ b/archaeological_files/urls.py @@ -126,7 +126,6 @@ urlpatterns = [ check_rights(["add_administrativeact"])(views.file_adminact_add), name="file-add-adminact", ), - url(r"dashboard_file/$", views.dashboard_file, name="dashboard-file"), url( r"file_administrativeact_document/$", administrativeactfile_document, diff --git a/archaeological_files/views.py b/archaeological_files/views.py index 117f9849c..2e6cf9aff 100644 --- a/archaeological_files/views.py +++ b/archaeological_files/views.py @@ -120,14 +120,6 @@ get_administrativeactfile = get_item( ) -def dashboard_file(request, *args, **kwargs): - """ - Main dashboard - """ - dct = {"dashboard": models.FileDashboard()} - return render(request, "ishtar/dashboards/dashboard_file.html", dct) - - file_search_wizard = wizards.FileSearch.as_view( [("general-file_search", forms.FileFormSelection)], label=_("File search"), 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"), diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index cc1477bdc..0e9352803 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -1038,94 +1038,13 @@ a.photo{ width:160px; } -#dashboard{ - padding-top: 20px; -} - -#dash-tabs .ui-tabs .ui-tabs-panel{ - padding:0; -} - -.dashboard{ - margin-top: 1em; -} - -.dashboard.ui-accordion .ui-accordion-header{ - margin-left: auto; - margin-right: auto; - padding-top: 0.8em; - padding-bottom: 0.8em; -} - -.dashboard.ui-accordion .ui-accordion-content{ - padding: 1.3em; -} - -.dashboard .ui-icon, -.dashboard .ui-state-hover .ui-icon, -.dashboard .ui-state-default .ui-icon, -.dashboard .ui-state-active .ui-icon { - background-image: none; - color: white; - text-indent: 0; -} - -.dashboard .ui-state-active .ui-icon:before { - content: "\f0d7"; - font-family: 'FontAwesome'; -} - -.dashboard .ui-icon:before { - content: "\f0da"; - font-family: 'FontAwesome'; -} - -.dashboard > div, -.dashboard h3{ - width:760px; - margin:0; - margin-left:auto; - margin-right:auto; - border-radius: 4px; -} - -.dashboard > div{ - background: #FFF; - text-align:left; - padding:10px; - border:1px solid #EAEAEA; - border-top-left-radius: 0; - border-top-right-radius: 0; -} - -.dashboard h3{ - margin-top:1em; - background-color:#922; - color:#FFF; - padding:10px; -} - -.dashboard p{ - margin:0; - padding:0 10px; -} - -.dashboard div.form{ - padding:20px 10px; - width:740px; -} - -.dashboard select { - max-width: 400px; -} - -#window .table, .dashboard .table{ +#window .table{ padding:10px; width:730px; overflow:auto; } -#window table.simple, .dashboard table.resume{ +#window table.simple{ font-size:0.9em; margin:10px 0; padding: 0 10px; @@ -1133,15 +1052,10 @@ a.photo{ width:100%; } -#window caption, .dashboard caption{ +#window caption{ font-size:1.2em; } -.dashboard caption{ - text-align:left; - padding:0.5em 1em; -} - .chart-img{ display:none; } @@ -1150,7 +1064,7 @@ a.photo{ margin-top:1em; } -#window table.simple th, .dashboard table.resume th{ +#window table.simple th{ background-color:#922; border:1px solid #f1f2f6; color:#FFF; @@ -1171,29 +1085,24 @@ a.photo{ text-align: center; } -.dashboard table.resume th{ - text-align:center; - padding:0.5em; -} - -#window table th.sub, .dashboard table.resume th.sub, .dashboard table.resume td.sub{ +#window table th.sub { background-color:#994242; border:1px solid #f1f2f6; color:#FFF; padding:0 1em; } -#window table.resume th.sub, .dashboard table.resume th.sub{ +#window table.resume th.sub{ text-align:left; } -#window table.simple td, .dashboard table.resume td{ +#window table.simple td{ text-align:right; padding:0 1em; border:1px solid #f1f2f6; } -#window table td.ref, .dashboard table.resume td.ref{ +#window table td.ref{ text-align:left; white-space:nowrap; font-family:monospace; @@ -1280,24 +1189,17 @@ table td.item-list span{ border-top-right-radius: 8px; } -.dashboard label, #window label{ display:inline-table; font-weight:bold; width:245px; } -.dashboard span.value, #window span.value{ display:inline-table; width:465px; } -.dashboard span.value.numeric{ - text-align: right; - width:80px; -} - #window ul.form-flex span.value { display: inline-table; width: 230px; @@ -1386,33 +1288,6 @@ a.remove{ margin:0 6px; } -.dashboard .jqplot-target table{ - width:auto; -} - -.dashboard table.jqplot-table-legend{ - width:default; - border-collapse:default; -} - -.dashboard div.jqplot-table-legend-swatch-outline, -.dashboard table.jqplot-table-legend th, .dashboard table.jqplot-table-legend td{ - border:0; -} - -.dashboard table.jqplot-table-legend td { - text-align:left; - padding:0; -} - -.dashboard table.resume{ - width:100%; - border-collapse:yes; -} -.dashboard table.resume th, .dashboard table.resume td{ - border:1px solid; -} - .form table.inline-table th{ text-align:center; font-weight:bold; -- cgit v1.2.3