From 26452f906875ebfc22d1bb6a0bcb852d4789a9f4 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 30 Nov 2012 14:33:37 +0100 Subject: [PATCH] Display previous stages on attribution view --- stages/static/img/closed.png | Bin 0 -> 263 bytes stages/static/img/open.png | Bin 0 -> 211 bytes stages/static/js/attribution.js | 10 +++++++++- stages/views.py | 6 ++++++ templates/attribution.html | 4 ++++ templates/student_summary.html | 19 ++++++++++++++++--- 6 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 stages/static/img/closed.png create mode 100644 stages/static/img/open.png diff --git a/stages/static/img/closed.png b/stages/static/img/closed.png new file mode 100644 index 0000000000000000000000000000000000000000..7323a89aac5e106dcfc4cc8f75eddd11e3db633e GIT binary patch literal 263 zcmeAS@N?(olHy`uVBq!ia0vp^96-#;!3HGxgLCzO6k~CayA#8@b22Z19JVBHcNd2L zAh=-f^2s2z1s;*b3=G`DAk4@xYmNj^kiEpy*OmPy3%{VX`PsLZ76OGNOI#yLobz*Y zQ}ap~oQqNuOHxx5$}>wc6x=<11Hv2m#DR*EJY5_^BrYe{e0{3VY@eg)db;OXk;vd$@?2>=DBQ+NOX literal 0 HcmV?d00001 diff --git a/stages/static/img/open.png b/stages/static/img/open.png new file mode 100644 index 0000000000000000000000000000000000000000..25e1aa48fd11f43a9cff7e847fe7f70a92ad378d GIT binary patch literal 211 zcmeAS@N?(olHy`uVBq!ia0vp^96-#;!3HGxgLCzO6k~CayA#8@b22Z19JVBHcNd2L zAh=-f^2s2z1s;*b3=G`DAk4@xYmNj^kiEpy*OmPy3%?Mf_2Vu7Rsn@1OI#yLobz*Y zQ}ap~oQqNuOHxx5$}>wc6x=<11Hv2m#DR+RJY5_^BrYc>ED$j;GB7ZBvTnyO`SnaO vU25(b#zsoq3fi+|7M|_6>QQs;BG94#F7aMlD8OS6)XCuK>gTe~DWM4f2!1-g literal 0 HcmV?d00001 diff --git a/stages/static/js/attribution.js b/stages/static/js/attribution.js index 2056a06..f04b2d7 100644 --- a/stages/static/js/attribution.js +++ b/stages/static/js/attribution.js @@ -128,7 +128,15 @@ $(document).ready(function() { }); $('#student_select').change(function(ev) { - $('#student_detail').load('/student/' + $(this).val() + '/summary/').addClass("filled"); + $('#student_detail').load('/student/' + $(this).val() + '/summary/', function() { + $('div#previous_stages_head').toggle(function() { + $('ul#previous_stages_list').toggle(); + $(this).find('img').attr('src', static_url + 'img/open.png'); + }, function() { + $('ul#previous_stages_list').toggle(); + $(this).find('img').attr('src', static_url + 'img/closed.png'); + }); + }).addClass("filled"); current_student = $(this).val(); if (current_avail !== null) $('input#valid_training').show() }); diff --git a/stages/views.py b/stages/views.py index 25416e1..e491ab3 100644 --- a/stages/views.py +++ b/stages/views.py @@ -15,6 +15,12 @@ class StudentSummaryView(DetailView): model = Student template_name = 'student_summary.html' + def get_context_data(self, **kwargs): + context = super(StudentSummaryView, self).get_context_data(**kwargs) + context['previous_stages'] = self.object.training_set.all( + ).select_related('availability__corporation').order_by('availability__period__end_date') + return context + class AvailabilitySummaryView(DetailView): model = Availability diff --git a/templates/attribution.html b/templates/attribution.html index bf7fbc1..4b02668 100644 --- a/templates/attribution.html +++ b/templates/attribution.html @@ -15,6 +15,9 @@ select#corp_select, select#corp_filter { width: 100%; } div#student_detail { float:left; width: 40%; margin: 1em; padding: 0.5em; border: 3px solid red; min-height: 4em; border-radius: 8px; } + div#previous_stages { background-color: #EEE; border-radius: 4px; } + ul#previous_stages_list { display: none; padding-left: 1.5em;} + div#corp_detail { float:right; width: 40%; margin: 1em; padding: 0.5em; border: 3px solid red; min-height: 4em; border-radius: 8px; } div#corp_total, div#student_total { font-style: italic; color: gray; } div.filled { border-color: green !important; } @@ -33,6 +36,7 @@ {% block extrahead %} + {% endblock %} {% block breadcrumbs %} diff --git a/templates/student_summary.html b/templates/student_summary.html index 1b8dea1..7a09d1c 100644 --- a/templates/student_summary.html +++ b/templates/student_summary.html @@ -1,3 +1,16 @@ -{{ object.first_name }} {{ object.last_name }}
-{{ object.pcode }} {{ object.city }}
-Date de naissance: {{ object.birth_date }} +
+
+ Stages précédents ({{ previous_stages|length }}) : +
+
    + {% for stage in previous_stages %} +
  • {{ stage.availability.period.dates }}: {{ stage.availability.corporation }} ({{ stage.availability.corporation.city }})
  • + {% endfor %} +
+
+ +
+ {{ object.first_name }} {{ object.last_name }}
+ {{ object.pcode }} {{ object.city }}
+ Date de naissance: {{ object.birth_date }} +