Univention Bugzilla – Bug 42416
[4.3] The user role should be configurable in the CSV file
Last modified: 2018-07-04 18:09:03 CEST
Currently the user role can only be defined in the CSV file if using the: ucsschool.importer.reader.test_csv_reader.TestCsvReader With a mapping of to a private property: "Benutzertyp": "__type", This should be easier!
I also vote for merging TestCsvReader into CsvReader in the product to officially support "__type" as part of "Sonderwerte" (http://docs.software-univention.de/ucsschool-import-handbuch-4.1R2.html#configuration:mapping), currently: "__action" and "__ignore". IMHO it is very likely that some customer will need this. With a distributed CSV-Import-module (-> more diverse input-sources) this becomes even more likely.
Please also write a ucs-test that tests with input * that is missing the column * for each of the 4 user types * with invalid input
The manual recommends not setting --user-role during an import if the role is set in the import data. Which doesn't really work, see above. http://docs.software-univention.de/ucsschool-import-handbuch-4.1R2.html#table:userimport_configuration
(In reply to Jürn Brodersen from comment #3) > The manual recommends not setting --user-role during an import if the role > is set in the import data. Which doesn't really work, see above. > > http://docs.software-univention.de/ucsschool-import-handbuch-4.1R2. > html#table:userimport_configuration I don't understand what isn't working, please clarify. But I see the gap in the documentation: It is missing a definition what happens if both is set: user-type in CSV _and_ --user-role.
(In reply to Daniel Tröder from comment #4) > (In reply to Jürn Brodersen from comment #3) > > The manual recommends not setting --user-role during an import if the role > > is set in the import data. Which doesn't really work, see above. > > > > http://docs.software-univention.de/ucsschool-import-handbuch-4.1R2. > > html#table:userimport_configuration > I don't understand what isn't working, please clarify. > > But I see the gap in the documentation: > It is missing a definition what happens if both is set: user-type in CSV > _and_ --user-role. Sorry, I meant that you can't set the user-type in CSV. E.g. the following mapping doesn't work: ''' "csv": { "mapping": { "Schulen": "schools", "Vorname": "firstname", "Nachname": "lastname", "Klassen": "school_classes", "Mailadresse": "email", "Telefon": "phone", "Beschreibung": "description", "Benutzertyp": "user_role" } } ''' If no --user-role is set: "ERROR cmdline.main:124 2: No role in configuration." and with --user-role set: "ERROR cmdline.main:124 2: Unknown UDM property: 'user_role'." The "__type" mapping in comment 1 doesn't seem to work with "ucs-school-user-import" neither.
New user role assignment can now be handled by the regular CSV reader class CsvReader. This allows the use of the special mapping value "__role". Allowed values in the CSV column are student, staff, teacher and teacher_and_staff. The use of the TestCsvReader class is no longer required. For backwards compatibility the class still exists and allows to use "__type". [4.3] a3d96076 Bug #42416: move handling of special mapping value for user role to regular CsvReader [4.3] 3ce6de59 Bug #42416: changelog [4.3] 6bf235c0 Bug #42416: adapt tests to use the new special mapping value in the regular CsvReader [4.3] ecdc15fa Bug #42416: changelog [4.3] b1ae0b2c Bug #42416: advisory ucs-school-import (16.0.1-29) ucs-test-ucsschool (5.0.2-50)
http://jenkins.knut.univention.de:8080/job/UCSschool-4.3/job/Handbook/2/artifact/webroot/ucsschool-import-handbuch-4.3.pdf
Created attachment 9574 [details] log with exception changelog OK Advisory OK Documentation OK Import with __role mapping OK Import wit __role and --user_role REOP When you import a csv with a __role mapping but also use the --user_role option the import crashes with a noObject exception if there is at least one row in the CSV that does not have the role specified in the command line parameter. This is because the created object got the role specified in the CSV but was expected to have the role specified in --user_role. The documentation states that the command line parameter should not be used if a __role attribute is present but the import should not just crash. In my opinion there should also be a clear rule for what option gets priority. I added the csv and the resulting log as attachements to the bug. The command used was: /usr/share/ucs-school-import/scripts/ucs-school-user-import --conffile /var/lib/ucs-school-import/configs/user_import.json --infile test.csv --school AE
Created attachment 9575 [details] the csv used to produce error
Created attachment 9576 [details] The mapping used during test
I forgot to add a remark about the documentation: In line 984 of ucsschool-import-handbuch-4.3.xml: Der Inhalt dieser Spalte wird ignoriert. Die kann z.B. verwendet werden, wenn die CSV-Datei leerer Spalten, oder solche mit nicht zu importierenden Daten, enthält. What does 'Die' refer to. The Sonderwerte from the beginning of the chapter? I guess it should be 'leere Spalten' This sentence is a bit hard to grasp in my opinion because of the "Die" and since it was already edited here it might be fixed here as well.
(In reply to Ole Schwiegert from comment #8) > Import wit __role and --user_role REOP > > When you import a csv with a __role mapping but also use the --user_role > option the import crashes with a noObject exception if there is at least one > row in the CSV that does not have the role specified in the command line > parameter. > > This is because the created object got the role specified in the CSV but was > expected to have the role specified in --user_role. The documentation states > that the command line parameter should not be used if a __role attribute is > present but the import should not just crash. > > In my opinion there should also be a clear rule for what option gets > priority. The documentation clearly states, that such a combination is not allowed: --------------------------------------------------------- user_role / -u / --user_role: Definiert die Benutzerrolle für alle Eingabedatensätze. Diese Variable sollte nur gesetzt werden, wenn die Benutzerrolle nicht in den Eingabedaten enthalten ist und die Eingabedatensätze homogen alle die gleiche Benutzerrolle verwenden sollen. --------------------------------------------------------- I have now additionally documented it in the section about "__role" and the import now also supports "none" on the cmdline for --user_role (to be able to overwrite a configuration file setting). It is now checked if both "user_role" and "__role" in config['csv']['mapping'] is used at the same time, and an InitialisationError is raised to prevent an import run with that combination. Prioritization is not allowed, as this is a contradictory configuration is most likely a user error. [4.3] c742d8c83 Bug #42416: prevent running forbidden configuration combination [4.3] 3e5aac541 Bug #42416: changelog [4.3] fbdde11fa Bug #42416: advisory update ucs-school-import (16.0.2-18)
changelog OK Advisory OK Documentation OK Import with __role mapping OK Import wit __role and --user_role OK
UCS@school 4.3 v4 has been released. https://docs.software-univention.de/changelog-ucsschool-4.3v4-de.html If this error occurs again, please clone this bug.