Skip to content

Allow helpers to edit their own nomination reason#1841

Merged
jchristgit merged 5 commits into
mainfrom
allow-helpers-to-edit-their-own-nomination-reason
Oct 4, 2021
Merged

Allow helpers to edit their own nomination reason#1841
jchristgit merged 5 commits into
mainfrom
allow-helpers-to-edit-their-own-nomination-reason

Conversation

@ChrisLovering
Copy link
Copy Markdown
Member

@ChrisLovering ChrisLovering commented Sep 21, 2021

Closes #1617

This change will allow helpers to run the edit reason command in the Talentpool cog.

To ensure that non-mod helpers can only edit their own reasons the interface for the reason command has been changed slightly.

If nominee_or_nomination_id is a member or user, then the command edits the currently active nomination for that person.
If it's an int, then use this to look up that nomination ID to edit.

If no nominator is specified, assume the invoker is editing their own nomination reason.
Otherwise, edit the reason from that specific nominator.

Raise a permission error if a non-mod staff member invokes this command on a
specific nomination ID, or with an nominator other than themselves.

@ChrisLovering ChrisLovering force-pushed the allow-helpers-to-edit-their-own-nomination-reason branch from a5badc8 to 3b57421 Compare September 21, 2021 21:54
@Xithrius Xithrius added a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) a: recruitment Related to recruitment: (talentpool) p: 2 - normal Normal Priority s: needs review Author is waiting for someone to review and approve t: feature New feature or request labels Sep 21, 2021
@ChrisLovering ChrisLovering force-pushed the allow-helpers-to-edit-their-own-nomination-reason branch from 3b57421 to 3adf7f9 Compare September 21, 2021 22:05
Comment thread bot/exts/recruitment/talentpool/_cog.py Outdated
Comment thread bot/exts/recruitment/talentpool/_cog.py Outdated
Comment thread bot/exts/recruitment/talentpool/_cog.py Outdated
jchristgit
jchristgit previously approved these changes Sep 22, 2021
Copy link
Copy Markdown
Contributor

@jchristgit jchristgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Yup. Yup. Yup. Yup.

Copy link
Copy Markdown
Member

@mbaruh mbaruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks good on the technical side, but I find the command structure confusing.

It's not clear to me semantically why the command group is the one which accepts the narrower option for a target. In other commands, when a group accepts arguments, it's the opposite - meaning, it accepts the wider definition of a certain argument (e.g infraction search).

While this is easier to write as code, technically speaking it's not much more problematic to replicate the same behavior by letting helpers invoke the edit reason subcommand and raising the appropriate error if another actor is specified. Or, to make the help embed more friendly to helpers, to do the opposite of what you did, and make the group take the wider definition of a target and let helpers use tp edit reason specifically. Still, in that case the functionality of the group command in this way will seem odd to me as the group includes editing end reasons as well.

Also, something that is missing is the ability to raise the help embed for the group. Currently, you make the target mandatory, which raises an error even when you would expect only the help embed to show up.

edit: Thinking about the comment below, I'm probably more in favor of the first approach of keeping the group without arguments, as in the second approach they will see the group taking arguments but not be able to use them?

@mbaruh
Copy link
Copy Markdown
Member

mbaruh commented Sep 22, 2021

Additionally, I'd argue we should allow the tp top command be invoked by helpers as well, so that they can see what command are available to them.

@ChrisLovering ChrisLovering force-pushed the allow-helpers-to-edit-their-own-nomination-reason branch 2 times, most recently from f27a1c6 to 2d1ddc6 Compare October 3, 2021 12:48
@ChrisLovering ChrisLovering dismissed jchristgit’s stale review October 3, 2021 12:48

Changed considerably since then.

@ChrisLovering ChrisLovering requested a review from mbaruh October 3, 2021 12:48
@ChrisLovering
Copy link
Copy Markdown
Member Author

ChrisLovering commented Oct 3, 2021

I have changed this back to one command, and change the interface slightly to allow for both helpers and mods to run the command, with validation being ran to ensure non-mod helpers can't edit other user's commands.

This also improves the interface for mods wanting to edit the reason for the own nomination of a user, by not needing them to look up the nomination ID.

ChrisLovering and others added 2 commits October 3, 2021 14:03
This change will allow helpers to run the edit reason command in the Talentpool cog.

To ensure that non-mod helpers can only edit their own reasons the interface for the reason command has been changed slightly.

If nominee_or_nomination_id is a member or user, then the command edits the currently active nomination for that person.
If it's an int, then use this to look up that nomination ID to edit.

If no nominator is specified, assume the invoker is editing their own nomination reason.
Otherwise, edit the reason from that specific nominator.

Raise a permission error if a non-mod staff member invokes this command on a
specific nomination ID, or with an nominator other than themselves.
Co-authored-by: Bluenix <bluenixdev@gmail.com>
@ChrisLovering ChrisLovering force-pushed the allow-helpers-to-edit-their-own-nomination-reason branch from 2d1ddc6 to 77f76cb Compare October 3, 2021 13:03
Copy link
Copy Markdown
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could limit this command to only be run in the nominations channel by helpers, although not really important. This all seems to work well 👍

Comment thread bot/exts/recruitment/talentpool/_cog.py Outdated
await ctx.send(f":x: Maxiumum allowed characters for the reason is {REASON_MAX_CHARS}.")
await ctx.send(f":x: Maximum allowed characters for the reason is {REASON_MAX_CHARS}.")
return
if isinstance(target, Member):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command can resolve to a user. What happens if you try to nominate someone off-server?

Copy link
Copy Markdown
Member Author

@ChrisLovering ChrisLovering Oct 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll just work with the code below, so I'll swap this around and have it check isinstance of int and then an else to catch Member & User

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By swapping the isinstance to check for int, the else block now catches the case where target is Member or User, this allows for editting the nomination reason of members that are off server.
Copy link
Copy Markdown
Member

@mbaruh mbaruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it makes sense to nominate someone outside the server at all, but that's out of scope for this PR. Looks good otherwise 👍

@jchristgit jchristgit merged commit 8d4d742 into main Oct 4, 2021
@jchristgit jchristgit deleted the allow-helpers-to-edit-their-own-nomination-reason branch October 4, 2021 05:29
@Xithrius Xithrius removed the s: needs review Author is waiting for someone to review and approve label Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) a: recruitment Related to recruitment: (talentpool) p: 2 - normal Normal Priority t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow helpers to update nomination reasons

6 participants