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

DEV: Scope guardian methods to the plugin and some cleanup #138

Merged
merged 4 commits into from
May 3, 2024

Conversation

nattsw
Copy link
Contributor

@nattsw nattsw commented May 3, 2024

While making some updates to the translator plugin, I found some generic guardian additions which could potentially cause conflicts. e.g. guardian.user_group_allowed? -> guardian.user_group_allow_translate?.

This PR

  • makes the guardian functions scoped to translate
  • for the two methods above(^), uses the available SiteSetting.group_map functions and user.in_any_groups functions
  • removes some shared examples 🙈 to make reading tests easier
  • moves old code to add_to_serializer

@nattsw nattsw force-pushed the rename-guardian-translator branch from 5074274 to 2322249 Compare May 3, 2024 04:12
@nattsw nattsw changed the title DEV: Scope guardian methods to the plugin DEV: Scope guardian methods to the plugin and some cleanup May 3, 2024
Copy link
Contributor

@martin-brennan martin-brennan left a comment

Choose a reason for hiding this comment

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

Approving but just asking a few clarifying questions

lib/discourse_translator/guardian_extension.rb Outdated Show resolved Hide resolved
lib/discourse_translator/guardian_extension.rb Outdated Show resolved Hide resolved
)
return false
end
add_to_serializer :post, :can_translate do
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to add a include_condition here too to just check SiteSetting.translator_enabled

Copy link
Contributor Author

@nattsw nattsw May 3, 2024

Choose a reason for hiding this comment

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

From /t/92657 if we don't include define_include_method=false we won't need to check if the plugin is enabled since by default respect_plugin_enabled is true.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh okay cool, good to know 👍

@nattsw nattsw force-pushed the rename-guardian-translator branch from dd8f0f3 to 7e89003 Compare May 3, 2024 05:12
@nattsw nattsw merged commit dc410ed into main May 3, 2024
3 checks passed
@nattsw nattsw deleted the rename-guardian-translator branch May 3, 2024 06:07
@nattsw
Copy link
Contributor Author

nattsw commented May 3, 2024

Thank you @martin-brennan

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