X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=db-config.d%2F001-admin_user;h=b01039f18eac76787431f1864f2e3daae0a3b629;hb=bc7bd41556e1fd137acf4df415e5dc0f6d5e02c4;hp=879716453b15879150d91a1a44c01d3034aa37aa;hpb=5afb8089a48433612fb10bed3c609006882b9859;p=plcapi.git diff --git a/db-config.d/001-admin_user b/db-config.d/001-admin_user index 87971645..b01039f1 100644 --- a/db-config.d/001-admin_user +++ b/db-config.d/001-admin_user @@ -1,24 +1,25 @@ # -*-python-*- -# $Id$ -# $URL$ -#################### +#################### # Create/update the default administrator account (should be person_id 2). -admin = { 'person_id': 2, - 'first_name': "Default", - 'last_name': "Administrator", - 'email': plc['root_user'], - 'password': plc['root_password'] } -persons = GetPersons([admin['person_id']]) +the_admin_id = 2 + +admin = {'first_name': "Default", + 'last_name': "Administrator", + 'email': plc['root_user'], + 'password': plc['root_password']} + +persons = GetPersons(the_admin_id) + if not persons: + # AddPerson won't let you pass a person_id person_id = AddPerson(admin) - if person_id != admin['person_id']: + if person_id != the_admin_id: # Huh? Someone deleted the account manually from the database. DeletePerson(person_id) - raise Exception, "Someone deleted the \"%s %s\" account from the database!" % \ - (admin['first_name'], admin['last_name']) - UpdatePerson(person_id, { 'enabled': True }) + raise Exception("Someone deleted the \"%s %s\" account from the database!" % + (admin['first_name'], admin['last_name'])) + UpdatePerson(person_id, {'enabled': True}) else: person_id = persons[0]['person_id'] UpdatePerson(person_id, admin) -