ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'SIGMA.dashboard.CustomAppIndexDashboard'
"""
-from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
+from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
+from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
from project.decorators import in_drh_or_admin
from project.rh.historique import get_active_revisions
for rev in revisions:
date = rev['short_date_created']
user = u"<span style='font-weight: bold;'>%s</span>" % rev['user']
- type = u"<span style='font-decoration: underligne;'>%s</span>" % rev['type']
- titre = u"""<span style='color:black;'>[%s] %s a modifié
- un(e) %s :</span> %s""" % (date, user, type, rev['objet'], )
- children.append({
- 'title': titre,
- 'url': rev['history_url'],
- 'external': False,
- })
+ if rev['type'] is None or rev['objet'] is None:
+ titre = u"""<span style='color:black;'>[%s] %s</span>
+ commentaire : %s """ % (date, user, rev['comment'])
+ children.append({
+ 'title': titre,
+ 'url': reverse('rhr_historique_des_modifications'),
+ 'external': False,
+ })
+ else:
+ type = u"<span style='font-decoration: underligne;'>%s</span>" % rev['type']
+ titre = u"""<span style='color:black;'>[%s] %s a modifié
+ un(e) %s :</span> %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,)
history_url = None
type = None
objet = None
+
for v in rev.version_set.all():
try:
+ klass = v.content_type.model_class()
+ id = int(v.object_id)
+ objet = klass.objects.get(id=id)
change_url = reverse('admin:rh_%s_change' % v.content_type.model,
- args=(v.object.id, ))
+ args=(id, ))
history_url = reverse('admin:rh_%s_history' % v.content_type.model,
- args=(v.object.id, ))
- type = v.content_type
- objet = v.object
+ args=(id, ))
+ type = klass._meta.verbose_name
break
except:
continue
'comment': rev.comment,
'change_url': change_url,
'history_url': history_url,
- 'type': unicode(type).capitalize(),
+ 'type': type,
'objet': objet,
})