Example #1
0
    def handle(self, *args, **options):

        roottag, xmltree = validate_xml(options['xmlfile'])

        if roottag == 'conditions':
            import_conditions(xmltree)

        elif roottag == 'options':
            import_options(xmltree)

        elif roottag == 'domain':
            import_domain(xmltree)

        elif roottag == 'catalog':
            import_catalog(xmltree)

        elif roottag == 'tasks':
            import_tasks(xmltree)

        elif roottag == 'views':
            import_views(xmltree)

        elif roottag == 'project':
            try:
                user = User.objects.get(username=options['user'])
            except User.DoesNotExist:
                raise CommandError('Give a valid username using --user.')
            import_project(xmltree, user)
Example #2
0
    def handle(self, *args, **options):

        tree = et.parse(options['xmlfile'])
        root = tree.getroot()

        if root.tag == 'rdmo':
            import_conditions(root)
            import_options(root)
            import_domain(root)
            import_questions(root)
            import_tasks(root)
            import_views(root)
Example #3
0
    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_domain(tree)
            return HttpResponseRedirect(self.success_url)
Example #4
0
    def post(self, request, *args, **kwargs):
        # context = self.get_context_data(**kwargs)
        try:
            request.FILES['uploaded_file']
        except:
            return HttpResponseRedirect(self.success_url)
        else:
            tempfilename = handle_uploaded_file(request.FILES['uploaded_file'])

        roottag, xmltree = validate_xml(tempfilename)
        if roottag == 'domain':
            import_domain(xmltree)
            return HttpResponseRedirect(self.success_url)
        else:
            log.info('Xml parsing error. Import failed.')
            return render(request, self.parsing_error_template, status=400)
Example #5
0
    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, '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_domain(tree)
            return HttpResponseRedirect(self.success_url)
Example #6
0
    def handle(self, *args, **options):

        tree = et.parse(options['xmlfile'])
        root = tree.getroot()

        if root.tag == 'rdmo':
            import_conditions(root)
            import_options(root)
            import_domain(root)
            import_questions(root)
            import_tasks(root)
            import_views(root)
        elif root.tag == 'project':
            try:
                user = User.objects.get(username=options['user'])
            except User.DoesNotExist:
                raise CommandError('Give a valid username using --user.')

            import_project(user, root)