Setting tag plcapi-5.4-2
[plcapi.git] / db-config.d / 001-admin_user
1 # -*-python-*-
2 #################### 
3 # Create/update the default administrator account (should be person_id 2).
4
5 the_admin_id=2
6 admin = { 'first_name': "Default",
7           'last_name': "Administrator",
8           'email': plc['root_user'],
9           'password': plc['root_password'] }
10 persons = GetPersons(the_admin_id)
11 if not persons:
12     # AddPerson won't let you pass a person_id
13     person_id = AddPerson(admin)
14     if person_id != the_admin_id:
15         # Huh? Someone deleted the account manually from the database.
16         DeletePerson(person_id)
17         raise Exception, "Someone deleted the \"%s %s\" account from the database!" % \
18               (admin['first_name'], admin['last_name'])
19     UpdatePerson(person_id, { 'enabled': True })
20 else:
21     person_id = persons[0]['person_id']
22     UpdatePerson(person_id, admin)
23