replace old-school formatting in Filter.py with f-strings
[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
7 admin = {'first_name': "Default",
8          'last_name': "Administrator",
9          'email': plc['root_user'],
10          'password': plc['root_password']}
11
12 persons = GetPersons(the_admin_id)
13
14 if not persons:
15     # AddPerson won't let you pass a person_id
16     person_id = AddPerson(admin)
17     if person_id != the_admin_id:
18         # Huh? Someone deleted the account manually from the database.
19         DeletePerson(person_id)
20         raise Exception("Someone deleted the \"%s %s\" account from the database!" %
21                         (admin['first_name'], admin['last_name']))
22     UpdatePerson(person_id, {'enabled': True})
23 else:
24     person_id = persons[0]['person_id']
25     UpdatePerson(person_id, admin)