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
Program manager permission #20803
Program manager permission #20803
Conversation
e144c2a
to
80e6424
Compare
0eb67c2
to
c22d638
Compare
03bd59d
to
9542b5d
Compare
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.
Offline discussion about changes to the workshop dashboard - please include those here as well
@@ -74,7 +74,7 @@ def assign_program_manager | |||
|
|||
# GET /regional_partners/:id/remove_program_manager | |||
def remove_program_manager | |||
@regional_partner.program_managers.delete(params[:program_manager_id]) | |||
@regional_partner.program_managers.destroy(params[:program_manager_id]) |
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.
Ick! Why were we deleting instead of destroying here any way?
@@ -17,4 +17,14 @@ class RegionalPartnerProgramManager < ActiveRecord::Base | |||
belongs_to :regional_partner | |||
|
|||
has_many :pd_workshops_organized, class_name: 'Pd::Workshop', through: :program_manager | |||
|
|||
after_create do | |||
program_manager.permission = 'program_manager' |
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.
Use the UserPremission::PROGRAM_MANAGER
constant
|
||
after_destroy do | ||
if program_manager.regional_partners.empty? | ||
program_manager.delete_permission 'program_manager' |
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.
Same here
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.
One test to augment, then this LGTM
@@ -16,6 +16,7 @@ describe("Permission class", () => { | |||
expect(permission.isWorkshopAdmin).to.be.true; |
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.
You should augment workshop_indexTest.js
as well
Add a
program_manager
permission that has the same abilities asworkshop_organizer
This PR creates the permission, and when a user becomes a program manager, they receive the permission. When their last
RegionalPartnerProgramManager
is destroyed, the permission is removed.This PR also updates the backend and one pegasus helper to check for
program_manager
everywhere we check forworkshop_organizer
.