Skip to content
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

Closed
wants to merge 8 commits into from

Conversation

DylannCordel
Copy link
Contributor

  • 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)
Copy link
Member

@danmichaelo danmichaelo left a 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:

mwclient/mwclient/client.py

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
"""
(An example isn't always needed though!)

mwclient/errors.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
* 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
DylannCordel added a commit to webu/mwclient that referenced this pull request Nov 19, 2019
DylannCordel added a commit to webu/mwclient that referenced this pull request Nov 20, 2019
DylannCordel added a commit to webu/mwclient that referenced this pull request Nov 20, 2019
@DylannCordel
Copy link
Contributor Author

Thanks for the review @danmichaelo

Requested changes are done and I also enhance coverage of new lines of code.

Copy link
Member

@danmichaelo danmichaelo left a 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!

mwclient/client.py Outdated Show resolved Hide resolved
mwclient/errors.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
Copy link
Member

@danmichaelo danmichaelo left a 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.

mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
mwclient/client.py Outdated Show resolved Hide resolved
@DylannCordel
Copy link
Contributor Author

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 ?

@waldyrious
Copy link
Member

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:

"Allow edits from maintainers" checkbox screenshot

Don't you see anything there?

@DylannCordel
Copy link
Contributor Author

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:

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.

@waldyrious
Copy link
Member

waldyrious commented Sep 23, 2021

Maybe it's because the repo is inside our organization namespace instead my personal namespace.

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.

DylannCordel added a commit to DylannCordel/mwclient that referenced this pull request Jul 5, 2023
* 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
DylannCordel added a commit to DylannCordel/mwclient that referenced this pull request Jul 5, 2023
@DylannCordel
Copy link
Contributor Author

move to #299 to allow edits by maintainers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants