Exemplo n.º 1
0
    def post(self, request, *args, **kwargs):
        super(UpdateView, self).post(request, *args, **kwargs)

        self.resources = self.data['resources']
        del self.data['resources']
        question_form = QuestionForm(self.data, instance=self.object)

        if question_form.is_valid():
            return self.form_valid(question_form)
        else:
            return self.form_invalid(question_form)
Exemplo n.º 2
0
    def post(self, request, *args, **kwargs):
        super(UpdateView, self).post(request, *args, **kwargs)

        self.resources = self.data["resources"]
        del self.data["resources"]
        question_form = QuestionForm(self.data, instance=self.object)

        if question_form.is_valid():
            return self.form_valid(question_form)
        else:
            return self.form_invalid(question_form)
Exemplo n.º 3
0
    def post(self, request, *args, **kwargs):
        self.user = request.user
        self.object = self.get_object()

        if not self.object.can_be_edited_by(self.user):
            return http.HttpResponseForbidden()

        self.data = json.loads(request.POST["json"])
        self.resources = self.data["resources"]
        del self.data["resources"]
        question_form = QuestionForm(self.data, instance=self.object)

        if question_form.is_valid():
            return self.form_valid(question_form)
        else:
            return self.form_invalid(question_form)
Exemplo n.º 4
0
    def post(self, request, *args, **kwargs):
        self.user = request.user
        self.object = self.get_object()

        if not self.object.can_be_edited_by(self.user):
            return http.HttpResponseForbidden()

        self.data = json.loads(request.POST['json'])
        self.resources = self.data['resources']
        del self.data['resources']
        question_form = QuestionForm(self.data, instance=self.object)

        if question_form.is_valid():
            return self.form_valid(question_form)
        else:
            return self.form_invalid(question_form)
Exemplo n.º 5
0
    def post(self, request, *args, **kwargs):
        super(UpdateView, self).post(request, *args, **kwargs)

        self.resources = self.data['resources']
        del self.data['resources']
        question_form = QuestionForm(self.data, instance=self.object)
        data = {
            'form-TOTAL_FORMS': len(self.resources),
            'form-INITIAL_FORMS': len(self.resources),
        }
        for i,rd in enumerate(self.resources):
            data['form-{}-id'.format(i)] = rd['pk']
            data['form-{}-alt_text'.format(i)] = rd['alt_text']
        self.resources_form = ResourcesAltTextForm(data=data)

        if question_form.is_valid() and self.resources_form.is_valid():
            return self.form_valid(question_form)
        else:
            return self.form_invalid(question_form)