-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Classification user groups authorization policies (#27)
* individual stats breakdown per group. add session time to user group projects breakdown. * update sort of group member stats breakdown * Update user_group_member_stats_breakdown_serializer.rb * add specs user group classification count controller for individual stats breakdown stats * add specs for group member breakdown query stats * add spec for serializer * update session time to be included with top contributors * update staging credentials to include staging panoptes client credentials. add initial logic for queried user group context policy * add comment to show reference of where to find diff types of user group stats visibilities * show stats if panoptes admin * Update queried_user_group_context_policy.rb * update group admin check to check for group_admin * update user group controller specs * add queried user group context policy spec * Update user_group_classification_count_controller.rb * update validations to allow non logged in users to view publicly visible stats and update specs * fix accidental spacing issue * Update staging.yml.enc * Update spec/support/authentication_helpers.rb Co-authored-by: Zach Wolfenbarger <[email protected]> * Update authentication_helpers.rb --------- Co-authored-by: Zach Wolfenbarger <[email protected]>
- Loading branch information
1 parent
d0ec241
commit da72ace
Showing
8 changed files
with
735 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# frozen_string_literal: true | ||
|
||
class QueriedUserGroupContextPolicy < ApplicationPolicy | ||
attr_reader :user | ||
|
||
def initialize(user, _record) | ||
super | ||
@user = user | ||
end | ||
|
||
def show? | ||
return true if panoptes_admin? | ||
|
||
if individual_stats_breakdown_requested? | ||
show_ind_stats_breakdown? | ||
else | ||
show_group_aggregate_stats? | ||
end | ||
end | ||
|
||
def show_group_aggregate_stats? | ||
# For types of group stats visibilities see: https://github.com/zooniverse/eras/wiki/(Panoptes)-User-Groups-Stats-Visibilities | ||
|
||
case group_stats_visibility | ||
when 'public_show_all', 'public_agg_show_ind_if_member', 'public_agg_only' | ||
true | ||
when 'private_show_agg_and_ind', 'private_agg_only' | ||
group_member? | ||
else | ||
false | ||
end | ||
end | ||
|
||
def show_ind_stats_breakdown? | ||
case group_stats_visibility | ||
when 'public_show_all' | ||
true | ||
when 'public_agg_show_ind_if_member', 'private_show_agg_and_ind' | ||
group_member? | ||
when 'public_agg_only', 'private_agg_only' | ||
group_admin? | ||
else | ||
false | ||
end | ||
end | ||
|
||
def group_member? | ||
current_user_membership && !current_user_roles.empty? | ||
end | ||
|
||
def group_admin? | ||
group_member? && current_user_roles.include?('group_admin') | ||
end | ||
|
||
def current_user_roles | ||
current_user_membership['roles'] | ||
end | ||
|
||
def current_user_membership | ||
user['user_membership'] | ||
end | ||
|
||
def individual_stats_breakdown_requested? | ||
user['individual_stats_breakdown'] || false | ||
end | ||
|
||
def group_stats_visibility | ||
user['user_group_stats_visibility'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
DE7jRIWwMnbmRiQRJ0SmsOae9uRB5sniKrwXf7F8ZuvfmLeo16iJbHLX+QtRkTG3hsBdJtjYA1fek7cfsLi78ThSon8Ovzaw+opS6h+mMBOT2takrxtlD1kYDYjupHbsTt5zb3MJEzLYXy+8utpy2wOunq/e8jXg28i0asWONbevnd0ieq/E8aVpSmNLNPlE6b4JeQA0Gk+aa1gKVnNPK9ByqWxaXieDimNiBQa90rmO6hdpvIVcDl6FbbZC3+SqOTab5yOdkZudiRvrcHnDc4fdb03V/hvPbk0vXSoL0dr1SsLlCjTgzkciU56NzJ75z7k9pd8GJ5qQnmJnNIgtOjJyK85t8jcVOhqARI3UihE6QXXbHS5BmhB2ssJ7gi031qpLtM6Iax60zhg9TgWU8mothUE3/b8IONQgEGnLwnnF5KoW4QXkQe50vM+ar0Os6bWEh4adfmjX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6Wv58g== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.