Example #1
0
    def perform_update(self, serializer):
        """ This method is override to set updated_by in Customer and add edition log """
        # Get changed fields in instance
        updated_customer = self.get_object()
        changed_fields = Customer.get_changed_fields(
            new_data=serializer.validated_data, instance=updated_customer)

        # The current user is the last user that has updated it
        instance = serializer.save(updated_by=self.request.user)

        # Add log
        CustomerLogManager.add_edition_log(user=self.request.user,
                                           customer=instance,
                                           changed_fields=changed_fields)
Example #2
0
 def add_creation_log(cls, user, customer, new_data):
     log_type = customer_choices.LOG_CREATION_TYPE
     changed_fields = Customer.get_changed_fields(new_data=new_data)
     cls._create_customer_log(user, customer, log_type, changed_fields)