Project

General

Profile

« Previous | Next » 

Revision 8e6a3c86

Added by Serghei Mihai over 9 years ago

logging actions on models improved using post_save and pre_delete signals

View differences:

calebasse/dossiers/models.py
239 239
                datetime(self.date_selected.year,
240 240
                        self.date_selected.month, self.date_selected.day)
241 241
        super(FileState, self).save(**kwargs)
242
        get_request().record('filestate-save', '{obj_id} saved by {user} from {ip}', obj_id=self.id)
243 242

  
244 243
    def __unicode__(self):
245 244
        return self.status.name + ' ' + str(self.date_selected)
......
254 253
            self.patient.save()
255 254
        obj_id = self.id
256 255
        super(FileState, self).delete(*args, **kwargs)
257
        get_request().record('filestate-delete', '{obj_id} deleted by {user} from {ip}',
258
                             obj_id=obj_id)
259 256

  
260 257
class PatientAddress(models.Model):
261 258

  
......
297 294
        if self.city:
298 295
            self.display_name += self.city + ' '
299 296
        super(PatientAddress, self).save(**kwargs)
300
        get_request().record('patientaddress-save', '{obj_id} saved by {user} from {ip}', obj_id=self.id)
301 297

  
302 298
class PatientContact(People):
303 299
    class Meta:
......
576 572
        if not getattr(self, 'service', None):
577 573
            raise Exception('The field service is mandatory.')
578 574
        super(PatientRecord, self).save(*args, **kwargs)
579
        get_request().record('patientrecord-save', '{obj_id} saved by {user} from {ip}', obj_id=self.id)
580 575

  
581 576
    def get_state(self):
582 577
        return self.last_state
......
636 631
        if self.can_be_deleted():
637 632
            obj_id = self.id
638 633
            super(PatientRecord, self).delete(*args, **kwargs)
639
            get_request().record('patientrecord-delete', '{obj_id} by {user} from {ip}', obj_id=obj_id)
640 634

  
641 635
    def get_ondisk_directory(self, service):
642 636
        if not settings.PATIENT_FILES_BASE_DIRECTORY:
......
1025 1019
    patient.save()
1026 1020
    patient.policyholder = patient.patientcontact
1027 1021
    patient.save()
1028
    get_request().record('new-patient', '{first_name} {last_name} ({id}) created by {user} from {ip}',
1029
                         first_name=patient.first_name, last_name=patient.last_name, id=patient.id)
1030 1022
    return patient

Also available in: Unified diff