This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
add --no-admin flag to registration script #3836
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ceec6ce
add --regular-user flag to registration script
bwindels 4311f86
fix PR review
bwindels d4c389f
remove not as the flags is set to false
bwindels 81b56f8
make clear in help text when will be prompted
bwindels 77f1de1
Merge branch 'develop' into bwindels/registerasregularuser
bwindels bd37c4a
fix logic, store_true/false doesn't set None by default but opposite …
bwindels 48957d2
didnt mean to commit this, obviously
bwindels a776ccd
add changelog
bwindels c5e1de6
Merge branch 'develop' into bwindels/registerasregularuser
bwindels File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,7 +133,7 @@ def register_new_user(user, password, server_location, shared_secret, admin): | |
print "Passwords do not match" | ||
sys.exit(1) | ||
|
||
if not admin: | ||
if admin is None: | ||
admin = raw_input("Make admin [no]: ") | ||
if admin in ("y", "yes", "true"): | ||
admin = True | ||
|
@@ -163,7 +163,12 @@ if __name__ == "__main__": | |
parser.add_argument( | ||
"-a", "--admin", | ||
action="store_true", | ||
help="Register new user as an admin. Will prompt if omitted.", | ||
help="Register new user as an admin. Will prompt if --regular-user is not set.", | ||
) | ||
parser.add_argument( | ||
"--regular-user", | ||
action="store_true", | ||
help="Register new user as a regular user.", | ||
) | ||
|
||
group = parser.add_mutually_exclusive_group(required=True) | ||
|
@@ -197,4 +202,10 @@ if __name__ == "__main__": | |
else: | ||
secret = args.shared_secret | ||
|
||
register_new_user(args.user, args.password, args.server_url, secret, args.admin) | ||
if args.admin and args.regular_user: | ||
print "Both --admin and --regular-user are set, choose either." | ||
sys.exit(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than doing this manually, we should probably use the inbuilt argparse conflict functionality: https://docs.python.org/2/howto/argparse.html#conflicting-options |
||
|
||
admin = True if args.admin else False if args.regular_user else None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I honestly can't remember how multiple if statements like this work, can we write split it out into actual if statements please? (You can also write this as |
||
|
||
register_new_user(args.user, args.password, args.server_url, secret, admin) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Traditionally this would probably be called
--no-admin
, to make it clearer that its the opposite of--admin
.