diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-11-16 18:05:49 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:23:19 +0100 | 
| commit | 2e15f5fd3525120d22336faf10e960050aaefb67 (patch) | |
| tree | 11cf75140bc4296fc5c936d4f7b6a3a640d4dbce | |
| parent | b46aa637fa1018a151f623138c94e145efa8288c (diff) | |
| download | Ishtar-2e15f5fd3525120d22336faf10e960050aaefb67.tar.bz2 Ishtar-2e15f5fd3525120d22336faf10e960050aaefb67.zip | |
Remove deadcode (old dashboards) - clean css
| -rw-r--r-- | archaeological_files/models.py | 148 | ||||
| -rw-r--r-- | archaeological_files/templates/ishtar/dashboards/dashboard_file.html | 251 | ||||
| -rw-r--r-- | archaeological_files/tests.py | 18 | ||||
| -rw-r--r-- | archaeological_files/urls.py | 1 | ||||
| -rw-r--r-- | archaeological_files/views.py | 8 | ||||
| -rw-r--r-- | archaeological_operations/ishtar_menu.py | 17 | ||||
| -rw-r--r-- | archaeological_operations/models.py | 531 | ||||
| -rw-r--r-- | archaeological_operations/templates/ishtar/dashboards/dashboard_operation.html | 721 | ||||
| -rw-r--r-- | archaeological_operations/tests.py | 18 | ||||
| -rw-r--r-- | archaeological_operations/urls.py | 3 | ||||
| -rw-r--r-- | archaeological_operations/views.py | 8 | ||||
| -rw-r--r-- | ishtar_common/static/media/style.css | 141 | 
12 files changed, 8 insertions, 1857 deletions
| 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 %} -<h2>{% trans "Archaeological files" %}</h2> -<div class='dashboard' id='dashboard-files'> - -  <h3>{% trans "Global informations" %}</h3> -  <div> -    <table class="table table-striped"> -        <tr> -          <th>{% trans "Total" %}</th> -          <td>{{dashboard.total_number|intcomma}}</td> -        </tr> -        {% for type in dashboard.types %} -        <tr> -          <th>{{type.file_type__label}}</th> -          <td>{{type.number|intcomma}}</td> -        </tr> -    {% endfor %} -    </table> - -    <div class='clean-table'> -      <h4>{% trans "by year"%}</h4> -      <div class='clean-table-wrap'> -        <table class="table table-striped"> -          <tr> -          {% for year in dashboard.by_year %}<th>{% if year.date.year %}{{year.date.year}}{% else %}{% trans "no year" %}{% endif %}</th>{% endfor %} -          </tr> -          <tr> -          {% for year in dashboard.by_year %}<td>{{year.number|intcomma}}</td>{% endfor%} -          </tr> -        </table> -      </div> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "by month"%}</h4> -    <table class="table table-striped"> -      <tr> -      {% for month in dashboard.by_month %}<th>{{month.date|date:"N Y"|capfirst}}</th>{% endfor %} -      </tr> -      <tr> -      {% for month in dashboard.by_month %}<td>{{month.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> - -  </div> - -  <h3>{% trans "Research archaeology" %}</h3> -  <div> -    <p><label>{% trans "Total:" %}</label><span class='value numeric'>{{dashboard.research.total_number|intcomma}}</span></p> -    <div class='clean-table'> -    <h4>{% trans "by year"%}</h4> -    <table class="table table-striped"> -      <tr> -      {% for year in dashboard.research.by_year %}<th>{{year.date.year}}</th>{% endfor %} -      </tr> -      <tr> -      {% for year in dashboard.research.by_year %}<td>{{year.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "by month"%}</h4> -    <table class="table table-striped"> -      <tr> -      {% for month in dashboard.research.by_month %}<th>{{month.date|date:"F Y"|capfirst}}</th>{% endfor %} -      </tr> -      <tr> -      {% for month in dashboard.research.by_month %}<td>{{month.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "by department"%}</h4> -    <table class="table table-striped"> -      <tr> -      {% for dpt in dashboard.research.by_dpt %}<th>{{dpt.department__label}}</th>{% endfor %} -      </tr> -      <tr> -      {% for dpt in dashboard.research.by_dpt %}<td>{{dpt.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "main towns"%}</h4> -      <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -      {% for town in dashboard.research.towns %}<th>{{town.town__name}}</th>{% endfor %} -      </tr> -      <tr> -      {% for town in dashboard.research.towns %}<td>{{town.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -      </div> -    </div> - -  </div> - -  <h3>{% trans "Rescue archaeology" %}</h3> -  <div> -    <p><label>{% trans "Total:" %}</label> <span class='value numeric'>{{dashboard.rescue.total_number|intcomma}}</span></p> - -    <div class='clean-table'> -    <h4>{% trans "by saisine type"%}</h4> -      <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -      {% for saisine in dashboard.rescue.saisine %}<th>{{saisine.saisine_type__label}}</th>{% endfor %} -      </tr> -      <tr> -      {% for saisine in dashboard.rescue.saisine %}<td>{{saisine.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "by administrative act"%}</h4> -      <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -      {% for act in dashboard.rescue.administrative_act %}<th>{{act.act_type__label}}</th>{% endfor %} -      </tr> -      <tr> -      {% for act in dashboard.rescue.administrative_act %}<td>{{act.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "by year"%}</h4> -      <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -      {% for year in dashboard.rescue.by_year %}<th>{{year.date.year}}</th>{% endfor %} -      </tr> -      <tr> -      {% for year in dashboard.rescue.by_year %}<td>{{year.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "by month"%}</h4> -      <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -      {% for month in dashboard.rescue.by_month %}<th>{{month.date|date:"F Y"|capfirst}}</th>{% endfor %} -      </tr> -      <tr> -      {% for month in dashboard.rescue.by_month %}<td>{{month.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> -    </div> - -    <p><label>{% trans "Archaeological files linked to at least one operation:" %}</label> <span class='value numeric'>{{dashboard.rescue.with_associated_operation|intcomma}}</span></p> -    <p><label>{% trans "Archaeological files linked to at least one operation (%):" %}</label> <span class='value numeric'>{{dashboard.rescue.with_associated_operation_percent|intcomma}}</span></p> - -    <div class='clean-table'> -    <h4>{% trans "archaeological files linked to at least one operation (%)"%}</h4> -      <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -      {% for year in dashboard.rescue.operational_by_year %}<th>{{year.date.year}}</th>{% endfor %} -      </tr> -      <tr> -      {% for year in dashboard.rescue.operational_by_year %}<td>{{year.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "by department"%}</h4> -      <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -      {% for dpt in dashboard.rescue.by_dpt %}<th>{{dpt.department__label}}</th>{% endfor %} -      </tr> -      <tr> -      {% for dpt in dashboard.rescue.by_dpt %}<td>{{dpt.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "surface by department (ha)"%}</h4> -      <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -      {% for dpt in dashboard.rescue.surface_by_dpt %}<th>{{dpt.department__label}}</th>{% endfor %} -      </tr> -      <tr> -      {% for dpt in dashboard.rescue.surface_by_dpt %}<td>{{dpt.number|m2_to_ha|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "main towns by number"%}</h4> -      <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -      {% for town in dashboard.rescue.towns %}<th>{{town.town__name}}</th>{% endfor %} -      </tr> -      <tr> -      {% for town in dashboard.rescue.towns %}<td>{{town.number|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> -    </div> - -    <div class='clean-table'> -    <h4>{% trans "main towns by surface (ha)"%}</h4> -      <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -      {% for town in dashboard.rescue.surface_by_town %}<th>{{town.town__name}}</th>{% endfor %} -      </tr> -      <tr> -      {% for town in dashboard.rescue.surface_by_town %}<td>{{town.number|m2_to_ha|intcomma}}</td>{% endfor%} -      </tr> -    </table> -    </div> -    </div> - -  </div> -</div> -<script> -  $( function() { -    $( "#dashboard-files" ).accordion({ -      collapsible: true, -      heightStyle: "content" -    }); -  } ); -</script> -{% 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 %} - -<h2>{% trans "Operations" %}</h2> - -<div class='dashboard' id='dashboard-operations'> -  <h3>{% trans "Global informations" %}</h3> -  <div> -    <div class='clean-table'> -    <h4>{% trans "total" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th> -      </tr> -      {% for lbl, nb in dashboard.total %} -      <tr> -        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -    <h4>{% trans "area by type of operation" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th>{% trans "Status" %}</th><th>{% trans "Area (ha)" %}</th> -      </tr> -      {% for surface in dashboard.surface_by_type %} -      <tr> -        <th class='sub'>{{surface.operation_type__label}}</th><td>{{surface.number|m2_to_ha|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -    <h4>{% trans "by types" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {% for typ in dashboard.types %} -            {% if forloop.counter0|divisibleby:5 %} -            <th class='sub'>{% trans "State" %}</th> -            {% endif %} -            <th>{{typ.label}}</th> -        {% endfor %} -      </tr> -      {% for lbl, types in dashboard.by_type %} -      <tr> -        {%for nb in types %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{{lbl}}</th>{% endif %} -        <td>{{nb|intcomma}}</td>{% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -    <h4>{% trans "by year" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {% for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{% trans "State" %}</th> -        {% endif %} -        <th>{{yr|default_if_none:''}}</th>{% endfor %} -      </tr> -      {% for lbl, years in dashboard.by_year %} -      <tr> -        {% for nb in years %} -        {% if forloop.counter0|divisibleby:5 %} -            <th class='sub'>{{lbl}}</th>{% endif %} -            <td>{{nb|intcomma}}</td> -        {% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "by realisation year" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {%for yr in dashboard.realisation_years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{% trans "State" %}</th> -        {% endif %} -        <th>{{yr.year|default_if_none:''}}</th>{% endfor %} -      </tr> -      {% for lbl, years in dashboard.by_realisation_year %} -      <tr> -        {% for nb in years %} -        {% if forloop.counter0|divisibleby:5 %} -            <th class='sub'>{{lbl}}</th>{% endif %} -            <td>{{nb|intcomma}}</td> -        {% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "effective operation by type and year" %}</h4> -    <div class='clean-table-wrap'> -    <table class='mini-table table table-striped'> -      {% for lbl, years in dashboard.effective %} - -      {% if forloop.counter0|divisibleby:6 %} -      <tr> -        {%for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th></th> -        {% endif %} -        <th>{{yr|default_if_none:''}}</th>{% endfor %} -      </tr> -      {% endif %} -      <tr> -        {% for nb in years %} -        {% if forloop.counter0|divisibleby:5 %} -            <th class='sub'>{{lbl}}</th>{% endif %} -            <td>{{nb|intcomma}}</td> -        {% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "by realisation month" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {%for mt in dashboard.last_months %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{% trans "State" %}</th> -        {% endif %} -        <th>{{mt.date|date:"N Y"|capfirst}}</th>{% endfor %} -      </tr> -      {% for lbl, months in dashboard.by_realisation_month %} -      <tr> -        {%for nb in months %} -        {% if forloop.counter0|divisibleby:5 %} -            <th class='sub'>{{lbl}}</th>{% endif %} -            <td>{{nb|intcomma}}</td> -        {% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -  </div> - -  <h3>{% trans "Survey informations" %}</h3> -  <div> - -    <div class='clean-table'> -      <h4>{% trans "total" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th> -      </tr> -      {% for lbl, nb in dashboard.survey.total %} -      <tr> -        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "by year" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {%for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{% trans "State" %}</th> -        {% endif %} -        <th>{{yr|default_if_none:''}}</th>{% endfor %} -      </tr> -      {% for lbl, years in dashboard.survey.by_year %} -      <tr> -        {% for nb in years %} -        {% if forloop.counter0|divisibleby:5 %} -            <th class='sub'>{{lbl}}</th>{% endif %} -            <td>{{nb|intcomma}}</td> -        {% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "by realisation year" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {%for yr in dashboard.realisation_years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{% trans "State" %}</th> -        {% endif %} -        <th>{{yr.year|default_if_none:''}}</th>{% endfor %} -      </tr> -      {% for lbl, years in dashboard.survey.by_realisation_year %} -      <tr> -        {% for nb in years %} -        {% if forloop.counter0|divisibleby:5 %} -            <th class='sub'>{{lbl}}</th>{% endif %} -            <td>{{nb|intcomma}}</td> -        {% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "current year" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th></th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%} -      </tr> -      <tr> -        <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.survey.area %}<td>{{nb|intcomma}}</td>{%endfor%} -      </tr> -      <tr> -        <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.survey.manday %}<td>{{nb|intcomma}}</td>{%endfor%} -      </tr> -      <tr> -        <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.survey.mandayhect %}<td>{{nb|intcomma}}</td>{%endfor%} -      </tr> -    </table></div></div> -    <p><strong>{% trans "Man-day/hectare for effective operations (current year):" %}</strong> {{dashboard.survey.mandayhect_effective}}</p> -    <div class='clean-table'> -      <h4>{% trans "organizations (current year)" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th> </th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th> -      </tr> -      {% for org in dashboard.survey.org %} -      <tr> -        <th class='sub'>{{org.scientist__attached_to__name}}</th><td>{{org.area|intcomma}}</td><td>{{org.manday|intcomma}}</td><td>{{org.mandayhect|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "current realisation year" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th>{% trans "Status" %}</th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%} -      </tr> -      <tr> -        <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.survey.area_realised %}<td>{{nb|intcomma}}</td>{%endfor%} -      </tr> -      <tr> -        <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.survey.manday_realised %}<td>{{nb|intcomma}}</td>{%endfor%} -      </tr> -      <tr> -        <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.survey.mandayhect_realised %}<td>{{nb|intcomma}}</td>{%endfor%} -      </tr> -    </table></div></div> - -    <p><strong>{% trans "Man-day/hectare for effective operations (current realisation year):" %}</strong> {{dashboard.survey.mandayhect_real_effective}}</p> - -    <div class='clean-table'> -      <h4>{% trans "organizations (current realisation year)" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th> </th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th> -      </tr> -      {% for org in dashboard.survey.org_realised %} -      <tr> -        <th class='sub'>{{org.scientist__attached_to__name}}</th><td>{{org.area|intcomma}}</td><td>{{org.manday|intcomma}}</td><td>{{org.mandayhect|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> -    <div class='clean-table'> -      <h4>{% trans "area by organization by year" %}</h4> -    <div class='clean-table-wrap'> -    <table class='mini-table table table-striped'> -      <tr> -      </tr> -      {% for org, vals in dashboard.survey.org_by_year %} -        {% if forloop.counter0|divisibleby:4 %} -        {% for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{% trans "Organization" %}</th> -        {% endif %} -        <th>{{yr|default_if_none:''}}</th> -        {% endfor %} -        {% endif %} - -      <tr> -        {% for area, cost in vals %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{{org}}</th> -        {% endif %} -        <td>{{area|intcomma}}</td>{% endfor %} -      </tr> -      {% endfor %} -      <tr> -        {% for area in dashboard.survey.org_by_year_area_mean %} -        {% if forloop.counter0|divisibleby:5 %} -        <th>{% trans "Mean" %}</th>{% endif%} -        <td>{{area|intcomma}}</td>{% endfor %} -      </tr> -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "effective operations areas (ha)" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {%for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th></th> -        {% endif %} -        <th>{{yr|default_if_none:''}}</th>{% endfor %} -      </tr> -      <tr> -        {% for nb, mean in dashboard.survey.effective %} -        {% if forloop.counter0|divisibleby:5 %}<th>{% trans "Sum" %}</th>{%endif%} -        <td>{{nb|m2_to_ha|intcomma}}</td>{% endfor %} -      </tr> -      <tr> -        {% for nb, avg in dashboard.survey.effective %} -        {% if forloop.counter0|divisibleby:5 %}<th>{% trans "Average" %}</th>{%endif%} -        <td>{{avg|m2_to_ha|intcomma}}</td>{% endfor %} -      </tr> -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "man-days/hectare by year" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {%for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th></th> -        {% endif %} -        <th>{{yr|default_if_none:''}}</th>{% endfor %} -      </tr> -      <tr> -        {% for nb, mean in dashboard.survey.mandayshect %} -        {% if forloop.counter0|divisibleby:5 %}<th>{% trans "Man-Days/hectare" %}</th>{%endif%} -        <td>{{nb|intcomma}}</td>{% endfor %} -      </tr> -      <tr> -        {% for nb, avg in dashboard.survey.mandayshect %} -        {% if forloop.counter0|divisibleby:5 %} -        <th>{% trans "Average" %}</th> -        {%endif%} -        <td>{{avg|intcomma}}</td>{% endfor %} -      </tr> -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "by month" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {% for mt in dashboard.last_months %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{% trans "State" %}</th>{% endif %} -        <th>{{mt.date|date:"N Y"|capfirst}}</th>{% endfor %} -      </tr> -      {% for lbl, months in dashboard.survey.by_month %} -      <tr> -        {%for nb in months %} -        {% if forloop.counter0|divisibleby:5 %} -            <th class='sub'>{{lbl}}</th>{% endif %} -            <td>{{nb|intcomma}}</td> -        {% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "by department" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {% for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{% trans "Department" %}</th> -        {% endif %} -        <th>{{yr|default_if_none:''}}</th>{% endfor %}<th>{% trans "Sum" %}</th> -      </tr> -      {% for lbl, years in dashboard.survey.by_dpt %} -      <tr> -        {% for nb in years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{{lbl}}</th>{% endif %} -        <td{%if forloop.last%} class='sub'{%endif%}>{{nb|intcomma}}</td>{% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "effective operation by department" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {% for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:4 %} -        <th rowspan='2'>{% trans "Department" %}</th>{% endif %} -        <th class='sub' colspan='2'>{{yr|default_if_none:''}}</th>{% endfor %}<th colspan='2'>{% trans "Sum" %}</th> -      </tr> -      <tr> -        {%for yr in dashboard.years %}<th>{%trans "Nb."%}</th><th>{%trans "Area"%}</th>{% endfor %}<th>{%trans "Nb."%}</th><th>{%trans "Area"%}</th> -      </tr> -      {% for lbl, years in dashboard.survey.effective_by_dpt %} -      <tr> -        {%for nb, area, cost, fnap in years %} -        {% if forloop.counter0|divisibleby:4 %} -        <th class='sub'>{{lbl}}</th>{% endif %} -        <td{%if forloop.last%} class='sub'{%endif%}>{{nb|intcomma}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{area|intcomma}}</td>{% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "main towns by number" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th>{% trans "Town" %}</th><th>{% trans "Number" %}</th> -      </tr> -      {% for lbl, nb in dashboard.survey.towns %} -      <tr> -        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "main towns by surface" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th>{% trans "Town" %}</th><th>{% trans "Total surface (ha)" %}</th> -      </tr> -      {% for lbl, nb in dashboard.survey.towns_surface %} -      <tr> -        <th class='sub'>{{lbl}}</th><td>{{nb|m2_to_ha|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> -  </div> - -  <h3>{% trans "Excavation informations" %}</h3> -  <div> -    <div class='clean-table'> -      <h4>{% trans "total" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th> -      </tr> -      {% for lbl, nb in dashboard.excavation.total %} -      <tr> -        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "by year" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {%for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th>{% trans "State" %}</th>{% endif %} -        <th>{{yr|default_if_none:''}}</th>{% endfor %} -      </tr> -      {% for lbl, years in dashboard.excavation.by_year %} -      <tr> -        {% for nb in years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{{lbl}}</th>{% endif %} -        <td>{{nb|intcomma}}</td>{% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "by realisation year" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {% for yr in dashboard.realisation_years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th>{% trans "State" %}</th>{% endif %} -        <th>{{yr.year}}</th>{% endfor %} -      </tr> -      {% for lbl, years in dashboard.excavation.by_realisation_year %} -      <tr> -        {% for nb in years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{{lbl}}</th>{% endif %} -        <td>{{nb}}</td>{% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "current realisation year" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th>{% trans "Status" %}</th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%} -      </tr> -      <tr> -        <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.excavation.area_realised %}<td>{{nb|default_if_none:'-'|intcomma}}</td>{%endfor%} -      </tr> -      <tr> -        <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.excavation.manday_realised %}<td>{{nb|default_if_none:'-'|intcomma}}</td>{%endfor%} -      </tr> -      <tr> -        <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.excavation.mandayhect_realised %}<td>{{nb|default_if_none:'-'|intcomma}}</td>{%endfor%} -      </tr> -    </table></div></div> - -    <p><strong>{% trans "Man-day/hectare for effective operations (current realisation year):" %}</strong> {{dashboard.excavation.mandayhect_real_effective}}</p> - -    <div class='clean-table'> -      <h4>{% trans "organizations (current realisation year)" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th> </th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th> -      </tr> -      {% for org in dashboard.excavation.org_realised %} -      <tr> -        <th class='sub'>{{org.scientist__attached_to__name}}</th><td>{{org.area|default_if_none:'-'|intcomma}}</td><td>{{org.manday|default_if_none:'-'|intcomma}}</td><td>{{org.mandayhect|default_if_none:'-'|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "area by organization by year" %}</h4> -    <div class='clean-table-wrap'> -    <table class='mini-table table table-striped'> -      {% for org, vals in dashboard.excavation.org_by_year %} -      {% if forloop.counter0|divisibleby:5 %} -      <tr> -        {% for yr in dashboard.years%} -        {% if forloop.counter0|divisibleby:5 %} -        <th>{% trans "Organization" %}</th>{% endif %} -        <th>{{yr|default_if_none:'-'}}</th>{% endfor %} -      </tr> -      {% endif %} -      <tr> -        {% for area, cost in vals %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{{org}}</th>{% endif %} -        <td>{{area|default_if_none:'-'|intcomma}}</td>{% endfor %} -      </tr> -      {% endfor %} -      <tr> -        {% for area in dashboard.excavation.org_by_year_area_sum %} -        {% if forloop.counter0|divisibleby:5 %} -        <th>{% trans "Sum" %}</th>{% endif %} -        <td>{{area|intcomma}}</td>{% endfor %} -      </tr> -      <tr> -        {% for area in dashboard.excavation.org_by_year_area_mean %} -        {% if forloop.counter0|divisibleby:5 %} -        <th>{% trans "Mean" %}</th>{% endif %} -        <td>{{area|intcomma}}</td>{% endfor %} -      </tr> -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "area by organization by realisation year" %}</h4> -    <div class='clean-table-wrap'> -    <table class='mini-table table table-striped'> -      {% for org, vals in dashboard.excavation.org_by_year %} - -        {% if forloop.counter0|divisibleby:5 %} -      <tr> -        {% for yr in dashboard.years%} -        {% if forloop.counter0|divisibleby:5 %} -        <th>{% trans "Organization" %}</th>{% endif %} -        <th>{{yr|default_if_none:'-'}}</th>{% endfor %} -      </tr> -        {% endif %} - -      <tr> -        {% for area, cost in vals %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{{org}}</th>{% endif %} -        <td>{{area|default_if_none:'-'|intcomma}}</td>{% endfor %} -      </tr> -      {% endfor %} -      <tr> -        {% for area in dashboard.excavation.org_by_year_area_sum %} -        {% if forloop.counter0|divisibleby:5 %} -        <th>{% trans "Sum" %}</th>{% endif %} -        <td>{{area|default_if_none:'-'|intcomma}}</td>{% endfor %} -      </tr> -      <tr> -        {% for area in dashboard.excavation.org_by_year_area_mean %} -        {% if forloop.counter0|divisibleby:5 %} -        <th>{% trans "Mean" %}</th>{% endif %} -        <td>{{area|default_if_none:'-'|intcomma}}</td>{% endfor %} -      </tr> -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "by month" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {% for mt in dashboard.last_months %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{% trans "State" %}</th>{% endif %} -        <th>{{mt.date|date:"N Y"|capfirst}}</th>{% endfor %} -      </tr> -      {% for lbl, months in dashboard.excavation.by_month %} -      <tr> -        {% for nb in months %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{{lbl}}</th>{% endif %} -        <td>{{nb|default_if_none:'-'|intcomma}}</td>{% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "by department" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {% for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{% trans "Department" %}</th>{% endif %} -        <th>{{yr|default_if_none:'-'}}</th>{% endfor %} -        <th>{% trans "Sum" %}</th> -      </tr> -      {% for lbl, years in dashboard.excavation.by_dpt %} -      <tr> -        {% for nb in years %} -        {% if forloop.counter0|divisibleby:5 %} -        <th class='sub'>{{lbl}}</th>{% endif %} -        <td{%if forloop.last%} class='sub'{%endif%}>{{nb|default_if_none:'-'|intcomma}}</td>{% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "effective operation by department" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        {% for yr in dashboard.years %} -        {% if forloop.counter0|divisibleby:3 %} -        <th rowspan='2' class="sub">{% trans "Department" %}</th>{% endif %} -        <th colspan='3'>{{yr|default_if_none:'-'}}</th>{% endfor %} -        <th rowspan='2' class="sub">{% trans "Department" %}</th> -        <th colspan='3'>{% trans "Sum" %}</th> -      </tr> -      <tr> -        {% for yr in dashboard.years %}<th>{%trans "Nb."%}</th><th>{%trans "Cost"%}</th><th>{%trans "FNAP cost"%}</th>{% endfor %}<th>{%trans "Nb."%}</th><th>{%trans "Cost"%}</th><th>{%trans "FNAP cost"%}</th> -      </tr> -      {% for lbl, years in dashboard.excavation.effective_by_dpt %} -      <tr> -        {% for nb, area, cost, fnap in years %} -        {% if forloop.counter0|divisibleby:3 %} -        <th class='sub'>{{lbl}}</th>{% endif %} -        <td{%if forloop.last%} class='sub'{%endif%}>{{nb|intcomma}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{cost|intcomma}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{fnap|intcomma}}</td>{% endfor %} -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "main towns by number" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th>{% trans "Town" %}</th><th>{% trans "Number" %}</th> -      </tr> -      {% for lbl, nb in dashboard.excavation.towns %} -      <tr> -        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> - -    <div class='clean-table'> -      <h4>{% trans "main towns by cost" %}</h4> -    <div class='clean-table-wrap'> -    <table class="table table-striped"> -      <tr> -        <th>{% trans "Town" %}</th><th>{% trans "Cost (euros)" %}</th> -      </tr> -      {% for lbl, nb in dashboard.excavation.towns_cost %} -      <tr> -        <th class='sub'>{{lbl}}</th><td>{{nb|intcomma}}</td> -      </tr> -      {% endfor %} -    </table></div></div> - - -  </div> -</div> -<script> -  $( function() { -    $( "#dashboard-operations" ).accordion({ -      collapsible: true, -      heightStyle: "content" -    }); -  } ); -</script> -{% 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 @@ -217,9 +217,6 @@ urlpatterns = [          name="generatedoc-administrativeactop",      ),      url( -        r"dashboard_operation/$", views.dashboard_operation, name="dashboard-operation" -    ), -    url(          r"autocomplete-administrativeact/$",          views.autocomplete_administrativeact,          name="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; | 
