From e37bc5c7b1c35db650a25c364c55d1d0b2cd6a49 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Fri, 10 Mar 2017 03:57:43 +0200 Subject: [PATCH 1/4] #3: add a script to create default db users. --- image/bin/createusers.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 image/bin/createusers.py diff --git a/image/bin/createusers.py b/image/bin/createusers.py new file mode 100644 index 0000000..fb863d8 --- /dev/null +++ b/image/bin/createusers.py @@ -0,0 +1,30 @@ +""" +Create 3 users in the db: +* user: a regular user +* developer: a developer (triager) that signed the cla +* coordinator: a coordinator and committer that signed the cla + +Most of the fields are the same as the username. +The password for all the users is 'pass'. +""" + +import subprocess + +rdadmin = ['/home/tracker/bin/roundup-admin', '-i', '/opt/tracker/python-dev'] + +users = ['user', 'developer', 'coordinator'] +roles = [] + +for user in users: + roles.append(user.capitalize()) + r = ','.join(roles) + ic = 1 if user == 'coordinator' else 0 # only coord is committer + args = ('create user username={u} address={u}@bugs.python.org ' + 'password=pass realname={u} github={u} roles={r} ' + 'iscommitter={ic}'.format(u=user, r=r, ic=ic)) + if user in {'developer', 'coordinator'}: + args += ' contrib_form=1 contrib_form_date=2017-03-22.00:00:00' + + print('Creating user:', user) + print(' - user id:', end=' ', flush=True) + subprocess.run(rdadmin + args.split()) From c04f5bf57ce50330676ac8979d422bd308c6d8e0 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Fri, 10 Mar 2017 04:00:52 +0200 Subject: [PATCH 2/4] #3: init the db and create default users automatically. --- image/init.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/image/init.sh b/image/init.sh index 86922c1..4d5083d 100644 --- a/image/init.sh +++ b/image/init.sh @@ -10,6 +10,13 @@ function stop_all() { trap stop_all HUP INT QUIT KILL TERM + +# initialize the db (pwd: admin) and create users +sleep 5 # wait for PG to start... +/home/tracker/bin/roundup-admin -i /opt/tracker/python-dev init admin +python3 /home/tracker/bin/createusers.py + + if [ $# -eq 0 ]; then /bin/bash else From b53b67bb6dab94eaad2ba308213ce9c9ac1a1677 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Fri, 10 Mar 2017 04:42:36 +0200 Subject: [PATCH 3/4] #3: document automatic init and user creation in the README. --- README.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e4e870b..2f32f4f 100644 --- a/README.md +++ b/README.md @@ -53,28 +53,30 @@ Usage This will launch the container in interactive mode, and mount the dir with the clones to the container's `/opt/tracker`. -6. Create a new empty instance of `python-dev` using: - - ``` - rd-admin init - ``` - -7. Run it using: +6. Every time the container is run, the tracker is initialized and 3 + users are created. You can then run the tracker with: ``` rd-start ``` -8. Your local instance of bugs.python.org should be available under +7. Your local instance of bugs.python.org should be available at http://localhost:9999 + On top of the two default users (`admin` and `anonymous`), + 3 additional users are also available: + * `user`: a regular user + * `developer`: a developer (triager) that signed the cla + * `coordinator`: a coordinator and committer that signed the cla + + You can login as any of these 3 users using `pass` as password. Notes ----- * Every time you stop the container, all the users and issues you created will be deleted. -* Every time you start the container, you will need to run - `rd-admin init` again and reinitialize the tracker. +* Every time you start the container, the tracker is initialized + and the 3 users are created. * Once the container is running, you can start and stop the tracker with `rd-start` and `ctrl+c`. * When you register a new user, look in `python-dev/debugmail.txt`: From c7aabf9c67bf7e25515cd6dd5c007cb1b9f69da9 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Fri, 10 Mar 2017 23:13:23 +0200 Subject: [PATCH 4/4] #3: address review comments by adding comments to createusers.py. --- image/bin/createusers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/image/bin/createusers.py b/image/bin/createusers.py index fb863d8..15e7229 100644 --- a/image/bin/createusers.py +++ b/image/bin/createusers.py @@ -16,12 +16,15 @@ roles = [] for user in users: + # listing the role is not enough -- all lower-level roles + # must be added too (e.g. Coordinator,Developer,User) roles.append(user.capitalize()) r = ','.join(roles) ic = 1 if user == 'coordinator' else 0 # only coord is committer args = ('create user username={u} address={u}@bugs.python.org ' 'password=pass realname={u} github={u} roles={r} ' 'iscommitter={ic}'.format(u=user, r=r, ic=ic)) + # developer and coordinator signed the cla if user in {'developer', 'coordinator'}: args += ' contrib_form=1 contrib_form_date=2017-03-22.00:00:00'