class Dossier(object):
def get_query(self,q,request):
-
employe = get_employe_from_user(request.user)
prefixe_implantation = 'poste__implantation'
url(r'^add-remun$', 'add_remun', name='add_remun'),
url(r'^add-remun/(?P<dossier>.*)/(?P<type_remun>.*)$', 'add_remun',
name='add_remun'),
- (r'^ajax_select/', include('ajax_select.urls')),
)
TEMPLATE_DEBUG=DEBUG
# Décommentez ces lignes pour activer la debugtoolbar
-#INTERNAL_IPS = ('127.0.0.1',)
-#INSTALLED_APPS += ('debug_toolbar',)
-#MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
+INTERNAL_IPS = ('127.0.0.1',)
+INSTALLED_APPS += ('debug_toolbar',)
+MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
AUTH_PASSWORD_REQUIRED = False
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
--- /dev/null
+.results_on_deck {
+ float: left;
+ margin-right: 2em;
+ margin-top: 0.5em;
+}
+
+.supprimer {
+ background: url("../django/img/admin/icon_deletelink.gif") no-repeat scroll 0 0 transparent;
+ margin-left: 1em;
+ padding-left: 1em;
+}
--- /dev/null
+# -*- encoding: utf-8 -*-
+
+from django.db.models import Q
+from auf.django.references import models as ref
+import models as rh
+
+class Pays(object):
+
+ def get_query(self,q,request):
+ pays = ref.Pays.objects.filter(Q(nom__icontains=q) | Q(code__icontains=q))
+ return pays
+
+ def format_result(self, pays):
+ return unicode(pays)
+
+ def format_item(self, pays):
+ return self.format_result(pays)
+
+ def get_objects(self, ids):
+ return ref.Pays.objects.filter(code__in=ids)
+
+
+class Implantation(object):
+
+ def get_query(self,q,request):
+ f = Q(nom__icontains=q) | Q(nom_court__icontains=q) | Q(nom_long__icontains=q) | Q(region__nom__icontains=q)
+ implantations = ref.Implantation.objects.filter(f)
+ return implantations
+
+ def format_result(self, implantation):
+ return unicode(implantation)
+
+ def format_item(self, implantation):
+ return self.format_result(implantation)
+
+ def get_objects(self, ids):
+ return ref.Implantation.objects.filter(id__in=ids)
+
+class TypePoste(object):
+
+ def get_query(self,q,request):
+ f = Q(nom__icontains=q) | Q(nom_feminin__icontains=q) | Q(famille_emploi__nom__icontains=q)
+ typepostes = rh.TypePoste.objects.filter(f)
+ return typepostes
+
+ def format_result(self, typeposte):
+ return unicode(typeposte)
+
+ def format_item(self, typeposte):
+ return self.format_result(typeposte)
+
+ def get_objects(self, ids):
+ return rh.TypePoste.objects.filter(id__in=ids)
+
+class Poste(object):
+
+ def get_query(self,q,request):
+ f = Q(nom__icontains=q) | Q(type_poste__nom__icontains=q)
+ postes = rh.Poste.objects.filter(f)
+ return postes
+
+ def format_result(self, poste):
+ return unicode(poste)
+
+ def format_item(self, poste):
+ return self.format_result(poste)
+
+ def get_objects(self, ids):
+ return rh.Poste.objects.filter(id__in=ids)
+
+class ValeurPoint(object):
+
+ def get_query(self,q,request):
+ f = Q(devise__code__icontains=q) | Q(implantation__nom__icontains=q)
+ points = rh.ValeurPoint.objects.select_related('devise', 'implantation').filter(f)
+ return points
+
+ def format_result(self, point):
+ return unicode(point)
+
+ def format_item(self, point):
+ return self.format_result(point)
+
+ def get_objects(self, ids):
+ return rh.ValeurPoint.objects.filter(id__in=ids)
# -*- encoding: utf-8 -*-
from django import forms
-from models import Dossier, Contrat, AyantDroit
+from ajax_select.fields import AutoCompleteSelectField
+from auf.django.references import models as ref
+from models import Dossier, Contrat, AyantDroit, Employe, Poste
+
+
+class AjaxSelect(object):
+
+ class Media:
+ css = {
+ 'all': ('jquery-autocomplete/jquery.autocomplete.css', 'css/select.css', )
+ }
+ js = ('js/jquery-1.5.1.min.js', 'jquery-autocomplete/jquery.autocomplete.js', )
class FormDate(object):
raise forms.ValidationError(u"La date de fin est antérieure à la date de début")
return date_fin
-class DossierForm(forms.ModelForm, FormDate):
+class PosteForm(forms.ModelForm, AjaxSelect):
+ implantation = AutoCompleteSelectField('implantations', help_text="Taper le nom de l'implantation ou sa région")
+
+ class Model:
+ model = Poste
+class DossierForm(forms.ModelForm, FormDate):
+
class Model:
model = Dossier
class Model:
model = Contrat
-class AyantDroitForm(forms.ModelForm):
+class AyantDroitForm(forms.ModelForm, AjaxSelect):
+
+ nationalite = AutoCompleteSelectField('pays', help_text="Taper le nom ou le code du pays")
def __init__(self, *args, **kwargs):
super(AyantDroitForm, self).__init__(*args, **kwargs)
model = AyantDroit
+class EmployeAdminForm(forms.ModelForm, AjaxSelect):
+
+ nationalite = AutoCompleteSelectField('pays', help_text="Taper le nom ou le code du pays")
+ pays = AutoCompleteSelectField('pays', help_text="Taper le nom ou le code du pays")
+
+ class Meta:
+ model = Employe
+
+ def __init__(self, *args, **kwargs):
+ super(EmployeAdminForm, self).__init__(*args, **kwargs)
+ self.fields['date_naissance'].widget = forms.widgets.DateInput()
+
+
from django.contrib import admin
from django.conf import settings
from django.db.models import Q
+from ajax_select import make_ajax_form
from auf.django.metadata.admin import AUFMetadataAdminMixin, AUFMetadataInlineAdminMixin, AUF_METADATA_READONLY_FIELDS
from project.rh import models as rh
-from forms import DossierForm, ContratForm, AyantDroitForm
+from forms import DossierForm, ContratForm, AyantDroitForm, EmployeAdminForm, PosteForm, AjaxSelect
from dae.utils import get_employe_from_user
pass
-class EmployeAdminForm(forms.ModelForm):
- class Meta:
- model = rh.Employe
-
- def __init__(self, *args, **kwargs):
- super(EmployeAdminForm, self).__init__(*args, **kwargs)
- self.fields['date_naissance'].widget = forms.widgets.DateInput()
-
-
class EmployeAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
alphabet_filter = 'nom'
DEFAULT_ALPHABET = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
)
-class PosteAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
+class PosteAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin, AjaxSelect):
+ form = make_ajax_form(rh.Poste, {
+ 'implantation' : 'implantations',
+ 'type_poste' : 'typepostes',
+ 'responsable' : 'postes',
+ 'valeur_point_min' : 'valeurpoints',
+ 'valeur_point_max' : 'valeurpoints',
+ })
alphabet_filter = 'nom'
search_fields = ('nom',
'implantation__code',
DossierROInline,
PosteCommentaireInline, )
+
def _nom(self, poste):
link = u"""<a onclick="return showAddAnotherPopup(this);" href='%s'>%s</a> <a href="%s" title="Modifier le poste"><img src="%simg/page_edit.png" /></a>""" % \
(reverse('poste_apercu', args=(poste.id,)),
def ma_region_ou_service(self, user):
return super(PosteManager, self).ma_region_ou_service(user).filter(actif=True)
- def get_query_set(self):
- fkeys = (
- 'id_rh',
- 'responsable',
- 'implantation',
- 'implantation.bureau_rattachement',
- 'type_poste',
- 'service',
- 'classement_min',
- 'classement_max',
- 'valeur_point_min',
- 'valeur_point_max',
- )
- return super(PosteManager, self).get_query_set() \
- .select_related(*fkeys).all()
+ #def get_query_set(self):
+ # fkeys = (
+ # 'id_rh',
+ # 'responsable',
+ # 'implantation',
+ # 'implantation.bureau_rattachement',
+ # 'type_poste',
+ # 'service',
+ # 'classement_min',
+ # 'classement_max',
+ # 'valeur_point_min',
+ # 'valeur_point_max',
+ # )
+ # return super(PosteManager, self).get_query_set() \
+ # .select_related(*fkeys).all()
class DossierManager(SecurityManager):
nom_feminin = models.CharField(max_length=255,
verbose_name = u"Titre du poste (au féminin)",
null=True)
- implantation = models.ForeignKey(ref.Implantation,
+ implantation = models.ForeignKey(ref.Implantation, help_text=u"Taper le nom de l'implantation ou sa région",
db_column='implantation', related_name='+')
- type_poste = models.ForeignKey('TypePoste', db_column='type_poste',
+ type_poste = models.ForeignKey('TypePoste', db_column='type_poste', help_text=u"Taper le nom du type de poste",
related_name='+',
null=True)
service = models.ForeignKey('Service', db_column='service',
related_name='+',
verbose_name = u"Direction/Service/Pôle support", )
responsable = models.ForeignKey('Poste', db_column='responsable',
- related_name='+', null=True,
+ related_name='+', null=True,help_text=u"Taper le nom du poste ou du type de poste",
verbose_name = u"Poste du responsable", )
# Contrat
classement_max = models.ForeignKey('Classement',
db_column='classement_max', related_name='+',
null=True, blank=True)
- valeur_point_min = models.ForeignKey('ValeurPoint',
+ valeur_point_min = models.ForeignKey('ValeurPoint', help_text=u"Taper le code ou le nom de l'implantation",
db_column='valeur_point_min', related_name='+',
null=True, blank=True)
- valeur_point_max = models.ForeignKey('ValeurPoint',
+ valeur_point_max = models.ForeignKey('ValeurPoint', help_text=u"Taper le code ou le nom de l'implantation",
db_column='valeur_point_max', related_name='+',
null=True, blank=True)
devise_min = models.ForeignKey('Devise', db_column='devise_min', null=True,
def __unicode__(self):
representation = u'%s - %s [%s]' % (self.implantation, self.nom,
self.id)
- if self.is_vacant():
- representation = representation + u' (VACANT)'
+ #if self.is_vacant():
+ # representation = representation + u' (VACANT)'
return representation
def is_vacant(self):
__doc__ = TauxChange_.__doc__
class ValeurPointManager(NoDeleteManager):
+
def get_query_set(self):
+ now = datetime.datetime.now()
return super(ValeurPointManager, self).get_query_set().select_related('devise', 'implantation')
verbose_name_plural = u"Valeurs du point"
def __unicode__(self):
- return u'%s %s (%s)' % (self.valeur, self.devise, self.annee)
+ return u'%s %s [%s]' % (self.devise, self.annee, self.implantation.nom_court)
class ValeurPoint(ValeurPoint_):
__doc__ = ValeurPoint_.__doc__
+
+class DeviseManager(NoDeleteManager):
+
+ def get_query_set(self):
+ # exclure US et CAN
+ return super(DeviseManager, self).get_query_set().exclude(id__in=(3, 15))
+
class Devise(AUFMetadata):
"""Devise monétaire.
"""
+ objects = DeviseManager()
+
code = models.CharField(max_length=10, unique=True)
nom = models.CharField(max_length=255)
'responsables' : ('dae.catalogues', 'Responsable'),
'dossiers' : ('dae.catalogues', 'Dossier'),
'postes' : ('dae.catalogues', 'Poste'),
+ 'pays' : ('rh.catalogues', 'Pays'),
+ 'implantations' : ('rh.catalogues', 'Implantation'),
+ 'typepostes' : ('rh.catalogues', 'TypePoste'),
+ 'postes' : ('rh.catalogues', 'Poste'),
+ 'valeurpoints' : ('rh.catalogues', 'ValeurPoint'),
}
+AJAX_SELECT_BOOTSTRAP = True
+AJAX_SELECT_INLINES = 'inline'
+
TINYMCE_DEFAULT_CONFIG = {
'theme': "advanced",
(r'^deconnexion/$', 'django.contrib.auth.views.logout'),
#url(r'^private_files/', include('private_files.urls')),
url(r'^captcha/', include('captcha.urls')),
+ (r'^ajax_select/', include('ajax_select.urls')),
(r'^tinymce/', include('tinymce.urls')),
(r'^prive/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.PRIVE_MEDIA_ROOT}),