Bug 45163 - [4.3] create custom django-admin command to seed School objects and check for superuser
[4.3] create custom django-admin command to seed School objects and check for...
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: HTTP-API (Kelvin)
UCS@school 4.2
Other Linux
: P5 normal (vote)
: UCS@school 4.3 v4
Assigned To: Daniel Tröder
Ole Schwiegert
:
Depends on:
Blocks: 45019 47181
  Show dependency treegraph
 
Reported: 2017-08-08 16:57 CEST by Daniel Tröder
Modified: 2018-07-04 18:09 CEST (History)
0 users

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2017-08-08 16:57:24 CEST
Instead of running in join script:

echo "..." | ... manage.py shell
Comment 1 Daniel Tröder univentionstaff 2018-03-13 08:53:56 CET
Writing custom django-admin commands: https://docs.djangoproject.com/en/1.10/howto/custom-management-commands/
Comment 2 Daniel Tröder univentionstaff 2018-06-12 11:29:13 CEST
Custom django-admin commands were created to improve the join script reliability.

--------------------------------------------------------------------
/usr/share/pyshared/ucsschool/http_api/manage.py --help
[..]

[import_api]
    superuserexists
    updateschools

/usr/share/pyshared/ucsschool/http_api/manage.py superuserexists --help
/usr/share/pyshared/ucsschool/http_api/manage.py updateschools --help

--------------------------------------------------------------------
# manage.py superuserexists xyz
CommandError: User 'xyz' does not exist or is not a superuser.
# echo $?
1
# manage.py superuserexists Administrator
# echo $?
0
--------------------------------------------------------------------
# manage.py updateschools --ou xyz
CommandError: Unknown school 'xyz'.
# echo $?
1
# manage.py updateschools --ou SchuleEins
Known schools now: 2576, SchuleEins, test2, test3, test4, test5, test6, test7, tx71qen12zw, wzs4y1txdfm.
# echo $?
0
# manage.py updateschools --all
Known schools now: 2576, SchuleEins, test2, test3, test4, test5, test6, test7, tx71qen12zw, wzs4y1txdfm.
# echo $?
0
--------------------------------------------------------------------


[4.3] 5bb9e5d0 Bug #45163: create custom django-admin commands
[4.3] 7c93d8da Bug #45163: changelog
[4.3] f32db1a1 Bug #45163: advisory

ucs-school-import (16.0.2-10)
Comment 3 Ole Schwiegert univentionstaff 2018-06-12 12:01:19 CEST
Tested with 16.0.2-10A~4.3.0.201806121117

package installs OK
new commands where executed and worked OK
advisory OK
changelog OK
Comment 4 Sönke Schwardt-Krummrich univentionstaff 2018-07-04 18:09:02 CEST
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.