diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-10-22 00:08:24 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-10-22 00:08:24 +0200 |
commit | 4ccbb4bef309571159c9558cca5da04987a68646 (patch) | |
tree | 3bedb956e0505accf622a6c42c94f3e613286bd6 /ishtar_common | |
parent | 39e0c9cf302f8b468e116047eef18f42d712166e (diff) | |
download | Ishtar-4ccbb4bef309571159c9558cca5da04987a68646.tar.bz2 Ishtar-4ccbb4bef309571159c9558cca5da04987a68646.zip |
Djangoization - Major refactoring (step 15)
* works on dashboards
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/menus.py | 30 | ||||
-rw-r--r-- | ishtar_common/models.py | 1 | ||||
-rw-r--r-- | ishtar_common/templates/dashboard_file.html | 215 | ||||
-rw-r--r-- | ishtar_common/templates/dashboard_operation.html | 510 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/dashboards/dashboard_main.html (renamed from ishtar_common/templates/dashboard_main.html) | 0 | ||||
-rw-r--r-- | ishtar_common/urls.py | 6 | ||||
-rw-r--r-- | ishtar_common/views.py | 23 |
7 files changed, 27 insertions, 758 deletions
diff --git a/ishtar_common/menus.py b/ishtar_common/menus.py index 4802a369d..77dcabcd3 100644 --- a/ishtar_common/menus.py +++ b/ishtar_common/menus.py @@ -37,7 +37,7 @@ for app in settings.INSTALLED_APPS: # sort __section_items = [menu for order, menu in sorted(_extra_menus, - key=lambda x:x[0])] + key=lambda x:x[0])] # regroup menus _section_items, __keys = [], [] for section_item in __section_items: @@ -45,29 +45,11 @@ for section_item in __section_items: __keys.append(section_item.idx) _section_items.append(section_item) continue - _section_items[__keys.index(section_item.idx)].childs += section_item.childs -""" - SectionItem('dashboard', _(u"Dashboard"), - childs=[ - MenuItem('dashboard_main', _(u"General informations"), - model=models.File, - access_controls=['change_file', 'change_own_file']), - MenuItem('dashboard_file', _(u"Archaeological files"), - model=models.File, - access_controls=['change_file', 'change_own_file']), - MenuItem('dashboard_operation', _(u"Operations"), - model=models.Operation, - access_controls=['change_operation', - 'change_own_operation']), - #MenuItem('dashboard_treatment', _(u"Treatments"), - # model=models.Treatment, - # access_controls=['change_treatment',]), - #MenuItem('dashboard_warehouse', _(u"Warehouses"), - # model=models.Warehouse, - # access_controls=['change_warehouse',]), - ]), - ] -""" + section_childs = _section_items[__keys.index(section_item.idx)].childs + childs_idx = [child.idx for child in section_childs] + for child in section_item.childs: + if child.idx not in childs_idx: + section_childs.append(child) class Menu: childs = _section_items diff --git a/ishtar_common/models.py b/ishtar_common/models.py index d8d3c3213..cff55ea5b 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -407,6 +407,7 @@ class Dashboard: last_ids = history_model.objects.values('id')\ .annotate(hd=Max('history_date')) last_ids = last_ids.filter(history_type=modif_type) + from archaeological_finds.models import Find if self.model == Find: last_ids = last_ids.filter(downstream_treatment_id__isnull=True) if modif_type == '+': diff --git a/ishtar_common/templates/dashboard_file.html b/ishtar_common/templates/dashboard_file.html deleted file mode 100644 index cebd147f4..000000000 --- a/ishtar_common/templates/dashboard_file.html +++ /dev/null @@ -1,215 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load range %} -{% block extra_head %} -{{form.media}} -{% endblock %} -{% block content %} -<div class='dashboard'> - <h2>{% trans "Archaeological files" %}</h2> - <div> - <h3>{% trans "Global informations" %}</h3> - - <p><strong>{% trans "Total:" %}</strong> {{dashboard.total_number}}</p> - {% for type in dashboard.types %} - <p><strong>{{type.file_type__label}}{% trans ":"%}</strong> {{type.number}}</p> - {% endfor %} - <div class='table'> - <table> - <caption>{% trans "By year"%}</caption> - <tr> - {% for year in dashboard.by_year %}<th>{{year.date.year}}</th>{% endfor %} - </tr> - <tr> - {% for year in dashboard.by_year %}<td>{{year.number}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "By month"%}</caption> - <tr> - {% for month in dashboard.by_month %}<th>{{month.date|date:"F Y"|capfirst}}</th>{% endfor %} - </tr> - <tr> - {% for month in dashboard.by_month %}<td>{{month.number}}</td>{% endfor%} - </tr> - </table> - </div> - - </div> - <div> - - <h3>{% trans "Research archaeology" %}</h3> - - <p><strong>{% trans "Total:" %}</strong> {{dashboard.research.total_number}}</p> - <div class='table'> - <table> - <caption>{% trans "By year"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "By month"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "By department"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "Main towns"%}</caption> - <tr> - {% for town in dashboard.research.towns %}<th>{{town.town__name}}</th>{% endfor %} - </tr> - <tr> - {% for town in dashboard.research.towns %}<td>{{town.number}}</td>{% endfor%} - </tr> - </table> - </div> - - </div> - <div> - - <h3>{% trans "Rescue archaeology" %}</h3> - - <p><strong>{% trans "Total:" %}</strong> {{dashboard.rescue.total_number}}</p> - - <div class='table'> - <table> - <caption>{% trans "By saisine type"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "By administrative act"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "By year"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "By month"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - <p><strong>{% trans "Archaeological files linked to at least one operation:" %}</strong> {{dashboard.rescue.with_associated_operation}}</p> - <p><strong>{% trans "Archaeological files linked to at least one operation (%):" %}</strong> {{dashboard.rescue.with_associated_operation_percent}}</p> - - <div class='table'> - <table> - <caption>{% trans "Archaeological files linked to at least one operation (%)"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "By department"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "Surface by department (m²)"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "Main towns by number"%}</caption> - <tr> - {% for town in dashboard.rescue.towns %}<th>{{town.town__name}}</th>{% endfor %} - </tr> - <tr> - {% for town in dashboard.rescue.towns %}<td>{{town.number}}</td>{% endfor%} - </tr> - </table> - </div> - - <div class='table'> - <table> - <caption>{% trans "Main towns by surface (m²)"%}</caption> - <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}}</td>{% endfor%} - </tr> - </table> - </div> - - </div> -</div> -{% endblock %} diff --git a/ishtar_common/templates/dashboard_operation.html b/ishtar_common/templates/dashboard_operation.html deleted file mode 100644 index 28f1dd9c6..000000000 --- a/ishtar_common/templates/dashboard_operation.html +++ /dev/null @@ -1,510 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load range %} -{% block extra_head %} -{{form.media}} -{% endblock %} -{% block content %} -<div class='dashboard'> - <h2>{% trans "Operations" %}</h2> - <div> - <h3>{% trans "Global informations" %}</h3> - - <div class='table'> - <table> - <caption>{% trans "Total" %}</caption> - <tr> - <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th> - </tr> - {% for lbl, nb in dashboard.total %} - <tr> - <th class='sub'>{{lbl}}</th><td>{{nb}}</td> - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Area by type of operation" %}</caption> - <tr> - <th>{% trans "Status" %}</th><th>{% trans "Area (m²)" %}</th> - </tr> - {% for surface in dashboard.surface_by_type %} - <tr> - <th class='sub'>{{surface.operation_type__label}}</th><td>{{surface.number}}</td> - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By types" %}</caption> - <tr> - <th>{% trans "State" %}</th>{%for typ in dashboard.types %}<th>{{typ.label}}</th>{% endfor %} - </tr> - {% for lbl, types in dashboard.by_type %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in types %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By year" %}</caption> - <tr> - <th>{% trans "State" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %} - </tr> - {% for lbl, years in dashboard.by_year %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By realisation year" %}</caption> - <tr> - <th>{% trans "State" %}</th>{%for yr in dashboard.realisation_years %}<th>{{yr.year}}</th>{% endfor %} - </tr> - {% for lbl, years in dashboard.by_realisation_year %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Effective operation by type and year" %}</caption> - <tr> - <th>{% trans "Type" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %} - </tr> - {% for lbl, years in dashboard.effective %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By realisation month" %}</caption> - <tr> - <th>{% trans "State" %}</th>{%for mt in dashboard.last_months %}<th>{{mt.date|date:"F Y"|capfirst}}</th>{% endfor %} - </tr> - {% for lbl, months in dashboard.by_realisation_month %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in months %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - </div> - <div> - - <h3>{% trans "Survey informations" %}</h3> - - <div class='table'> - <table> - <caption>{% trans "Total" %}</caption> - <tr> - <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th> - </tr> - {% for lbl, nb in dashboard.survey.total %} - <tr> - <th class='sub'>{{lbl}}</th><td>{{nb}}</td> - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By year" %}</caption> - <tr> - <th>{% trans "State" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %} - </tr> - {% for lbl, years in dashboard.survey.by_year %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By realisation year" %}</caption> - <tr> - <th>{% trans "State" %}</th>{%for yr in dashboard.realisation_years %}<th>{{yr.year}}</th>{% endfor %} - </tr> - {% for lbl, years in dashboard.survey.by_realisation_year %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Current year" %}</caption> - <tr> - <th>{% trans "Status" %}</th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%} - </tr> - <tr> - <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.survey.area %}<td>{{nb}}</td>{%endfor%} - </tr> - <tr> - <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.survey.manday %}<td>{{nb}}</td>{%endfor%} - </tr> - <tr> - <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.survey.mandayhect %}<td>{{nb}}</td>{%endfor%} - </tr> - </table></div> - - <p><strong>{% trans "Man-day/hectare for effective operations (current year):" %}</strong> {{dashboard.survey.mandayhect_effective}}</p> - - <div class='table'> - <table> - <caption>{% trans "Organizations (current year)" %}</caption> - <tr> - <th> </th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th> - </tr> - {% for org in dashboard.survey.org %} - <tr> - <th class='sub'>{{org.in_charge__attached_to__name}}</th><td>{{org.area}}</td><td>{{org.manday}}</td><td>{{org.mandayhect}}</td> - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Current realisation year" %}</caption> - <tr> - <th>{% trans "Status" %}</th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%} - </tr> - <tr> - <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.survey.area_realised %}<td>{{nb}}</td>{%endfor%} - </tr> - <tr> - <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.survey.manday_realised %}<td>{{nb}}</td>{%endfor%} - </tr> - <tr> - <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.survey.mandayhect_realised %}<td>{{nb}}</td>{%endfor%} - </tr> - </table></div> - - <p><strong>{% trans "Man-day/hectare for effective operations (current realisation year):" %}</strong> {{dashboard.survey.mandayhect_real_effective}}</p> - - <div class='table'> - <table> - <caption>{% trans "Organizations (current realisation year)" %}</caption> - <tr> - <th> </th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th> - </tr> - {% for org in dashboard.survey.org_realised %} - <tr> - <th class='sub'>{{org.in_charge__attached_to__name}}</th><td>{{org.area}}</td><td>{{org.manday}}</td><td>{{org.mandayhect}}</td> - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Area by organization by year" %}</caption> - <tr> - <th>{% trans "Organization" %}</th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} - </tr> - {% for org, vals in dashboard.survey.org_by_year %} - <tr> - <th class='sub'>{{org}}</th>{% for area, cost in vals %}<td>{{area}}</td>{% endfor %} - </tr> - {% endfor %} - <tr> - <th>{% trans "Mean" %}</th>{% for area in dashboard.survey.org_by_year_area_mean %}<td>{{area}}</td>{% endfor %} - </tr> - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Effective operations areas (m²)" %}</caption> - <tr> - <th> </th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} - </tr> - <tr> - <th>{% trans "Sum" %}</th>{% for nb, mean in dashboard.survey.effective %}<td>{{nb}}</td>{% endfor %} - </tr> - <tr> - <th>{% trans "Average" %}</th>{% for nb, avg in dashboard.survey.effective %}<td>{{avg}}</td>{% endfor %} - </tr> - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Man-Days/hectare by Year" %}</caption> - <tr> - <th> </th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} - </tr> - <tr> - <th>{% trans "Man-Days/hectare" %}</th>{% for nb, mean in dashboard.survey.mandayshect %}<td>{{nb}}</td>{% endfor %} - </tr> - <tr> - <th>{% trans "Average" %}</th>{% for nb, avg in dashboard.survey.mandayshect %}<td>{{avg}}</td>{% endfor %} - </tr> - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By month" %}</caption> - <tr> - <th>{% trans "State" %}</th>{%for mt in dashboard.last_months %}<th>{{mt.date|date:"F Y"|capfirst}}</th>{% endfor %} - </tr> - {% for lbl, months in dashboard.survey.by_month %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in months %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By department" %}</caption> - <tr> - <th>{% trans "Department" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %}<th>{% trans "Sum" %}</th> - </tr> - {% for lbl, years in dashboard.survey.by_dpt %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in years %}<td{%if forloop.last%} class='sub'{%endif%}>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Effective operation by department" %}</caption> - <tr> - <th rowspan='2'>{% trans "Department" %}</th>{%for yr in dashboard.years %}<th colspan='2'>{{yr}}</th>{% endfor %}<th colspan='2'>{% trans "Sum" %}</th> - </tr> - <tr> - {%for yr in dashboard.years %}<th>{%trans "Nb."%}</th><th>{%trans "Area"%}</th>{% endfor %}<th>{%trans "Nb."%}</th><th>{%trans "Area"%}</th> - </tr> - {% for lbl, years in dashboard.survey.effective_by_dpt %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb, area, cost, fnap in years %}<td{%if forloop.last%} class='sub'{%endif%}>{{nb}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{area}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Main towns by number" %}</caption> - <tr> - <th>{% trans "Town" %}</th><th>{% trans "Number" %}</th> - </tr> - {% for lbl, nb in dashboard.survey.towns %} - <tr> - <th class='sub'>{{lbl}}</th><td>{{nb}}</td> - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Main towns by surface" %}</caption> - <tr> - <th>{% trans "Town" %}</th><th>{% trans "Total surface (m²)" %}</th> - </tr> - {% for lbl, nb in dashboard.survey.towns_surface %} - <tr> - <th class='sub'>{{lbl}}</th><td>{{nb}}</td> - </tr> - {% endfor %} - </table></div> - - - </div> - <div> - - <h3>{% trans "Excavation informations" %}</h3> - - <div class='table'> - <table> - <caption>{% trans "Total" %}</caption> - <tr> - <th>{% trans "Status" %}</th><th>{% trans "Number" %}</th> - </tr> - {% for lbl, nb in dashboard.excavation.total %} - <tr> - <th class='sub'>{{lbl}}</th><td>{{nb}}</td> - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By year" %}</caption> - <tr> - <th>{% trans "State" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %} - </tr> - {% for lbl, years in dashboard.excavation.by_year %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By realisation year" %}</caption> - <tr> - <th>{% trans "State" %}</th>{%for yr in dashboard.realisation_years %}<th>{{yr.year}}</th>{% endfor %} - </tr> - {% for lbl, years in dashboard.excavation.by_realisation_year %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in years %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Current realisation year" %}</caption> - <tr> - <th>{% trans "Status" %}</th>{% for lbl in dashboard.filters_label %}<th>{{lbl}}</th>{%endfor%} - </tr> - <tr> - <th class='sub'>{% trans "Area"%}</th>{% for nb in dashboard.excavation.area_realised %}<td>{{nb}}</td>{%endfor%} - </tr> - <tr> - <th class='sub'>{% trans "Man-day"%}</th>{% for nb in dashboard.excavation.manday_realised %}<td>{{nb}}</td>{%endfor%} - </tr> - <tr> - <th class='sub'>{% trans "Man-day/hectare"%}</th>{% for nb in dashboard.excavation.mandayhect_realised %}<td>{{nb}}</td>{%endfor%} - </tr> - </table></div> - - <p><strong>{% trans "Man-day/hectare for effective operations (current realisation year):" %}</strong> {{dashboard.excavation.mandayhect_real_effective}}</p> - - <div class='table'> - <table> - <caption>{% trans "Organizations (current realisation year)" %}</caption> - <tr> - <th> </th><th>{% trans "Area" %}</th><th>{% trans "Man-day" %}</th><th>{% trans "Man-day/hectare" %}</th> - </tr> - {% for org in dashboard.excavation.org_realised %} - <tr> - <th class='sub'>{{org.in_charge__attached_to__name}}</th><td>{{org.area}}</td><td>{{org.manday}}</td><td>{{org.mandayhect}}</td> - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Area by organization by year" %}</caption> - <tr> - <th>{% trans "Organization" %}</th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} - </tr> - {% for org, vals in dashboard.excavation.org_by_year %} - <tr> - <th class='sub'>{{org}}</th>{% for area, cost in vals %}<td>{{area}}</td>{% endfor %} - </tr> - {% endfor %} - <tr> - <th>{% trans "Sum" %}</th>{% for area in dashboard.excavation.org_by_year_area_sum %}<td>{{area}}</td>{% endfor %} - </tr> - <tr> - <th>{% trans "Mean" %}</th>{% for area in dashboard.excavation.org_by_year_area_mean %}<td>{{area}}</td>{% endfor %} - </tr> - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Area by organization by realisation year" %}</caption> - <tr> - <th>{% trans "Organization" %}</th>{% for yr in dashboard.years%}<th>{{yr}}</th>{% endfor %} - </tr> - {% for org, vals in dashboard.excavation.org_by_year %} - <tr> - <th class='sub'>{{org}}</th>{% for area, cost in vals %}<td>{{area}}</td>{% endfor %} - </tr> - {% endfor %} - <tr> - <th>{% trans "Sum" %}</th>{% for area in dashboard.excavation.org_by_year_area_sum %}<td>{{area}}</td>{% endfor %} - </tr> - <tr> - <th>{% trans "Mean" %}</th>{% for area in dashboard.excavation.org_by_year_area_mean %}<td>{{area}}</td>{% endfor %} - </tr> - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By month" %}</caption> - <tr> - <th>{% trans "State" %}</th>{%for mt in dashboard.last_months %}<th>{{mt.date|date:"F Y"|capfirst}}</th>{% endfor %} - </tr> - {% for lbl, months in dashboard.excavation.by_month %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in months %}<td>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "By department" %}</caption> - <tr> - <th>{% trans "Department" %}</th>{%for yr in dashboard.years %}<th>{{yr}}</th>{% endfor %}<th>{% trans "Sum" %}</th> - </tr> - {% for lbl, years in dashboard.excavation.by_dpt %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb in years %}<td{%if forloop.last%} class='sub'{%endif%}>{{nb}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Effective operation by department" %}</caption> - <tr> - <th rowspan='2'>{% trans "Department" %}</th>{%for yr in dashboard.years %}<th colspan='3'>{{yr}}</th>{% endfor %}<th colspan='3'>{% trans "Sum" %}</th> - </tr> - <tr> - {%for yr in dashboard.years %}<th>{%trans "Nb."%}</th><th>{%trans "Cost"%}</th><th>{%trans "FNAP cost"%}</th>{% endfor %}<th>{%trans "Nb."%}</th><th>{%trans "Cost"%}</th><th>{%trans "FNAP cost"%}</th> - </tr> - {% for lbl, years in dashboard.excavation.effective_by_dpt %} - <tr> - <th class='sub'>{{lbl}}</th>{%for nb, area, cost, fnap in years %}<td{%if forloop.last%} class='sub'{%endif%}>{{nb}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{cost}}</td><td{%if forloop.last%} class='sub'{%endif%}>{{fnap}}</td>{% endfor %} - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Main towns by number" %}</caption> - <tr> - <th>{% trans "Town" %}</th><th>{% trans "Number" %}</th> - </tr> - {% for lbl, nb in dashboard.excavation.towns %} - <tr> - <th class='sub'>{{lbl}}</th><td>{{nb}}</td> - </tr> - {% endfor %} - </table></div> - - <div class='table'> - <table> - <caption>{% trans "Main towns by cost" %}</caption> - <tr> - <th>{% trans "Town" %}</th><th>{% trans "Cost (€)" %}</th> - </tr> - {% for lbl, nb in dashboard.excavation.towns_cost %} - <tr> - <th class='sub'>{{lbl}}</th><td>{{nb}}</td> - </tr> - {% endfor %} - </table></div> - - - </div> -</div> -{% endblock %} diff --git a/ishtar_common/templates/dashboard_main.html b/ishtar_common/templates/ishtar/dashboards/dashboard_main.html index e710dbe16..e710dbe16 100644 --- a/ishtar_common/templates/dashboard_main.html +++ b/ishtar_common/templates/ishtar/dashboards/dashboard_main.html diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index cebea1dbe..597327379 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -48,8 +48,8 @@ actions = r"|".join(actions) # other views urlpatterns += patterns('ishtar_common.views', # General - url(r'(?P<action_slug>' + actions + r')/$', 'action', - name='action'), + url(r'dashboard-main/$', 'dashboard_main', + name='dashboard-main'), url(r'update-current-item/$', 'update_current_item', name='update-current-item'), url(r'new-person/(?P<parent_name>.+)?/$', @@ -66,4 +66,6 @@ urlpatterns += patterns('ishtar_common.views', 'new_organization', name='new-organization'), url(r'autocomplete-organization/([0-9_]+)?$', 'autocomplete_organization', name='autocomplete-organization'), + url(r'(?P<action_slug>' + actions + r')/$', 'action', + name='action'), ) diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 6c682c932..d0a5af7b7 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -535,6 +535,7 @@ def action(request, action_slug, obj_id=None, *args, **kwargs): associated_wizard = action_slug + '_wizard' dct = {} globals_dct = globals() + print action_slug if action_slug in globals_dct: return globals_dct[action_slug](request, dct, obj_id, *args, **kwargs) elif hasattr(ishtar_forms, action_slug + "_wizard"): @@ -547,12 +548,20 @@ def dashboard_main(request, dct, obj_id=None, *args, **kwargs): """ Main dashboard """ - dct = {'items':[ - (_(u"Archaeological files"), models.Dashboard(models.File)), - (_(u"Operations"), models.Dashboard(models.Operation)), - (_(u"Context records"), models.Dashboard(models.ContextRecord)), - (_(u"Archaeological items"), models.Dashboard(models.Item)), - ], + items = [] + if 'archaeological_files' in settings.INSTALLED_APPS: + from archaeological_files.models import File + items.append((_(u"Archaeological files"), + models.Dashboard(File))) + from archaeological_operations.models import Operation + items.append((_(u"Operations"), models.Dashboard(Operation))) + if 'archaeological_context_records' in settings.INSTALLED_APPS: + from archaeological_context_records.models import ContextRecord + items.append((_(u"Context records"), models.Dashboard(ContextRecord))) + if 'archaeological_finds' in settings.INSTALLED_APPS: + from archaeological_finds.models import Find + items.append((_(u"Context records"), models.Dashboard(Find))) + dct = {'items':items, 'ishtar_users':models.UserDashboard()} - return render_to_response('dashboard_main.html', dct, + return render_to_response('ishtar/dashboards/dashboard_main.html', dct, context_instance=RequestContext(request)) |