diff --git a/app/models/guidance.rb b/app/models/guidance.rb index 5c096e7..287a49a 100644 --- a/app/models/guidance.rb +++ b/app/models/guidance.rb @@ -73,7 +73,7 @@ ## # Returns whether or not a given user can view a given guidance # we define guidances viewable to a user by those owned by a guidance group: - # owned by the DCC + # owned by the managing curation center # owned by a funder organisation # owned by an organisation, of which the user is a member # @@ -95,7 +95,7 @@ end end - # guidance groups are viewable if they are owned by the DCC + # guidance groups are viewable if they are owned by the Managing Curation Center if guidance_group.organisation.id == Organisation.find_by( name: GlobalHelpers.constant("organisation_types.managing_organisation")).id viewable = true end @@ -112,14 +112,14 @@ ## # Returns a list of all guidances which a specified user can view # we define guidances viewable to a user by those owned by a guidance group: - # owned by the DCC + # owned by the Managing Curation Center # owned by a funder organisation # owned by an organisation, of which the user is a member # # @param user [User] a user object # @return [Array] a list of all "viewable" guidances to a user def self.all_viewable(user) - dcc_groups = (Organisation.find_by name: GlobalHelpers.constant("organisation_types.managing_organisation")).guidance_groups + managing_groups = (Organisation.find_by name: GlobalHelpers.constant("organisation_types.managing_organisation")).guidance_groups # find all groups owned by a Funder organisation funder_groups = [] funders = OrganisationType.find_by( name: GlobalHelpers.constant("organisation_types.funder")) @@ -133,7 +133,7 @@ end # find all guidances belonging to any of the viewable groups all_viewable_guidances = [] - all_viewable_groups = dcc_groups + funder_groups + organisation_groups + all_viewable_groups = managing_groups + funder_groups + organisation_groups all_viewable_groups.each do |group| all_viewable_guidances += group.guidances end diff --git a/app/models/guidance_group.rb b/app/models/guidance_group.rb index 3cb5240..201818c 100644 --- a/app/models/guidance_group.rb +++ b/app/models/guidance_group.rb @@ -54,7 +54,7 @@ ## # Returns whether or not a given user can view a given guidance group # we define guidances viewable to a user by those owned by: - # the DCC + # the managing curation center # a funder organisation # an organisation, of which the user is a member # @@ -71,9 +71,9 @@ viewable = true end end - # groups are viewable if they are owned by the DCC - Organisation.where( name: GlobalHelpers.constant("organisation_types.managing_organisation")).find_each do |dcc| - if guidance_group.organisation.id == dcc.id + # groups are viewable if they are owned by the managing curation center + Organisation.where( name: GlobalHelpers.constant("organisation_types.managing_organisation")).find_each do |managing_group| + if guidance_group.organisation.id == managing_group.id viewable = true end end @@ -88,17 +88,17 @@ ## # Returns a list of all guidance groups which a specified user can view # we define guidance groups viewable to a user by those owned by: - # the DCC + # the Managing Curation Center # a funder organisation # an organisation, of which the user is a member # # @param user [User] a user object # @return [Array] a list of all "viewable" guidance groups to a user def self.all_viewable(user) - # first find all groups owned by the DCC - dcc_groups = [] - Organisation.where( name: GlobalHelpers.constant("organisation_types.managing_organisation")).find_each do |dcc| - dcc_groups = dcc_groups + dcc.guidance_groups + # first find all groups owned by the Managing Curation Center + managing_org_groups = [] + Organisation.where( name: GlobalHelpers.constant("organisation_types.managing_organisation")).find_each do |managing_org| + managing_org_groups = managing_org_groups + managing_org.guidance_groups end # find all groups owned by a Funder organisation @@ -113,7 +113,7 @@ organisation_groups = organisation_groups + organisation.guidance_groups end # pass this list to the view with respond_with @all_viewable_groups - all_viewable_groups = dcc_groups + funder_groups + organisation_groups + all_viewable_groups = managing_org_groups + funder_groups + organisation_groups all_viewable_groups = all_viewable_groups.uniq{|x| x.id} return all_viewable_groups end