Skip to content

Referenced in DCC Bug 698 - The School departments functionality broken. - #3155

Merged
briri merged 1 commit into
developmentfrom
dcc_bug_698_Org_schools_departments_broken
Apr 13, 2022
Merged

Referenced in DCC Bug 698 - The School departments functionality broken.#3155
briri merged 1 commit into
developmentfrom
dcc_bug_698_Org_schools_departments_broken

Conversation

@johnpinto1

@johnpinto1 johnpinto1 commented Apr 13, 2022

Copy link
Copy Markdown
Contributor

Referenced in a comment in DCC bug 698 https://github.com/DigitalCurationCentre/DMPonline-Service/issues/698#issuecomment-1096577463

Fix involved following change:

  • in app/policies/department_policy the index?() policy method
    reference @department (which does not exist). Even changing @department
    to @record fails as @record is the Department class (not an instance of
    Department). Inspect of @record in index?() shows
    "Department(id: integer, name: string, code: string, org_id: integer,
    created_at: datetime, updated_at: datetime)".
    So replaced
    (@user.can_org_admin? && @user.org.id == @department.org_id) ||
    @user.can_super_admin?
    by @user.can_org_admin? || @user.can_super_admin?
    as @department is nil and @record.org_id id not defined for a Class
    object Department.

This fixes issue. But to see results you will need to change

The largest page size allowed in requests to the API (all versions)
config.x.application.api_max_page_size = 100

which I have done
config.x.application.api_max_page_size = 10

Selection_035

Selection_037

"View all" shows
Selection_036

Reverting back to with
config.x.application.api_max_page_size = 100
you see the same set of Departments for "View less" and "View all"
Selection_039
Selection_038

Referenced in a comment in DCC bug 698 https://github.com/DigitalCurationCentre/DMPonline-Service/issues/698#issuecomment-1096577463

Fix involved following change:
 - in app/policies/department_policy the index?() policy method
 reference @department (which does not exist). Even changing @department
to @record fails as @record is the Department class (not an instance of
Department). Inspect of @record in index?() shows
 "Department(id: integer, name: string, code: string, org_id: integer,
created_at: datetime, updated_at: datetime)".
So replaced
    (@user.can_org_admin? && @user.org.id == @department.org_id) ||
     @user.can_super_admin?
by    @user.can_org_admin? || @user.can_super_admin?
as @department is nil and @record.org_id id not defined for a Class
object Department.

@briri briri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense @johnpinto1. Thanks!

@briri
briri merged commit 67913a9 into development Apr 13, 2022
@briri
briri deleted the dcc_bug_698_Org_schools_departments_broken branch April 13, 2022 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants