Exemplo n.º 1
0
    def update_obj(self, obj, request, custom_pk=None, *args, **kwargs):
        cake_form = CakeForm(request.DATA)

        if cake_form.is_valid():
            return self._update_obj(
                obj, cake_form.cleaned_data, custom_pk=custom_pk)
        else:
            self.raise_validation_error(request, cake_form.errors)
Exemplo n.º 2
0
    def update_obj(self, obj, request, custom_pk=None, *args, **kwargs):
        cake_form = CakeForm(request.DATA)

        if cake_form.is_valid():
            return self._update_obj(obj,
                                    cake_form.cleaned_data,
                                    custom_pk=custom_pk)
        else:
            self.raise_validation_error(request, cake_form.errors)
Exemplo n.º 3
0
    def _put(self, request, *args, **kwargs):
        data = request.DATA

        if not isinstance(data, list):
            self.raise_http_error(request, 'Must be a list')

        cake_forms = []

        for cake in data:
            cake_form = CakeForm(cake)

            if not cake_form.is_valid():
                self.raise_http_error(request, 'Invalid Cake')

            cake_forms.append(cake_form)

        # Delete Old List
        Cake.objects.all().delete()

        # Create New List
        cakes = [self._update_obj(Cake(), cake_form.cleaned_data) \
                    for cake_form in cake_forms]

        return cakes
Exemplo n.º 4
0
    def _put(self, request, *args, **kwargs):
        data = request.DATA

        if not isinstance(data, list):
            self.raise_http_error(request, 'Must be a list')

        cake_forms = []

        for cake in data:
            cake_form = CakeForm(cake)

            if not cake_form.is_valid():
                self.raise_http_error(request, 'Invalid Cake')

            cake_forms.append(cake_form)

        # Delete Old List
        Cake.objects.all().delete()

        # Create New List
        cakes = [self._update_obj(Cake(), cake_form.cleaned_data) \
                    for cake_form in cake_forms]

        return cakes