Skip to content

Commit

Permalink
add 3 day gip flag to whitelisting script itcgames/celiapp#179
Browse files Browse the repository at this point in the history
  • Loading branch information
kenpower committed Jun 25, 2021
1 parent 97fa1b5 commit f241b96
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ The `desqol-authentication` server requires Python 3 and MongoDB.
```sh
docker-compose build
docker-compose up

#if you need a shell
docker-compose run auth-server sh
```

The server is available on port 4000.
Expand Down Expand Up @@ -90,7 +93,14 @@ gamify flag of `false` and not using gip stick (both these flags default to tru
```sh
python run_whitelist.py add foo@bar.com --no-gamify --no-gip

If a user is gip testing every day:

python run_whitelist.py add baz@bar.com --gamify --gip

If a user is gip testing 3 days week:

python run_whitelist.py add baz@bar.com --gamify --gip3days

```

To list the users on the whitelist:
Expand Down
16 changes: 11 additions & 5 deletions run_whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_user(db, email):


@coroutine
def insert_user(db, email, gamify, using_gip):
def insert_user(db, email, gamify, using_gip, gip3days):
if not isinstance(email, str):
click.echo('The email address is not valid!')
return
Expand All @@ -25,12 +25,16 @@ def insert_user(db, email, gamify, using_gip):
if not isinstance(using_gip, bool):
click.echo('The usingGIP flag is not valid!')
return
if not isinstance(gip3days, bool):
click.echo('The gip3days flag is not valid!')
return
user = yield get_user(db, email)
if user is None:
yield db.whitelist.insert_one({
'email': email,
'gamify': gamify,
'usingGIP': using_gip
'usingGIP': using_gip,
'gip3PerWeek': gip3days
})
click.echo('SUCCESS: ' + email + ' is whitelisted!')
else:
Expand All @@ -55,7 +59,8 @@ def get_users(db):
cur = db.whitelist.find({}, {
'email': 1,
'gamify': 1,
'usingGIP': 1
'usingGIP': 1,
'gip3PerWeek': 1
})
docs = yield cur.to_list(length=None)
print('There are ' + str(len(docs)) + ' users on the whitelist:')
Expand All @@ -72,9 +77,10 @@ def cli():
@click.argument('email')
@click.option('--gamify/--no-gamify', default=True)
@click.option('--gip/--no-gip', default=True)
def add(email, gamify, gip):
@click.option('--gip3days', default=False, is_flag=True)
def add(email, gamify, gip, gip3days):
db = MotorClient(**MONGODB_HOST)[MONGODB_DBNAME]
IOLoop.current().run_sync(lambda: insert_user(db, email.lower(), gamify, gip))
IOLoop.current().run_sync(lambda: insert_user(db, email.lower(), gamify, gip, gip3days))


@cli.command()
Expand Down

0 comments on commit f241b96

Please sign in to comment.