예제 #1
0
    def post(self, request, *args, **kwargs):
        # context = self.get_context_data(**kwargs)
        try:
            request.FILES['uploaded_file']
        except KeyError:
            return HttpResponseRedirect(self.success_url)
        else:
            tempfilename = handle_uploaded_file(request.FILES['uploaded_file'])

        tree = read_xml_file(tempfilename)
        if tree is None:
            log.info('Xml parsing error. Import failed.')
            return render(
                request,
                'core/error.html', {
                    'title':
                    _('Import error'),
                    'error':
                    _('The content of the xml file does not consist of well formed data or markup.'
                      )
                },
                status=400)
        else:
            import_questions(tree)
            return HttpResponseRedirect(self.success_url)
예제 #2
0
파일: views.py 프로젝트: AYCHSearch/RDMO
    def post(self, request, *args, **kwargs):
        try:
            request.FILES['uploaded_file']
        except KeyError:
            return HttpResponseRedirect(self.success_url)
        else:
            tempfilename = handle_uploaded_file(request.FILES['uploaded_file'])

        tree = read_xml_file(tempfilename)
        if tree is None:
            log.info('Xml parsing error. Import failed.')
            return render(request, self.parsing_error_template, status=400)
        else:
            import_conditions(tree)
            return HttpResponseRedirect(self.success_url)