from django.db import models
from django import forms
+from django.core.urlresolvers import reverse
from django.contrib import admin
from django.conf import settings
from django.db.models import Q
ordering = ('nom', )
actions = ('desactiver', )
form = EmployeAdminForm
- list_display = ('id', 'nom', 'prenom', 'date_modification', 'user_modification',)
+ list_display = ('id', 'nom', 'prenom', '_dossiers', 'date_modification', 'user_modification',)
list_display_links = ('id', 'nom',)
+ list_filter = ('dossiers__poste__implantation__region', 'dossiers__poste__implantation',)
inlines = (AyantDroitInline,
DossierROInline,
EmployePieceInline,
add_form_template = 'admin/change_form.html'
+ 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,)),
+ d.date_debut.year,
+ d.poste)
+ l.append(link)
+ return "<ul>%s</ul>" % "\n".join(l)
+ _dossiers.allow_tags = True
+
def queryset(self, request):
qs = super(EmployeAdmin, self).queryset(request)
return qs.filter(actif=True).select_related(depth=1)
--- /dev/null
+{% load i18n %}
+
+<h3>{% blocktrans with title as filter_title %} By {{ filter_title }} {% endblocktrans %}</h3>
+{% if choices|length > 2 %}
+<select dir="rtl" style="width: 95%;" onchange="window.location=window.location.pathname+this.options[this.selectedIndex].value">
+{% for choice in choices %}
+ <option{% if choice.selected %} selected="selected"{% endif %}
+ dir="ltr"
+ value="{{ choice.query_string|iriencode }}">{{ choice.display }}</option>
+{% endfor %}
+</select>
+
+{% else %}
+<ul>
+{% for choice in choices %}
+ <li{% if choice.selected %} class="selected"{% endif %}>
+ <a href="{{ choice.query_string|iriencode }}">{{ choice.display }}</a></li>
+{% endfor %}
+</ul>
+{% endif %}