예제 #1
0
 def partial_update(self, request, *args, **kwargs):
     instance = self.get_object()
     log = ActionsForLogEntry()
     log.insert_log_entry(request, instance, {}, CHANGE,
                          self.serializer_class.__name__)
     kwargs['partial'] = True
     return self.update(request, *args, **kwargs)
 def update(self, instance, validated_data):
     instance_super = super(RequestAPISerializer,
                            self).update(instance, validated_data)
     log = ActionsForLogEntry()
     log.insert_log_entry(self.context['request'], instance_super,
                          validated_data, CHANGE, "RequestAPISerializer")
     return instance_super
 def create(self, validated_data):
     instance_super = super(ProductCreateSerializer,
                            self).create(validated_data)
     log = ActionsForLogEntry()
     log.insert_log_entry(self.context['request'], instance_super,
                          validated_data, ADDITION,
                          "ProductCreateSerializer")
     return instance_super
 def update(self, instance, validated_data):
     instance_super = super(ExtraProductTypeRetrieveUpdateAPISerializer,
                            self).update(instance, validated_data)
     log = ActionsForLogEntry()
     log.insert_log_entry(self.context['request'], instance_super,
                          validated_data, CHANGE,
                          "ExtraProductTypeRetrieveUpdateAPISerializer")
     return instance_super
예제 #5
0
    def destroy(self, request, *args, **kwargs):
        instance = self.get_object()

        log = ActionsForLogEntry()

        log.insert_log_entry(request, instance, {}, DELETION,
                             self.serializer_class.__name__)

        return super().destroy(request, *args, **kwargs)
    def update(self, instance, validated_data):

        obj = {"products": []}
        for pk in validated_data["products"]:
            obj["products"].append(int(pk["id"]))
        obj["client"] = Client.objects.get(pk=self.context['request'].user.pk)
        instance_super = super(RequestCreateSerializer,
                               self).update(instance, obj)
        log = ActionsForLogEntry()
        log.insert_log_entry(self.context['request'], instance_super,
                             validated_data, CHANGE, "RequestCreateSerializer")
        return validated_data
예제 #7
0
    def update(self, instance, validated_data):
        user_data = validated_data.get('user', None)
        user = instance.user
        if user_data:
            user = UserSerializer.update(UserSerializer(),
                                         instance=instance.user,
                                         validated_data=user_data)
        instance.user = user
        instance.cpf = validated_data.get('cpf', instance.cpf)
        instance.birthday = validated_data.get('birthday', instance.birthday)
        instance.gender = validated_data.get('gender', instance.gender)
        instance.phone_number = validated_data.get('phone_number',
                                                   instance.phone_number)
        instance.save()

        log = ActionsForLogEntry()
        log.insert_log_entry(self.context['request'], instance, validated_data,
                             CHANGE, "ClientSerializer")

        return instance