View | Details | Raw Unified | Return to bug 32888 | Differences between
and this patch

Collapse All | Expand All

(-)ucs-school-umc-distribution/umc/js/distribution/DetailPage.js (+3 lines)
 Lines 150-155    Link Here 
150
				})
150
				})
151
			}, {
151
			}, {
152
				type: MultiUploader,
152
				type: MultiUploader,
153
				multiFile: true,
153
				name: 'files',
154
				name: 'files',
154
				command: 'distribution/upload',
155
				command: 'distribution/upload',
155
				dynamicOptions: {
156
				dynamicOptions: {
 Lines 312-317    Link Here 
312
		},
313
		},
313
314
314
		_checkFilenameUpload: function(fileInfo) {
315
		_checkFilenameUpload: function(fileInfo) {
316
			console.log('### _checkFilenameUpload:', fileInfo);
317
			//return true;
315
			var nameWidget = this._form.getWidget('name');
318
			var nameWidget = this._form.getWidget('name');
316
			var isNewProject = !nameWidget.get('disabled');
319
			var isNewProject = !nameWidget.get('disabled');
317
			return this.umcpCommand('distribution/checkfiles', {
320
			return this.umcpCommand('distribution/checkfiles', {
(-)ucs-school-umc-distribution/umc/python/distribution/__init__.py (-11 / +20 lines)
 Lines 72-93    Link Here 
72
	@file_upload
72
	@file_upload
73
	def upload(self, request):
73
	def upload(self, request):
74
		# make sure that we got a list
74
		# make sure that we got a list
75
		MODULE.info('### upload: %r' % (request, ))
76
		MODULE.info('### upload options: %r' % (request.options, ))
75
		if not isinstance(request.options, (tuple, list)):
77
		if not isinstance(request.options, (tuple, list)):
76
			raise UMC_OptionTypeError( 'Expected list of dicts, but got: %s' % str(request.options) )
78
			raise UMC_OptionTypeError( 'Expected list of dicts, but got: %s' % str(request.options) )
77
		file = request.options[0]
78
		if not ('tmpfile' in file and 'filename' in file):
79
			raise UMC_OptionTypeError( 'Invalid upload data, got: %s' % str(file) )
80
79
81
		# create a temporary upload directory, if it does not already exist
80
		#file = request.options[0]
82
		if not self._tmpDir:
81
		for file in request.options:
83
			self._tmpDir = tempfile.mkdtemp(prefix='ucsschool-distribution-upload-')
82
			if not ('tmpfile' in file and 'filename' in file):
84
			MODULE.info('Created temporary directory: %s' % self._tmpDir)
83
				raise UMC_OptionTypeError( 'Invalid upload data, got: %s' % str(file) )
85
84
86
		filename = self.__workaround_filename_bug(file)
85
			# create a temporary upload directory, if it does not already exist
87
		destPath = os.path.join(self._tmpDir, filename)
86
			if not self._tmpDir:
88
		MODULE.info('Received file %r, saving it to %r' % (file['tmpfile'], destPath))
87
				self._tmpDir = tempfile.mkdtemp(prefix='ucsschool-distribution-upload-')
89
		shutil.move(file['tmpfile'], destPath)
88
				MODULE.info('Created temporary directory: %s' % self._tmpDir)
90
89
90
			filename = self.__workaround_filename_bug(file)
91
			destPath = os.path.join(self._tmpDir, filename)
92
			MODULE.info('Received file %r, saving it to %r' % (file['tmpfile'], destPath))
93
			shutil.move(file['tmpfile'], destPath)
94
91
		# done
95
		# done
92
		self.finished( request.id, None )
96
		self.finished( request.id, None )
93
97
 Lines 124-129    Link Here 
124
			'distributed': True|False
128
			'distributed': True|False
125
		}
129
		}
126
		'''
130
		'''
131
		###TODO: remove me
132
		MODULE.info ('### Request: %r' % (request, ))
133
		MODULE.info ('### Request.options: %r' % (request.options, ))
134
		self.finished( request.id, True )
135
		return
127
136
128
		if not 'filenames' in request.options or not 'project' in request.options:
137
		if not 'filenames' in request.options or not 'project' in request.options:
129
			raise UMC_OptionTypeError( 'Expected dict with entries "filenames" and "project", but got: %s' % request.options )
138
			raise UMC_OptionTypeError( 'Expected dict with entries "filenames" and "project", but got: %s' % request.options )

Return to bug 32888