--- ucs-school-umc-distribution/umc/js/distribution/DetailPage.js (Revision 59808) +++ ucs-school-umc-distribution/umc/js/distribution/DetailPage.js (Arbeitskopie) @@ -150,6 +150,7 @@ }) }, { type: MultiUploader, + multiFile: true, name: 'files', command: 'distribution/upload', dynamicOptions: { @@ -312,22 +313,52 @@ }, _checkFilenameUpload: function(fileInfo) { + var filename; + if ('name' in fileInfo){ + filename = [ fileInfo.name ]; + }else{ + if (fileInfo.length > 1) { + filename = []; + fileInfo.forEach(function(ifile){ + filename.push(ifile.name); + }); + } + } var nameWidget = this._form.getWidget('name'); var isNewProject = !nameWidget.get('disabled'); + return this.umcpCommand('distribution/checkfiles', { project: isNewProject ? null : nameWidget.get('value'), - filenames: [ fileInfo.name ] - }).then(lang.hitch(this, function(response) { - var result = response.result[0]; - if (result.distributed) { + filenames: filename + }).then(function(response) { + + var distributed = []; + var projectDuplicate = []; + var sessionDuplicate = []; + var result = response.result; + + array.forEach(result, lang.hitch(this, function(ifile){ + if (ifile.distributed){ + distributed.push(ifile.filename); + } + if (ifile.projectDuplicate){ + projectDuplicate.push(ifile.filename); + } + if (ifile.sessionDuplicate){ + sessionDuplicate.push(ifile.filename); + } + })); + + if (distributed.length > 0){ // do not allow the upload of an already distributed file - dialog.alert(_('The file "%s" cannot be uploaded as it has already been distributed.', fileInfo.name)); + var files = distributed.join(); + dialog.alert(_('The following files cannot be uploaded as they have already been distributed: %s','')); return false; } - if (result.projectDuplicate) { - // the file exists in the project, but has not been distributed yet - return dialog.confirm(_('The file "%s" has already been assigned to the project, please confirm to overwrite it.', fileInfo.name), [{ + if (projectDuplicate.length > 0){ + // a file exists in the project, but has not been distributed yet + return dialog.confirm(_('The following files have already been assigned to the project, please confirm to overwrite them: %s',''), [{ name: 'cancel', label: _('Cancel upload') }, { @@ -339,9 +370,9 @@ }); } - if (result.sessionDuplicate) { + if (sessionDuplicate.length > 0){ // a file with the same name has already been uploaded during this session - return dialog.confirm(_('The file "%s" has already been uploaded, please confirm to overwrite it.', fileInfo.name), [{ + return dialog.confirm(_('The following files have already been uploaded, please confirm to overwrite them: %s', ''), [{ name: 'cancel', label: _('Cancel upload') }, { @@ -355,7 +386,8 @@ // everything OK :) return true; - })); + }); + }, _resetForm: function() { --- ucs-school-umc-distribution/umc/js/de.po (Revision 59808) +++ ucs-school-umc-distribution/umc/js/de.po (Arbeitskopie) @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: ucs-school-umc-distribution\n" "Report-Msgid-Bugs-To: packages@univention.de\n" -"POT-Creation-Date: 2015-02-16 16:40+0100\n" +"POT-Creation-Date: 2015-04-15 13:54+0200\n" "PO-Revision-Date: 2012-05-14 11:48+0200\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -32,19 +32,19 @@ msgid "All projects" msgstr "Alle Projekte" -#: umc/js/distribution/DetailPage.js:167 +#: umc/js/distribution/DetailPage.js:168 msgid "Assign classes/workgroups" msgstr "Klassen/Arbeitsgruppen zuordnen" -#: umc/js/distribution/DetailPage.js:168 +#: umc/js/distribution/DetailPage.js:169 msgid "Assigned classes/workgroups" msgstr "Zugeordnete Klassen/Arbeitsgruppen" -#: umc/js/distribution/DetailPage.js:230 +#: umc/js/distribution/DetailPage.js:231 msgid "Automatic collection" msgstr "Automatisches Einsammeln" -#: umc/js/distribution/DetailPage.js:205 +#: umc/js/distribution/DetailPage.js:206 msgid "Automatic distribution" msgstr "Automatisches Austeilen" @@ -57,7 +57,7 @@ msgid "Cancel" msgstr "Abbrechen" -#: umc/js/distribution/DetailPage.js:332 umc/js/distribution/DetailPage.js:346 +#: umc/js/distribution/DetailPage.js:363 umc/js/distribution/DetailPage.js:377 msgid "Cancel upload" msgstr "Dateitransfer abbrechen" @@ -73,15 +73,15 @@ msgid "Collect project files from users." msgstr "Projektdateien von Schüler einsammeln." -#: umc/js/distribution/DetailPage.js:235 +#: umc/js/distribution/DetailPage.js:236 msgid "Collection date" msgstr "Einsammeldatum" -#: umc/js/distribution/DetailPage.js:222 +#: umc/js/distribution/DetailPage.js:223 msgid "Collection of project files" msgstr "Einsammeln der Projektdateien" -#: umc/js/distribution/DetailPage.js:240 +#: umc/js/distribution/DetailPage.js:241 msgid "Collection time" msgstr "Einsammelzeit" @@ -89,15 +89,15 @@ msgid "Create a new distribution project" msgstr "Neues Verteilungsprojekt erstellen" -#: umc/js/distribution/DetailPage.js:428 +#: umc/js/distribution/DetailPage.js:460 msgid "Create project" msgstr "Projekt erstellen" -#: umc/js/distribution/DetailPage.js:236 +#: umc/js/distribution/DetailPage.js:237 msgid "Date at which the project files will be collected automatically." msgstr "Datum, an dem die Projektdateien automatisch eingesammelt werden." -#: umc/js/distribution/DetailPage.js:211 +#: umc/js/distribution/DetailPage.js:212 msgid "Date at which the project files will be distributed automatically." msgstr "Datum, an dem die Projektdateien automatisch verteilt werden." @@ -121,19 +121,19 @@ msgid "Distribute project files to users." msgstr "Projektdateien an Schüler verteilen." -#: umc/js/distribution/DetailPage.js:250 +#: umc/js/distribution/DetailPage.js:251 msgid "Distribution and collection of project files" msgstr "Verteilen und Einsammeln der Projektdateien" -#: umc/js/distribution/DetailPage.js:210 +#: umc/js/distribution/DetailPage.js:211 msgid "Distribution date" msgstr "Verteilungsdatum" -#: umc/js/distribution/DetailPage.js:197 +#: umc/js/distribution/DetailPage.js:198 msgid "Distribution of project files" msgstr "Verteilen der Projektdateien" -#: umc/js/distribution/DetailPage.js:216 +#: umc/js/distribution/DetailPage.js:217 msgid "Distribution time" msgstr "Verteilungszeit" @@ -153,31 +153,31 @@ msgid "Error: No recipients have been assigned to the project!" msgstr "Fehler: Kein Empfänger wurde für das Projekt ausgewählt!" -#: umc/js/distribution/DetailPage.js:159 umc/js/distribution/DetailPage.js:259 +#: umc/js/distribution/DetailPage.js:160 umc/js/distribution/DetailPage.js:260 msgid "Files" msgstr "Dateien" -#: umc/js/distribution/DetailPage.js:160 +#: umc/js/distribution/DetailPage.js:161 msgid "Files that have been added to this teaching material project" msgstr "Dateien, die mit Materialverteilungsprojekt verknüpft sind" -#: umc/js/distribution/DetailPage.js:247 +#: umc/js/distribution/DetailPage.js:248 msgid "General" msgstr "Allgemein" -#: umc/js/distribution/DetailPage.js:169 +#: umc/js/distribution/DetailPage.js:170 msgid "List of groups that are marked to receive the teaching materials" msgstr "Liste der Gruppen, die die Projektmaterialien empfangen werden" -#: umc/js/distribution/DetailPage.js:227 +#: umc/js/distribution/DetailPage.js:228 msgid "Manual collection" msgstr "Manuelles Einsammeln" -#: umc/js/distribution/DetailPage.js:202 +#: umc/js/distribution/DetailPage.js:203 msgid "Manual distribution" msgstr "Manuelles Verteilen" -#: umc/js/distribution/DetailPage.js:256 +#: umc/js/distribution/DetailPage.js:257 msgid "Members" msgstr "Mitglieder" @@ -200,7 +200,7 @@ msgid "Only the owner of a project is able to remove it." msgstr "Nur der Eigentümer eines Projektes kann es entfernen." -#: umc/js/distribution/DetailPage.js:335 umc/js/distribution/DetailPage.js:349 +#: umc/js/distribution/DetailPage.js:366 umc/js/distribution/DetailPage.js:380 msgid "Overwrite file" msgstr "Datei überschreiben" @@ -252,15 +252,15 @@ msgid "Removes the project from the internal database." msgstr "Löscht das Projekt aus der internen Datenbank." -#: umc/js/distribution/DetailPage.js:84 umc/js/distribution/DetailPage.js:408 +#: umc/js/distribution/DetailPage.js:84 umc/js/distribution/DetailPage.js:440 msgid "Save changes" msgstr "Änderungen speichern" -#: umc/js/distribution/DetailPage.js:173 +#: umc/js/distribution/DetailPage.js:174 msgid "School" msgstr "Schule" -#: umc/js/distribution/DetailPage.js:180 +#: umc/js/distribution/DetailPage.js:181 msgid "Search name" msgstr "Suchname" @@ -277,12 +277,12 @@ msgstr "" "Gibt die Zeichenkette an, nach der in den Projektbeschreibungen gesucht wird." -#: umc/js/distribution/DetailPage.js:223 +#: umc/js/distribution/DetailPage.js:224 msgid "" "Specifies whether the project data is collected automatically or manually." msgstr "Gibt an, ob das Projekte automatisch oder manuell eingesammelt wird." -#: umc/js/distribution/DetailPage.js:198 +#: umc/js/distribution/DetailPage.js:199 msgid "" "Specifies whether the project data is distributed automatically or manually." msgstr "Gibt an, ob das Projekte automatisch oder manuell verteilt wird." @@ -295,42 +295,46 @@ msgid "The description of the teaching material project" msgstr "Die Beschreibung des Materialverteilungsprojekts" -#: umc/js/distribution/DetailPage.js:324 +#: umc/js/distribution.js:320 umc/js/distribution.js:384 #, python-format -msgid "The file \"%s\" cannot be uploaded as it has already been distributed." -msgstr "" -"Die Datei \"%s\" kann nicht übertragen werden, da sie bereits verteilt wurde" +msgid "The following error occurred: %s" +msgstr "Der folgende Fehler trat auf: %s" -#: umc/js/distribution/DetailPage.js:330 +#: umc/js/distribution/DetailPage.js:306 #, python-format msgid "" -"The file \"%s\" has already been assigned to the project, please confirm to " -"overwrite it." +"The following files cannot be removed as they have already been distributed: " +"%s" msgstr "" -"Die Datei \"%s\" wurde bereits dem Projekt hinzugefügt. Bitte bestätigen " -"Sie, um die vorhandene Datei zu überschreiben." +"Die folgenden Dateien können nicht entfernt werden, da sie bereits verteilt " +"wurden." -#: umc/js/distribution/DetailPage.js:344 +#: umc/js/distribution/DetailPage.js:355 #, python-format msgid "" -"The file \"%s\" has already been uploaded, please confirm to overwrite it." +"The following files cannot be uploaded as they have already been " +"distributed: %s" msgstr "" -"Die Datei \"%s\" wurde bereits während der Sitzung hochgeladen. Bitte " -"bestätigen Sie, um die vorhandene Datei zu überschreiben." +"Die folgenden Dateien können nicht hochgeladen werden, da sie bereits verteilt " +"wurden: %s" -#: umc/js/distribution.js:320 umc/js/distribution.js:384 +#: umc/js/distribution/DetailPage.js:361 #, python-format -msgid "The following error occurred: %s" -msgstr "Der folgende Fehler trat auf: %s" +msgid "" +"The following files have already been assigned to the project, please " +"confirm to overwrite them: %s" +msgstr "" +"Die folgenden Dateien wurde bereits dem Projekt hinzugefügt. Bitte bestätigen " +"Sie, um die vorhandenen Dateien zu überschreiben: %s" -#: umc/js/distribution/DetailPage.js:305 +#: umc/js/distribution/DetailPage.js:375 #, python-format msgid "" -"The following files cannot be removed as they have already been distributed: " -"%s" +"The following files have already been uploaded, please confirm to overwrite " +"them: %s" msgstr "" -"Die folgenden Dateien können nicht entfernt werden, da sie bereits verteilt " -"wurden." +"Die folgenden Dateien wurde bereits während der Sitzung hochgeladen. Bitte " +"bestätigen Sie, um die vorhandenen Dateien zu überschreiben: %s" #: umc/js/distribution/DetailPage.js:132 msgid "" @@ -354,11 +358,11 @@ "Diese Seite ermöglicht es, Eigenschaften eines bestehenden oder neuen " "Materialverteilungsprojekts zu bearbeiten." -#: umc/js/distribution/DetailPage.js:241 +#: umc/js/distribution/DetailPage.js:242 msgid "Time at which the project files will be collected automatically." msgstr "Zeit, zu der die Projektdateien automatisch eingesammelt werden." -#: umc/js/distribution/DetailPage.js:217 +#: umc/js/distribution/DetailPage.js:218 msgid "Time at which the project files will be distributed automatically." msgstr "Zeit, zu der die Projektdateien automatisch verteilt werden." @@ -396,6 +400,12 @@ #~ msgstr "Speichern" #~ msgid "" +#~ "The file \"%s\" cannot be uploaded as it has already been distributed." +#~ msgstr "" +#~ "Die Datei \"%s\" kann nicht übertragen werden, da sie bereits verteilt " +#~ "wurde" + +#~ msgid "" #~ "This page demonstrates how object properties can be viewed for editing." #~ msgstr "Diese " --- ucs-school-umc-distribution/umc/python/distribution/de.po (Revision 59808) +++ ucs-school-umc-distribution/umc/python/distribution/de.po (Arbeitskopie) @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: ucs-school-umc-distribution\n" "Report-Msgid-Bugs-To: packages@univention.de\n" -"POT-Creation-Date: 2014-08-15 11:21+0200\n" +"POT-Creation-Date: 2015-04-15 13:54+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,22 +16,22 @@ msgid "A valid project owner needs to be specified." msgstr "Für ein gültiges Projekt muss ein Besitzer definiert sein." -#: umc/python/distribution/__init__.py:173 +#: umc/python/distribution/__init__.py:197 #, python-format msgid "Could not authenticate user \"%s\"!" msgstr "Der Benutzer konnte nicht authentifizieren werden: \"%s\"!" -#: umc/python/distribution/util.py:439 +#: umc/python/distribution/util.py:437 #, python-format msgid "Could not save project file: %s (%s)" msgstr "Das Projekt konnte nicht gespeichert werden: %s (%s)" -#: umc/python/distribution/__init__.py:226 +#: umc/python/distribution/__init__.py:253 #, python-format msgid "Could not set date for: %s" msgstr "Die Zeit konnte nicht gesetzt werden: %s" -#: umc/python/distribution/__init__.py:238 +#: umc/python/distribution/__init__.py:265 msgid "" "Distributing the data needs to happen sufficiently long enough before " "collecting them" @@ -39,34 +39,34 @@ "Die Verteilung der Daten muss ausreichend lange vor ihrem Einsammeln " "geschehen" -#: umc/python/distribution/__init__.py:171 +#: umc/python/distribution/__init__.py:195 #, python-format msgid "Failed to load user information: %s" msgstr "Das Laden der Benutzerinformationen schlug fehl: %s" -#: umc/python/distribution/__init__.py:557 +#: umc/python/distribution/__init__.py:584 msgid "Only the owner himself or an administrator may delete a project." msgstr "" "Nur der Eigentümer selbst oder ein Administrator können ein Projekt löschen." -#: umc/python/distribution/__init__.py:426 +#: umc/python/distribution/__init__.py:453 msgid "Only the owner himself or an administrator may distribute a project." msgstr "" "Nur der Eigentümer selbst oder ein Administrator können ein Projekt " "austeilen." -#: umc/python/distribution/__init__.py:421 -#: umc/python/distribution/__init__.py:473 -#: umc/python/distribution/__init__.py:520 +#: umc/python/distribution/__init__.py:448 +#: umc/python/distribution/__init__.py:500 +#: umc/python/distribution/__init__.py:547 #, python-format msgid "Project \"%s\" could not be loaded" msgstr "Das Projekt \"%s\" konnte nicht geladen werden" -#: umc/python/distribution/__init__.py:215 +#: umc/python/distribution/__init__.py:242 msgid "Project collection" msgstr "Projekteinsammlung" -#: umc/python/distribution/__init__.py:365 +#: umc/python/distribution/__init__.py:392 msgid "" "Project details are only visible to the project owner himself or an " "administrator." @@ -74,11 +74,11 @@ "Projekteigenschaften sind nur sichtbar für den Eigentümer selbst oder einen " "Administrator." -#: umc/python/distribution/__init__.py:215 +#: umc/python/distribution/__init__.py:242 msgid "Project distribution" msgstr "Projektverteilung" -#: umc/python/distribution/__init__.py:486 +#: umc/python/distribution/__init__.py:513 #, python-format msgid "The following user directories could not been collected: %s" msgstr "" @@ -92,12 +92,12 @@ msgid "The given project directory name must be non-empty." msgstr "Das angegebene Projektverzeichnis darf nicht leer sein." -#: umc/python/distribution/__init__.py:212 +#: umc/python/distribution/__init__.py:239 msgid "The project can only be modified by the owner himself" msgstr "Ein Projekt kann nur durch den Eigentümer selbst bearbeitet werden" -#: umc/python/distribution/__init__.py:290 -#: umc/python/distribution/__init__.py:436 +#: umc/python/distribution/__init__.py:317 +#: umc/python/distribution/__init__.py:463 #, python-format msgid "The project could not distributed to the following users: %s" msgstr "" @@ -131,19 +131,19 @@ msgstr "" "Das angegebene Projektverzeichnis muss verschieden sein von \".\" and \"..\"." -#: umc/python/distribution/__init__.py:257 +#: umc/python/distribution/__init__.py:284 #, python-format msgid "" "The specified project directory name \"%s\" is already in use by a different " "project." msgstr "Das angegebene Projektverzeichnis \"%s\" wird bereits verwendet." -#: umc/python/distribution/__init__.py:201 +#: umc/python/distribution/__init__.py:228 #, python-format msgid "The specified project does not exist: %s" msgstr "Das angegebene Projekt existiert nicht: %s" -#: umc/python/distribution/__init__.py:230 +#: umc/python/distribution/__init__.py:257 #, python-format msgid "The specified time needs to lie in the future for: %s" msgstr "Die angegebene Zeit muss in der Zukunft liegen: %s" --- ucs-school-umc-distribution/umc/python/distribution/__init__.py (Revision 59808) +++ ucs-school-umc-distribution/umc/python/distribution/__init__.py (Arbeitskopie) @@ -72,22 +72,26 @@ @file_upload def upload(self, request): # make sure that we got a list + MODULE.info('### upload: %r' % (request, )) + MODULE.info('### upload options: %r' % (request.options, )) if not isinstance(request.options, (tuple, list)): raise UMC_OptionTypeError( 'Expected list of dicts, but got: %s' % str(request.options) ) - file = request.options[0] - if not ('tmpfile' in file and 'filename' in file): - raise UMC_OptionTypeError( 'Invalid upload data, got: %s' % str(file) ) - # create a temporary upload directory, if it does not already exist - if not self._tmpDir: - self._tmpDir = tempfile.mkdtemp(prefix='ucsschool-distribution-upload-') - MODULE.info('Created temporary directory: %s' % self._tmpDir) + #file = request.options[0] + for file in request.options: + if not ('tmpfile' in file and 'filename' in file): + raise UMC_OptionTypeError( 'Invalid upload data, got: %s' % str(file) ) - filename = self.__workaround_filename_bug(file) - destPath = os.path.join(self._tmpDir, filename) - MODULE.info('Received file %r, saving it to %r' % (file['tmpfile'], destPath)) - shutil.move(file['tmpfile'], destPath) + # create a temporary upload directory, if it does not already exist + if not self._tmpDir: + self._tmpDir = tempfile.mkdtemp(prefix='ucsschool-distribution-upload-') + MODULE.info('Created temporary directory: %s' % self._tmpDir) + filename = self.__workaround_filename_bug(file) + destPath = os.path.join(self._tmpDir, filename) + MODULE.info('Received file %r, saving it to %r' % (file['tmpfile'], destPath)) + shutil.move(file['tmpfile'], destPath) + # done self.finished( request.id, None ) @@ -135,6 +139,7 @@ if request.options.get('project'): project = util.Project.load(request.options.get('project')) + result = [] for ifile in request.options.get('filenames'): ifile = ifile.encode('UTF-8') @@ -148,9 +153,7 @@ if project: iresult['projectDuplicate'] = ifile in project.files iresult['distributed'] = ifile in project.files and not os.path.exists(os.path.join(project.cachedir, ifile)) - result.append(iresult) - # done :) self.finished( request.id, result )