mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-17 03:39:25 +00:00
Fixes the HR message issue when changing status
This commit is contained in:
18
hr/models.py
18
hr/models.py
@@ -66,23 +66,31 @@ class Application(models.Model):
|
|||||||
return blacklist
|
return blacklist
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
|
||||||
|
user = None
|
||||||
|
if 'user' in kwargs:
|
||||||
|
user = kwargs['user']
|
||||||
|
del kwargs['user']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
old_instance = Application.objects.get(id=self.id)
|
old_instance = Application.objects.get(id=self.id)
|
||||||
if not (old_instance.status == int(self.status)):
|
if not (old_instance.status == int(self.status)):
|
||||||
event = Audit(application=self)
|
event = Audit(application=self)
|
||||||
if 'user' in kwargs:
|
event.user = user
|
||||||
event.user = kwargs['user']
|
|
||||||
event.event = AUDIT_EVENT_STATUSCHANGE
|
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()
|
event.save()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if 'user' in kwargs:
|
|
||||||
del kwargs['user']
|
|
||||||
super(Application, self).save(*args, **kwargs)
|
super(Application, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.character.name
|
return self.character.name
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user