- list = []\r
- if request.method == "POST" and "dump" in request.FILES:\r
- dump = ZipFile(request.FILES['dump'])\r
- members = [f for f in dump.namelist() if f.endswith('.xml')]\r
- extract_to = os.path.join(os.path.dirname(__file__), 'tmp')\r
-\r
- if not os.path.exists(extract_to):\r
- os.makedirs(extract_to)\r
-\r
- for m in members:\r
- f = open(os.path.join(extract_to, m), 'w')\r
- f.write(dump.read(m))\r
- f.close()\r
-\r
- #dump.extractall(extract_to, members)\r
- dump.close()\r
- importer.sximport(extract_to, request.POST)\r
-\r
- return render_to_response('modules/sximporter/page.html', {\r
- 'names': list\r
- }, context_instance=RequestContext(request))\r
+ if (not User.objects.exists()) or (request.user.is_authenticated() and request.user.is_superuser):\r
+ list = []\r
+ if request.method == "POST" and "dump" in request.FILES:\r
+ dump = ZipFile(request.FILES['dump'])\r
+ members = [f for f in dump.namelist() if f.endswith('.xml')]\r
+ extract_to = os.path.join(os.path.dirname(__file__), 'tmp')\r
+\r
+ if not os.path.exists(extract_to):\r
+ os.makedirs(extract_to)\r
+\r
+ for m in members:\r
+ f = open(os.path.join(extract_to, m), 'w')\r
+ f.write(dump.read(m))\r
+ f.close()\r
+\r
+ #dump.extractall(extract_to, members)\r
+ dump.close()\r
+\r
+ options = dict([(k, v) for k, v in request.POST.items()])\r
+ options['authenticated_user'] = (request.user.is_authenticated() and (request.user,) or (None,))[0]\r
+\r
+ importer.sximport(extract_to, options)\r
+\r
+ return render_to_response('modules/sximporter/page.html', {\r
+ 'names': list\r
+ }, context_instance=RequestContext(request))\r
+ else:\r
+ return HttpResponseUnauthorized(request)\r
+\r