-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add methods to manage users: #238
Conversation
DylannCordel
commented
Nov 13, 2019
- simple user creation
- block user
- unblock user
- get basic info about user
- get groups
- add groups
- remove groups
- set groups (get current ones and add/remove what is needed)
* simple user creation * block user * unblock user * get basic info about user * get groups * add groups * remove groups * set groups (get current ones and add/remove what is needed)
9725ac7
to
29307e7
Compare
29307e7
to
fa3dd5b
Compare
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.
Thanks, this is a very useful addition! And thanks for taking the time to add some tests! I've added a few comments so far. Also, while not strictly necessary, docstrings for the new methods would be very welcome. There's a long backlog of methods missing docstrings, but I'm trying to add docstrings to all new methods or methods that are updated. For a good docstring, see the email method:
Lines 482 to 503 in fa3dd5b
def email(self, user, text, subject, cc=False): | |
""" | |
Send email to a specified user on the wiki. | |
>>> try: | |
... site.email('SomeUser', 'Some message', 'Some subject') | |
... except mwclient.errors.NoSpecifiedEmail: | |
... print('User does not accept email, or has no email address.') | |
Args: | |
user (str): User name of the recipient | |
text (str): Body of the email | |
subject (str): Subject of the email | |
cc (bool): True to send a copy of the email to yourself (default is False) | |
Returns: | |
Dictionary of the JSON response | |
Raises: | |
NoSpecifiedEmail (mwclient.errors.NoSpecifiedEmail): User doesn't accept email | |
EmailError (mwclient.errors.EmailError): Other email errors | |
""" |
* adds docstring to newly added methods * rename `MwClientNotFound` to `UserNotFound` and creates new ones to get better debugging possibilities: * `NotFound` * `CreateError` * `UserCreateError` * rename `AVAILABLE_TOKENS_TYPES` to `AVAILABLE_TOKEN_TYPES` * remove FIXME prefix comment * raises ValueError instead of Exception when it's more relevant
a704a9f
to
23f8996
Compare
23f8996
to
8e40168
Compare
8e40168
to
44fb998
Compare
Thanks for the review @danmichaelo Requested changes are done and I also enhance coverage of new lines of code. |
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.
Thanks for updating the PR @DylannCordel ! Hope you can comment on the exceptions and update the args in the docstrings. Otherwise looks very good!
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.
Again, sorry it took so long to get back to this. Note: If you also tick "Allow edits from maintainers", I can tidy up any remaining parts myself if I discover a few issues after this round.
Hi @danmichaelo Requested changes have been applied. I have not the "Allow edits from maintainers" link on this PR. Maybe it's only when we create a new-one ? |
You should be able to see it as a checkbox in the sidebar of this PR, as shown in the screenshot from the page @danmichaelo linked to: Don't you see anything there? |
Not in this PR. On other projects, I have this checkbox (eg: IdentityPython/djangosaml2#292) but on this one I have not the checkbox. Maybe it's because the repo is inside our organization namespace instead my personal namespace. I looked into organization settings and repository settings to find an option to allow it but nothing seems to do the job. It seems to be an old known problem : https://github.community/t/how-can-we-enable-allow-edits-from-maintainers-by-default/2847 I'll fork into my personal account next time. |
Ah, that makes sense. Yeah, it should be it. Thanks for digging up that info! I've noticed it's also tracked in isaacs/github#1681. |
* adds docstring to newly added methods * rename `MwClientNotFound` to `UserNotFound` and creates new ones to get better debugging possibilities: * `NotFound` * `CreateError` * `UserCreateError` * rename `AVAILABLE_TOKENS_TYPES` to `AVAILABLE_TOKEN_TYPES` * remove FIXME prefix comment * raises ValueError instead of Exception when it's more relevant
move to #299 to allow edits by maintainers |