From 4b6a8d50c3a9afc6e97456b4fcbc58284be6b001 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 8 Apr 2013 14:19:23 +0200 Subject: [PATCH] Add institution detail view with stats --- common/urls.py | 3 ++ stages/models.py | 13 +++++++++ stages/static/img/edit.png | Bin 0 -> 2623 bytes stages/tests.py | 15 ++++++++-- stages/views.py | 39 +++++++++++++++++++++++++ templates/admin/index.html | 12 +++++++- templates/corporation.html | 56 ++++++++++++++++++++++++++++++++++++ templates/corporations.html | 12 ++++++++ 8 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 stages/static/img/edit.png create mode 100644 templates/corporation.html create mode 100644 templates/corporations.html diff --git a/common/urls.py b/common/urls.py index 68d1e40..8b9ad0e 100644 --- a/common/urls.py +++ b/common/urls.py @@ -18,6 +18,9 @@ urlpatterns = patterns('', url(r'^attribution/$', views.AttributionView.as_view(), name='attribution'), url(r'^stages/export/$', 'stages.views.stages_export', name='stages_export'), + url(r'^institutions/$', views.CorporationListView.as_view(), name='corporations'), + url(r'^institutions/(?P\d+)/$', views.CorporationView.as_view(), name='corporation'), + # AJAX/JSON urls url(r'^section/(?P\d+)/periods/', 'stages.views.section_periods'), url(r'^section/(?P\d+)/classes/', 'stages.views.section_classes'), diff --git a/stages/models.py b/stages/models.py index d9ca6d1..c6198fd 100644 --- a/stages/models.py +++ b/stages/models.py @@ -163,6 +163,19 @@ class Period(models.Model): def dates(self): return '%s - %s' % (self.start_date, self.end_date) + @property + def school_year(self): + if self.start_date.month < 8: + start_year = self.start_date.year - 1 + else: + start_year = self.start_date.year + return "%d — %d" % (start_year, start_year + 1) + + @property + def weeks(self): + """ Return the number of weeks of this period """ + return (self.end_date - self.start_date).days // 7 + class Availability(models.Model): """ Disponibilités des institutions """ diff --git a/stages/static/img/edit.png b/stages/static/img/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..cb1bd1aad45b03470217ce2c5df4ed8204bfe7d0 GIT binary patch literal 2623 zcmV-F3c&S=P)Px#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ock %} @@ -13,6 +19,10 @@ {% block content %}
+ + {% if app_list %} {% for app in app_list %}
diff --git a/templates/corporation.html b/templates/corporation.html new file mode 100644 index 0000000..262aca6 --- /dev/null +++ b/templates/corporation.html @@ -0,0 +1,56 @@ +{% extends "admin/base_site.html" %} +{% load i18n %} + +{% block extrastyle %} + +{% endblock %} + +{% block breadcrumbs %} + +{% endblock %} + +{% block content %} +
+

{{ corp.name }}

+ + + + + + + + + + +
Adresse :{{ corp.street }}
+ {{ corp.pcode }} {{ corp.city }}
+ Tél: {{ corp.tel }}
+ {% if corp.email %}{{ corp.email }}
{% endif %} + {% if corp.web %}{{ corp.web }}
{% endif %} +
Type de structure :{{ corp.typ }}
Contacts :{% for cont in corp.corpcontact_set.all %} + {{ cont.first_name }} {{ cont.last_name }} {% if cont.role %} ({{ cont.role }}){% endif %}{% endfor %} +
+ +{% for year, data in years.items %} +

{{ year }}

+ + {% for avail in data.avails %} + + + + + {% endfor %} + + + +
{{ avail.period.dates }}{% if not avail.training %}Disponibilité{% else %}{{ avail.training.student }} ({{ avail.training.student.klass }}){% endif %}{{ avail.period.section }}
Totaux :{% for fil, num in data.stats.items %}{{ fil }} : {{ num }} semaine(s)
{% endfor %}
+{% endfor %} + +{% endblock %} diff --git a/templates/corporations.html b/templates/corporations.html new file mode 100644 index 0000000..4778ea2 --- /dev/null +++ b/templates/corporations.html @@ -0,0 +1,12 @@ +{% extends "admin/base_site.html" %} + +{% block content %} +

Liste des institutions

+ + +{% for corp in object_list %} + + +{% endfor %} +
{{ corp.name }}{{ corp.pcode }} {{ corp.city }}
+{% endblock %}