apercu
authorOlivier Larchevêque <olivier.larcheveque@auf.org>
Fri, 6 Jan 2012 21:16:25 +0000 (16:16 -0500)
committerOlivier Larchevêque <olivier.larcheveque@auf.org>
Fri, 6 Jan 2012 21:16:25 +0000 (16:16 -0500)
project/rh/lib.py
project/rh/models.py
project/rh/templates/admin/rh/dossier/apercu.html [new file with mode: 0644]
project/rh/templates/admin/rh/dossier/linked.html [new file with mode: 0644]
project/rh/templates/rh/include/dossier.html [new file with mode: 0644]
project/rh/templates/rh/include/employe.html [new file with mode: 0644]
project/rh/templates/rh/include/poste.html [new file with mode: 0644]
project/rh/urls.py
project/rh/views.py

index 2a90a28..101ab82 100644 (file)
@@ -86,6 +86,7 @@ class ContratInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
 
 
 class DossierROInline(ReadOnlyInlineMixin, LinkedInline):
 
 
 class DossierROInline(ReadOnlyInlineMixin, LinkedInline):
+    template = "admin/rh/dossier/linked.html"
     exclude = AUF_METADATA_READONLY_FIELDS
     model = models.Model  # à remplacer dans admin.py
     extra = 0
     exclude = AUF_METADATA_READONLY_FIELDS
     model = models.Model  # à remplacer dans admin.py
     extra = 0
@@ -393,8 +394,12 @@ class EmployeAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
     def _dossiers(self, obj):
         l = []
         for d in obj.dossiers.all().order_by('-date_debut'):
     def _dossiers(self, obj):
         l = []
         for d in obj.dossiers.all().order_by('-date_debut'):
-            link = "<li><a href='%s'>%s : %s</a></li>" % \
-                (reverse('admin:rh_dossier_change', args=(d.id,)),
+            style = ""
+            if d.date_fin is not None:
+                style = "color: grey";
+            link = """<li><a style="%s;" onclick="return showAddAnotherPopup(this);" href='%s'>%s : %s</a></li>""" % \
+                (style,
+                 reverse('dossier_apercu', args=(d.id,)),
                  d.date_debut.year,
                  d.poste)
             l.append(link)
                  d.date_debut.year,
                  d.poste)
             l.append(link)
index cf85772..0f492e3 100644 (file)
@@ -606,6 +606,10 @@ class Dossier_(AUFMetadata):
         return [self.poste.implantation.region]
 
 
         return [self.poste.implantation.region]
 
 
+    def remunerations(self):
+        return self.rh_remuneration_remunerations.all().order_by('date_debut')
+
+
 class Dossier(Dossier_):
     __doc__ = Dossier_.__doc__
 
 class Dossier(Dossier_):
     __doc__ = Dossier_.__doc__
 
diff --git a/project/rh/templates/admin/rh/dossier/apercu.html b/project/rh/templates/admin/rh/dossier/apercu.html
new file mode 100644 (file)
index 0000000..11a6ad4
--- /dev/null
@@ -0,0 +1,26 @@
+{% extends 'admin/change_form.html' %}
+{% load i18n admin_modify adminmedia %}
+
+{% block breadcrumbs %}{% if not is_popup %}
+<div class="breadcrumbs">
+     <a href="{% url admin:index %}">{% trans "Home" %}</a> &rsaquo;
+     <a href="{% url admin:index %}/rh">Rh</a> &rsaquo;
+     <a href="{% url admin:rh_employe_changelist %}">Liste employés</a> &rsaquo;
+     Dossier {{ dossier }}
+</div>
+{% endif %}{% endblock %}
+
+{% block content %}
+<h2>Aperçu du dossier de {{ dossier.employe }}</h2>
+
+{% with dossier.employe as employe %}
+    {% include "rh/include/employe.html" %}
+{% endwith %}
+
+{% with dossier.poste as poste %}
+    {% include "rh/include/poste.html" %}
+{% endwith %}
+
+{% include "rh/include/dossier.html" %}
+
+{% endblock %}
diff --git a/project/rh/templates/admin/rh/dossier/linked.html b/project/rh/templates/admin/rh/dossier/linked.html
new file mode 100644 (file)
index 0000000..4700e6a
--- /dev/null
@@ -0,0 +1,132 @@
+{% load i18n adminmedia %}
+<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
+  <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
+{{ inline_admin_formset.formset.management_form }}
+<fieldset class="module">
+   <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
+   {{ inline_admin_formset.formset.non_form_errors }}
+   <table>
+     <thead><tr>
+     {% for field in inline_admin_formset.fields %}
+       {% if not field.widget.is_hidden %}
+         <th{% if forloop.first %} colspan="2"{% endif %}{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}</th>
+       {% endif %}
+     {% endfor %}
+     {% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
+     </tr></thead>
+
+     <tbody>
+     {% for inline_admin_form in inline_admin_formset %}
+        {% if inline_admin_form.form.non_field_errors %}
+        <tr><td colspan="{{ inline_admin_form.field_count }}">{{ inline_admin_form.form.non_field_errors }}</td></tr>
+        {% endif %}
+        <tr class="{% cycle "row1" "row2" %} {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}{% if forloop.last %} empty-form{% endif %}"
+             id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
+        <td class="original">
+          {% if inline_admin_form.original or inline_admin_form.show_url %}<p>
+          {% if inline_admin_form.original %}
+          <a href="{% url dossier_apercu inline_admin_form.original.pk %}" onclick="return showAddAnotherPopup(this);">{{ inline_admin_form.original }}</a>
+          {% endif %}
+          {% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.id }}/">{% trans "View on site" %}</a>{% endif %}
+            </p>{% endif %}
+          {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
+          {{ inline_admin_form.fk_field.field }}
+          {% spaceless %}
+          {% for fieldset in inline_admin_form %}
+            {% for line in fieldset %}
+              {% for field in line %}
+                {% if field.is_hidden %} {{ field.field }} {% endif %}
+              {% endfor %}
+            {% endfor %}
+          {% endfor %}
+          {% endspaceless %}
+        </td>
+        {% for fieldset in inline_admin_form %}
+          {% for line in fieldset %}
+            {% for field in line %}
+              <td class="{{ field.field.name }}">
+              {% if field.is_readonly %}
+                  <p>{{ field.contents }}</p>
+              {% else %}
+                  {{ field.field.errors.as_ul }}
+                  {{ field.field }}
+              {% endif %}
+              </td>
+            {% endfor %}
+          {% endfor %}
+        {% endfor %}
+        {% if inline_admin_formset.formset.can_delete %}
+          <td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
+        {% endif %}
+        </tr>
+     {% endfor %}
+     </tbody>
+   </table>
+</fieldset>
+  </div>
+</div>
+
+<script type="text/javascript">
+(function($) {
+    $(document).ready(function($) {
+        var rows = "#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr";
+        var alternatingRows = function(row) {
+            $(rows).not(".add-row").removeClass("row1 row2")
+                .filter(":even").addClass("row1").end()
+                .filter(rows + ":odd").addClass("row2");
+        }
+        var reinitDateTimeShortCuts = function() {
+            // Reinitialize the calendar and clock widgets by force
+            if (typeof DateTimeShortcuts != "undefined") {
+                $(".datetimeshortcuts").remove();
+                DateTimeShortcuts.init();
+            }
+        }
+        var updateSelectFilter = function() {
+            // If any SelectFilter widgets are a part of the new form,
+            // instantiate a new SelectFilter instance for it.
+            if (typeof SelectFilter != "undefined"){
+                $(".selectfilter").each(function(index, value){
+                  var namearr = value.name.split('-');
+                  SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% admin_media_prefix %}");
+                })
+                $(".selectfilterstacked").each(function(index, value){
+                  var namearr = value.name.split('-');
+                  SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% admin_media_prefix %}");
+                })
+            }
+        }
+        var initPrepopulatedFields = function(row) {
+            row.find('.prepopulated_field').each(function() {
+                var field = $(this);
+                var input = field.find('input, select, textarea');
+                var dependency_list = input.data('dependency_list') || [];
+                var dependencies = [];
+                $.each(dependency_list, function(i, field_name) {
+                  dependencies.push('#' + row.find(field_name).find('input, select, textarea').attr('id'));
+                });
+                if (dependencies.length) {
+                    input.prepopulate(dependencies, input.attr('maxlength'));
+                }
+            });
+        }
+        {% if inline_admin_formset.formset.has_add_permission != False %}
+        $(rows).formset({
+            prefix: "{{ inline_admin_formset.formset.prefix }}",
+            addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
+            formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
+            deleteCssClass: "inline-deletelink",
+            deleteText: "{% trans "Remove" %}",
+            emptyCssClass: "empty-form",
+            removed: alternatingRows,
+            added: (function(row) {
+                initPrepopulatedFields(row);
+                reinitDateTimeShortCuts();
+                updateSelectFilter();
+                alternatingRows(row);
+            })
+        });
+        {% endif %}
+    });
+})(django.jQuery);
+</script>
diff --git a/project/rh/templates/rh/include/dossier.html b/project/rh/templates/rh/include/dossier.html
new file mode 100644 (file)
index 0000000..6a3a4ac
--- /dev/null
@@ -0,0 +1,43 @@
+<h2>Dossier</h2>
+
+<h3>Durée et régime</h3>
+<table>
+    <tr><th>Date début d'occupation</th><td>{{ dossier.date_debut }}</td></tr>
+    <tr><th>Date fin d'occupation</th><td>{% if dossier.date_fin == None %}<span style="color: red;">en cours</span>{% else %}{{ dossier.date_fin }}{% endif %}</td></tr>
+
+    <tr><th>Régime de travail (% du temps complet)</th><td>{{ dossier.regime_travail }}</td></tr>
+    <tr><th>Régime de travail (Nb. heures par semaine)</th><td>{{ dossier.regime_travail_nb_heure_semaine }}</td></tr>
+</table>
+
+<h3>Information</h3>
+<table>
+    <tr><th>Statut</th><td>{{ dossier.statut }}</td></tr>
+    <tr><th>Organisme BSTG</th><td>{{ dossier.organisme_bstg }}</td></tr>
+    <tr><th>Statut de résidence</th><td>{{ dossier.statut_residence }}</td></tr>
+    <tr><th>Classement</th><td>{{ dossier.classement }}</td></tr>
+    {% if dossier.remplacement %}
+        <th>Remplacement</th><td>{{ dossier.remplacement_de }}</td></tr>
+    {% endif %}
+</table>
+
+<h3>Rémunérations</h3>
+<table>
+    <tr>
+        <th>Type</th>
+        <th>Nature</th>
+        <th>Montant (devise)</th>
+        <th>Commentaire</th>
+        <th>Date début</th>
+        <th>Date fin</th>
+    </tr>
+    {% for r in dossier.remunerations %}
+    <tr>
+        <th>{{ r.type }}</th>
+        <th>{{ r.type.nature_remuneration }}</th>
+        <td>{{ r.montant }} {{ r.devise.code }}</td>
+        <td>{{ r.commentaire }}</td>
+        <td>{{ r.date_debut }}</td>
+        <td>{{ r.date_fin }}</td>
+    </tr>
+    {% endfor %}
+</table>
diff --git a/project/rh/templates/rh/include/employe.html b/project/rh/templates/rh/include/employe.html
new file mode 100644 (file)
index 0000000..3d095b9
--- /dev/null
@@ -0,0 +1,2 @@
+<h2>Employé</h2>
+<h3>{{ employe.nom|title }} {{employe.prenom|title }}</h3>
diff --git a/project/rh/templates/rh/include/poste.html b/project/rh/templates/rh/include/poste.html
new file mode 100644 (file)
index 0000000..6281583
--- /dev/null
@@ -0,0 +1,28 @@
+<h2>Poste</h2>
+
+<h3>Identification</h3>
+<table>
+    <tr><th>Nom</th><td>{{ poste.nom }}</td></tr>
+    <tr><th>Implantation</th><td>{{ poste.implantation }}</td></tr>
+
+    <tr><th>Type</th><td>{{ poste.type_poste }}</td></tr>
+    <tr><th>Service</th><td>{{ poste.service }}</td></tr>
+    <tr><th>Responsable</th><td>{{ poste.responsable }}</td></tr>
+</table>
+
+{% comment %}
+<h3>Contrat</h3>
+<table>
+    <tr><th>Régime de travail (% du temps complet)</th><td>{{ poste.regime_travail }}</td></tr>
+    <tr><th>Régime de travail (Nb. heures par semaine)</th><td>{{ poste.regime_travail_nb_heure_semaine }}</td></tr>
+</table>
+
+<h3>Recrutement</h3>
+<table>
+    <tr><th>Local</th><td>{{ poste.local }}</td></tr>
+    <tr><th>Expatrié</th><td>{{ poste.expatrie }}</td></tr>
+    <tr><th>Mise à disposition</th><td>{{ poste.mise_a_disposition }}</td></tr>
+    <tr><th>Appel à candidature</th><td>{{ poste.appel }}</td></tr>
+</table>
+{% endcomment %}
+
index cf138ed..0525c3b 100644 (file)
@@ -7,4 +7,5 @@ urlpatterns = patterns(
     url(r'^admin/rh/rapports/postes$', 'rapports_poste', name='rhr_postes'),
     url(r'^admin/rh/rapports/contrats$', 'rapports_contrat', name='rhr_contrats'),
     url(r'^admin/rh/rapports/remuneration$', 'rapports_remuneration', name='rhr_remuneration'),
     url(r'^admin/rh/rapports/postes$', 'rapports_poste', name='rhr_postes'),
     url(r'^admin/rh/rapports/contrats$', 'rapports_contrat', name='rhr_contrats'),
     url(r'^admin/rh/rapports/remuneration$', 'rapports_remuneration', name='rhr_remuneration'),
+    url(r'^admin/rh/dossier/(\d+)/apercu/$', 'dossier_apercu', name='dossier_apercu'),
 )
 )
index f3ab9ce..ce2802d 100644 (file)
@@ -193,3 +193,11 @@ def rapports_remuneration(request):
     }
 
     return render_to_response('rh/rapports/remuneration.html', c, RequestContext(request))
     }
 
     return render_to_response('rh/rapports/remuneration.html', c, RequestContext(request))
+
+def dossier_apercu(request, dossier_id):
+    c = {
+        'is_popup' : request.GET.get('_popup', False),
+        'dossier' : get_object_or_404(rh.Dossier, pk=dossier_id)
+
+    }
+    return render_to_response('admin/rh/dossier/apercu.html', c, RequestContext(request))