From 72e1d9d42ec306e6baa53fd271d7d0ab797e30a5 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Wed, 28 Jul 2010 11:59:41 +0100 Subject: [PATCH] Fixes the HR message issue when changing status --- hr/models.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hr/models.py b/hr/models.py index 6d5cbb9..89ed562 100644 --- a/hr/models.py +++ b/hr/models.py @@ -66,23 +66,31 @@ class Application(models.Model): return blacklist def save(self, *args, **kwargs): + + user = None + if 'user' in kwargs: + user = kwargs['user'] + del kwargs['user'] + try: old_instance = Application.objects.get(id=self.id) if not (old_instance.status == int(self.status)): event = Audit(application=self) - if 'user' in kwargs: - event.user = kwargs['user'] + event.user = user event.event = AUDIT_EVENT_STATUSCHANGE - event.text = "Status changed from %s to %s" % (old_instance.get_status_display(), self.get_status_display()) + # Save the application so we can get a up to date status + super(Application, self).save(*args, **kwargs) + new_instance = Application.objects.get(id=self.id) + + event.text = "Status changed from %s to %s" % (old_instance.get_status_display(), new_instance.get_status_display()) event.save() except: pass - if 'user' in kwargs: - del kwargs['user'] super(Application, self).save(*args, **kwargs) + def __unicode__(self): return self.character.name