Example #1
0
 def save(self, *args, **kwargs):
     if self.id:
         # self.modified_by = CuserMiddleware.get_user()
         self.modified_on = datetime()
     else:
         # self.created_by = CuserMiddleware.get_user()
         self.created_on = datetime()
         kwargs['force_insert'] = False
     super(Auditable, self).save(*args, **kwargs)
Example #2
0
 def _create_user(self, email, password, is_admin=False,
                  **extra_fields):
     if not email:
         raise ValueError('Users must have an email address')
     is_active = extra_fields.pop("is_active", True)
     user = self.model(email=self.normalize_email(email),
                       is_active=is_active,
                       is_admin=is_admin, last_login=datetime(), **extra_fields)
     user.set_password(password)
     user.save(using=self._db)
     return user
Example #3
0
 def update(self):
     super(AuditableQuerySet, self).update(modified_on=datetime(), modified_by=current_user)
Example #4
0
 def delete(self):
     super(AuditableQuerySet, self).update(is_deleted=True, modified_on=datetime(), modified_by=current_user)