示例#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)
示例#2
0
文件: question.py 项目: numbas/editor
    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)
示例#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)
示例#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)
示例#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)