summaryrefslogtreecommitdiff
path: root/archaeological_files
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_files')
-rw-r--r--archaeological_files/ishtar_menu.py30
-rw-r--r--archaeological_files/models.py4
-rw-r--r--archaeological_files/templates/ishtar/dashboards/dashboard_file.html215
-rw-r--r--archaeological_files/urls.py1
-rw-r--r--archaeological_files/views.py4
5 files changed, 250 insertions, 4 deletions
diff --git a/archaeological_files/ishtar_menu.py b/archaeological_files/ishtar_menu.py
index 398b43f4b..236c47776 100644
--- a/archaeological_files/ishtar_menu.py
+++ b/archaeological_files/ishtar_menu.py
@@ -61,5 +61,33 @@ MENU_SECTIONS = [
access_controls=['delete_file', 'delete_own_file']),
],),
]),
- )
+ ),
+ (100, SectionItem('dashboard', _(u"Dashboard"),
+ childs=[
+ MenuItem('dashboard_main', _(u"General informations"),
+ model=models.File,
+ access_controls=['change_file', 'change_own_file']),
+ MenuItem('dashboard_file', _(u"Archaeological files"),
+ model=models.File,
+ access_controls=['change_file', 'change_own_file']),
+ ]),
+ ),
]
+"""
+ SectionItem('dashboard', _(u"Dashboard"),
+ childs=[
+ MenuItem('dashboard_main', _(u"General informations"),
+ model=models.File,
+ access_controls=['change_file', 'change_own_file']),
+ MenuItem('dashboard_file', _(u"Archaeological files"),
+ model=models.File,
+ access_controls=['change_file', 'change_own_file']),
+ #MenuItem('dashboard_treatment', _(u"Treatments"),
+ # model=models.Treatment,
+ # access_controls=['change_treatment',]),
+ #MenuItem('dashboard_warehouse', _(u"Warehouses"),
+ # model=models.Warehouse,
+ # access_controls=['change_warehouse',]),
+ ]),
+ ]
+"""
diff --git a/archaeological_files/models.py b/archaeological_files/models.py
index 0b95c021a..a91f6ed69 100644
--- a/archaeological_files/models.py
+++ b/archaeological_files/models.py
@@ -180,6 +180,7 @@ class FileByDepartment(models.Model):
class FileDashboard:
def __init__(self):
+ from archaeological_operations.models import AdministrativeAct
main_dashboard = Dashboard(File)
self.total_number = main_dashboard.total_number
@@ -266,7 +267,8 @@ class FileDashboard:
self.rescue['with_associated_operation'] = rescues\
.filter(operations__isnull=False).count()
- self.rescue['with_associated_operation_percent'] = round(
+ if self.rescue['total_number']:
+ self.rescue['with_associated_operation_percent'] = round(
float(self.rescue['with_associated_operation'])\
/self.rescue['total_number']*100, 2)
diff --git a/archaeological_files/templates/ishtar/dashboards/dashboard_file.html b/archaeological_files/templates/ishtar/dashboards/dashboard_file.html
new file mode 100644
index 000000000..cebd147f4
--- /dev/null
+++ b/archaeological_files/templates/ishtar/dashboards/dashboard_file.html
@@ -0,0 +1,215 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% load range %}
+{% block extra_head %}
+{{form.media}}
+{% endblock %}
+{% block content %}
+<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/archaeological_files/urls.py b/archaeological_files/urls.py
index 4c5d923a2..72a6e2df7 100644
--- a/archaeological_files/urls.py
+++ b/archaeological_files/urls.py
@@ -59,4 +59,5 @@ urlpatterns += patterns('archaeological_files.views',
'show_file', name='show-historized-file'),
url(r'revert-file/(?P<pk>.+)/(?P<date>.+)$',
'revert_file', name='revert-file'),
+ url(r'dashboard_file/$', 'dashboard_file', name='dashboard-file')
)
diff --git a/archaeological_files/views.py b/archaeological_files/views.py
index 84ee84136..3ef8c0f28 100644
--- a/archaeological_files/views.py
+++ b/archaeological_files/views.py
@@ -70,12 +70,12 @@ get_administrativeactfile = get_item(AdministrativeAct,
'operation__towns':'operation__towns__pk',
'act_type__intented_to':'act_type__intented_to'})
-def dashboard_file(request, dct, obj_id=None, *args, **kwargs):
+def dashboard_file(request, *args, **kwargs):
"""
Main dashboard
"""
dct = {'dashboard': models.FileDashboard()}
- return render_to_response('dashboard_file.html', dct,
+ return render_to_response('ishtar/dashboards/dashboard_file.html', dct,
context_instance=RequestContext(request))
file_search_wizard = SearchWizard.as_view(