-
Notifications
You must be signed in to change notification settings - Fork 33
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
TAN-852 - Permissions service refactor #7844
Conversation
@@ -48,7 +48,7 @@ def index_mini | |||
).find_records | |||
ideas = paginate SortByParamsService.new.sort_ideas(ideas, params, current_user) | |||
|
|||
render json: linked_json(ideas, WebApi::V1::IdeaMiniSerializer, params: jsonapi_serializer_params(pcs: ParticipationPermissionsService.new)) |
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.
Moved the permissions service entirely as the mini serializer doesn't use it
include: include | ||
} | ||
else | ||
{ | ||
params: jsonapi_serializer_params(pcs: ParticipationPermissionsService.new), | ||
params: jsonapi_serializer_params(pcs: IdeaPermissionsService.new), |
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.
Not clear if there is any benefit in passing the service in as a param, but have left it for now
|
…vice and broke link with parent
# Conflicts: # back/app/services/registration_requirements_service.rb # back/spec/services/registration_requirements_service_spec.rb
back/spec/rails_helper.rb
Outdated
@@ -94,3 +94,18 @@ | |||
end | |||
|
|||
ActiveJob::Base.queue_adapter = :test | |||
|
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.
Hadn't meant to check this in yet - but this is a method I've added which I was going to use to help analyse where the performance blocks are within the permissions 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.
Should we delete it now?
@@ -272,7 +272,7 @@ def anonymous_not_allowed? | |||
|
|||
case @post_type | |||
when 'Idea' | |||
!ParticipationPermissionsService.new.get_current_phase(@comment.post.project).allow_anonymous_participation | |||
!TimelineService.new.current_phase_not_archived(@comment.post.project).allow_anonymous_participation |
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.
Moved this method from permissions into the timeline service where it belongs
|
||
module Permissions | ||
class PermissionsService | ||
USER_DENIED_REASONS = { |
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.
There was a mix of language between 'denied reason' and 'disabled reason'. Decided to go with 'denied' until the output of the action descriptor - where it changes to disabled as that's what the FE is expecting
A refactor from 2 services with too many methods and mixed focus:
PermissionsService
ParticipationPermissionsService
To 7 services - namespaced in
Permissions::
:PermissionsUpdateService
- Dedicated to updating permissionsUserRequirementsService
- Just the logic for return flexible registration requirementsBasePermissionsService
- 2 methodsdenied_reason_for_action
&action_descriptors
- all other classes then inherit and extend these methodsInitiativesPermissionsService
PhasePermissionsService
ProjectPermissionsService
IdeaPermissionsService
Action descriptors are now generated via a method on the PermissionsServices instead of directly in the serializer.
Further documentation can be found here - https://www.notion.so/citizenlab/Permissions-service-d0e193dc551949a3bdc60dd0c500d75d
Changelog
Technical