X-Git-Url: http://git.auf.org/?p=auf_rh_dae.git;a=blobdiff_plain;f=project%2Fdashboard.py;h=1868e05581a9680ed4b455a39ecd7d9e316cabc5;hp=366c2452e416d7bc24ad137f033bbb1458ee248c;hb=391368ee499f689d4788a7d23c71bdd3b2deb44f;hpb=de151a1e2ae0dba15859e303d384870546c01bfe diff --git a/project/dashboard.py b/project/dashboard.py index 366c245..1868e05 100644 --- a/project/dashboard.py +++ b/project/dashboard.py @@ -12,50 +12,114 @@ And to activate the app index dashboard:: ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'SIGMA.dashboard.CustomAppIndexDashboard' """ +from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ - from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard -from admin_tools.utils import get_admin_site_name - +from project.decorators import in_drh_or_admin +from project.rh.historique import get_active_revisions class CustomIndexDashboard(Dashboard): """ - Custom index dashboard for SIGMA. + Custom index dashboard for SGRH. """ def init_with_context(self, context): + request = context['request'] # append an app list module for "Applications" - self.children.append(modules.AppList( + self.children.append(modules.Group( _('Applications'), - models=( - 'project.dae.models.*', - 'project.recrutement.models.*', - 'project.rh.models.AyantDroit', - 'project.rh.models.Dossier', - 'project.rh.models.DossierInactif', - 'project.rh.models.Employe', - 'project.rh.models.EmployeInactif', - 'project.rh.models.Poste', - ), + display='stacked', + children=[ + modules.ModelList( + title='Demande d\'autorisation d\'engagement', + models=( + 'project.dae.models.*', + ) + ), + modules.ModelList( + title='Recrutement', + models=( + 'auf.django.emploi.models.OffreEmploi', + 'project.recrutement.models.ProxyOffreEmploi', + 'auf.django.emploi.models.Candidat', + 'project.recrutement.models.ProxyCandidat', + 'project.recrutement.models.CandidatEvaluation', + 'project.recrutement.models.MesCandidatEvaluation', + 'project.recrutement.models.Evaluateur', + 'project.recrutement.models.OffreEmploiEvaluateur', + 'project.recrutement.models.CourrielTemplate', + ) + ), + modules.ModelList( + title='Gestion des personnels', + models=( + 'project.rh.models.AyantDroit', + 'project.rh.models.Dossier', + 'project.rh.models.DossierInactif', + 'project.rh.models.Employe', + 'project.rh.models.EmployeInactif', + 'project.rh.models.Poste', + ) + ), + modules.ModelList( + title='Log', + models=( + 'project.rh.models.ChangementPersonnel', + ) + ), + ] )) + + if in_drh_or_admin(request.user): + revisions = get_active_revisions()[:10] + children = [] + for rev in revisions: + date = rev['short_date_created'] + user = u"%s" % rev['user'] + if rev['type'] is None or rev['objet'] is None: + titre = u"""[%s] %s + commentaire : %s """ % (date, user, rev['comment']) + children.append({ + 'title': titre, + 'url': reverse('rhr_historique_des_modifications'), + 'external': False, + }) + else: + type = u"%s" % rev['type'] + titre = u"""[%s] %s a modifié + un(e) %s : %s""" % (date, user, type, rev['objet'], ) + children.append({ + 'title': titre, + 'url': rev['history_url'], + 'external': False, + }) + self.children.append(modules.LinkList( + title='10 dernières modifications', + children=children,) + ) + + + # append an app list module for "Configuration" self.children.append(modules.AppList( _('Configuration'), models=( - 'project.rh.models.Classement', - 'project.rh.models.Devise', - 'project.rh.models.FamilleEmploi', - 'project.rh.models.OrganismeBstg', - 'project.rh.models.Responsable', - 'project.rh.models.Service', - 'project.rh.models.Statut', - 'project.rh.models.TauxChange', - 'project.rh.models.TypeContrat', - 'project.rh.models.TypePoste', - 'project.rh.models.TypeRevalorisation', - 'project.rh.models.TypeRemuneration', - 'project.rh.models.ValeurPoint', + 'project.rh.models.Classement', + 'project.rh.models.Devise', + 'project.rh.models.CategorieEmploi', + 'project.rh.models.FamilleProfessionnelle', + 'project.rh.models.OrganismeBstg', + 'project.rh.models.Responsable', + 'project.rh.models.Service', + 'project.rh.models.Statut', + 'project.rh.models.TauxChange', + 'project.rh.models.TypeContrat', + 'project.rh.models.TypePoste', + 'project.rh.models.TypeRevalorisation', + 'project.rh.models.TypeRemuneration', + 'project.rh.models.ValeurPoint', + 'project.rh.models.ChangementPersonnelNotifications', ), exclude=('django.contrib.*',), )) @@ -64,7 +128,7 @@ class CustomIndexDashboard(Dashboard): self.children.append(modules.AppList( _(u'Inter-systèmes'), models=( - 'project.rh.models.ResponsableImplantation', + 'project.rh.models.ResponsableImplantationProxy', ), )) @@ -72,14 +136,10 @@ class CustomIndexDashboard(Dashboard): self.children.append(modules.AppList( _('Administration'), models=( - 'django.contrib.*', + 'django.contrib.*', ), )) - # append a recent actions module - #self.children.append(modules.RecentActions(_('Recent Actions'), 5)) - - class CustomAppIndexDashboard(AppIndexDashboard): """ Custom app index dashboard for project. @@ -98,12 +158,7 @@ class CustomAppIndexDashboard(AppIndexDashboard): if self.app_title != 'Rh': # append a model list module and a recent actions module self.children += [ - modules.ModelList(self.app_title,self.models), - #modules.RecentActions( - # _('Recent Actions'), - # include_list=self.get_app_content_types(), - # limit=5 - #) + modules.ModelList(self.app_title, self.models), ] return @@ -112,12 +167,12 @@ class CustomAppIndexDashboard(AppIndexDashboard): self.children.append(modules.AppList( _('Application'), models=( - 'project.rh.models.AyantDroit', - 'project.rh.models.Dossier', - 'project.rh.models.DossierInactif', - 'project.rh.models.Employe', - 'project.rh.models.EmployeInactif', - 'project.rh.models.Poste', + 'project.rh.models.AyantDroit', + 'project.rh.models.Dossier', + 'project.rh.models.DossierInactif', + 'project.rh.models.Employe', + 'project.rh.models.EmployeInactif', + 'project.rh.models.Poste', ), )) @@ -125,19 +180,20 @@ class CustomAppIndexDashboard(AppIndexDashboard): self.children.append(modules.AppList( _('Configuration'), models=( - 'project.rh.models.Classement', - 'project.rh.models.Devise', - 'project.rh.models.FamilleEmploi', - 'project.rh.models.OrganismeBstg', - 'project.rh.models.Responsable', - 'project.rh.models.Service', - 'project.rh.models.Statut', - 'project.rh.models.TauxChange', - 'project.rh.models.TypeContrat', - 'project.rh.models.TypePoste', - 'project.rh.models.TypeRevalorisation', - 'project.rh.models.TypeRemuneration', - 'project.rh.models.ValeurPoint', + 'project.rh.models.Classement', + 'project.rh.models.Devise', + 'project.rh.models.CategorieEmploi', + 'project.rh.models.FamilleProfessionnelle', + 'project.rh.models.OrganismeBstg', + 'project.rh.models.Responsable', + 'project.rh.models.Service', + 'project.rh.models.Statut', + 'project.rh.models.TauxChange', + 'project.rh.models.TypeContrat', + 'project.rh.models.TypePoste', + 'project.rh.models.TypeRevalorisation', + 'project.rh.models.TypeRemuneration', + 'project.rh.models.ValeurPoint', ), )) @@ -145,13 +201,6 @@ class CustomAppIndexDashboard(AppIndexDashboard): self.children.append(modules.AppList( _(u'Inter-systèmes'), models=( - 'project.rh.models.ResponsableImplantation', + 'project.rh.models.ResponsableImplantation', ), )) - - # append a recent actions module - #self.children.append(modules.RecentActions( - # _('Recent Actions'), - # include_list=self.get_app_content_types(), - # limit=5 - #))