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

admin button to auto-gen & link Discord roles #746

Merged
merged 11 commits into from
Jan 10, 2024
Merged

Conversation

npinsker
Copy link
Collaborator

@npinsker npinsker commented Jan 9, 2024

image

addresses #671

  • Button on the sidebar that's visible to admins only
  • Clicking it will generate Discord roles for all tags that are blue or white
  • Also creates a ChatRole for all Discord roles, meaning people with those roles will get pinged when a puzzle's tagged with the corresponding tag

@npinsker npinsker marked this pull request as draft January 9, 2024 23:13
@rgossiaux
Copy link
Contributor

Why did you move this from the hunt edit page to the sidebar? I thought that made the most sense to me.

I also think it's unlikely we ever want to modify these during the hunt FWIW

@npinsker
Copy link
Collaborator Author

idk i felt like /edit was reserved for like hunt metadata whereas the sidebar felt more like a control panel. but i think you're right and i'll move it back.

i was expecting we'd want to add new tags to Discord as well, but it doesn't matter much

@npinsker npinsker marked this pull request as ready for review January 10, 2024 01:02
@npinsker npinsker marked this pull request as draft January 10, 2024 01:05
@npinsker npinsker marked this pull request as ready for review January 10, 2024 01:09
@npinsker
Copy link
Collaborator Author

moved back to /edit

@npinsker npinsker requested a review from rgossiaux January 10, 2024 02:47
chat/tasks.py Outdated
Comment on lines 190 to 191
if tag.color != PuzzleTagColor.BLUE and tag.color != PuzzleTagColor.WHITE:
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also check if it's a default tag

chat/tasks.py Outdated
if existing_chat_role.exists():
obj = existing_chat_role.first()
if obj.role_id != discord_roles_by_name[tag.name]["id"]:
with transaction.atomic():
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this actually do anything if we're just doing a single operation? ditto below

hunts/views.py Outdated
Comment on lines 158 to 161
chat.tasks.sync_roles(
hunt,
settings.CHAT_DEFAULT_SERVICE,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will run this synchronously by the web process, right? Need to call .delay() if you want to create a task

Copy link
Contributor

@rgossiaux rgossiaux left a comment

Choose a reason for hiding this comment

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

Lgtm, nice!

@npinsker npinsker merged commit 3b421be into main Jan 10, 2024
2 checks passed
@npinsker npinsker deleted the discord-autoupdate branch January 10, 2024 06:26
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.

2 participants