def post(self, request, *args, **kwargs):
    import_tmpfile_name = request.session.get('create_import_tmpfile_name')
    import_key = request.session.get('create_import_key')
    checked = [key for (key, value) in request.POST.items() if ('on' in value)]
    if (import_tmpfile_name and import_key):
        import_plugin = get_plugin('PROJECT_IMPORTS', import_key)
        import_plugin.file_name = import_tmpfile_name
        if import_plugin.check():
            try:
                import_plugin.process()
            except ValidationError as e:
                return render(request, 'core/error.html', {'title': _('Import error'), 'errors': e}, status=400)
            import_plugin.project.site = get_current_site(self.request)
            import_plugin.project.save()
            membership = Membership(project=import_plugin.project, user=request.user, role='owner')
            membership.save()
            save_import_values(import_plugin.project, import_plugin.values, checked)
            save_import_snapshot_values(import_plugin.project, import_plugin.snapshots, checked)
            save_import_tasks(import_plugin.project, import_plugin.tasks)
            save_import_views(import_plugin.project, import_plugin.views)
            return HttpResponseRedirect(import_plugin.project.get_absolute_url())
    return render(request, 'core/error.html', {'title': _('Import error'), 'errors': [_('There has been an error with your import.')]}, status=400)
def post(self, request, *args, **kwargs):
    import_tmpfile_name = request.session.get('create_import_tmpfile_name')
    import_key = request.session.get('create_import_key')
    checked = [key for (key, value) in request.POST.items() if ('on' in value)]
    if (import_tmpfile_name and import_key):
        import_plugin = get_plugin('PROJECT_IMPORTS', import_key)
        import_plugin.file_name = import_tmpfile_name
        if import_plugin.check():
            try:
                import_plugin.process()
            except ValidationError as e:
                return render(request, 'core/error.html', {'title': _('Import error'), 'errors': e}, status=400)
            import_plugin.project.site = get_current_site(self.request)
            import_plugin.project.save()
            membership = Membership(project=import_plugin.project, user=request.user, role='owner')
            membership.save()
            save_import_values(import_plugin.project, import_plugin.values, checked)
            save_import_snapshot_values(import_plugin.project, import_plugin.snapshots, checked)
            save_import_tasks(import_plugin.project, import_plugin.tasks)
            save_import_views(import_plugin.project, import_plugin.views)
            return HttpResponseRedirect(import_plugin.project.get_absolute_url())
    return render(request, 'core/error.html', {'title': _('Import error'), 'errors': [_('There has been an error with your import.')]}, status=400)