-
Notifications
You must be signed in to change notification settings - Fork 118
Issue #496 - Fix for search bug of Plans on the "My Dashboard". #3000
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
Issue #496 - Fix for search bug of Plans on the "My Dashboard". #3000
Conversation
|
A bug i found that I can't work out the reason why it occurs. Full details here |
|
I may be being slow here but I can't see what either condition is doing. The "where(Role.creator_condition)" means only select plans that have a creator? The "where(roles: {active: true})" means select plans that have at least one active role? is this really an surrogate for "select only plans that are active" but in a roundabout way? What would be wrong with just removing the where clause? Presumably something or it wouldn't be there. |
|
It is really confusing. When a user clicks the 'Remove' link to get rid of a plan from their 'My Dashboard' page, the plan doesn't actually get deleted. So it really just sets For whatever reason, that If the plan has no active roles though then everyone has said they don't want to see it, so should it be considered 'deleted'? I'm not sure. There are paginable Plan tables (with search functionality) in the following places:
Perhaps what we want here is to remove that # Controller code
results = Plan.search(params[:search_term])
.where(Role.creator_condition)We would need to do the same in all of those places listed above though. |
94e0301 to
75d6704
Compare
|
@raycarrick-ed @briri based on your comments I have updated code with changes
Further, I don't think I have make any changes here for this comment by @briri
|
Changes:
- In the search scope in the Plan model the clause
where(Role.creator_condition)
has been removed.
- Paginable::PlansController method org_admin_other_user the paginable_renderiseblock has
scope: Plan.active(@user)
replaced by
scope: Plan.active(@user).where(Role.creator_condition).
-In PublicPagesController method plan_index
@plans = Plan.publicly_visible.includes(:template)
has been replaced by
@plans = Plan.where(Role.creator_condition).publicly_visible.includes(:template).
75d6704 to
861af32
Compare
|
can we discuss this @magdalenadrafiova @mariapraetzellis @pherterich in the Wednesday call? We need to determine agree upon what each Plans table should show |
|
We discussed this in our team meeting. @johnpinto1 My Dashboard - shows Plans the current user's currently has an 'active' role on (creator, co-owner, editor, commenter)
My Dashboard - shows the organisationally visible plans for the current user Admin -> Plans - shows all of the plans owned/co-owned by one of the Org's users
Admin -> Users - shows the Plans for the user being edited (not sure if these are creator or would show if the user is just an editor or commenter)
Public Plans - shows any Plan marked as publicly_visible
We'd have to look at the API v0 and v1 to see if they use that search method (I think v0 might)
|
|
Explanatory comment on the roadmap instance settings. In general, org admins should be able to see all plans connected to users in their org and super admins should be able to see all plans in the roadmap instance. There is a special case, where org admins and super admins should not be allowed to see plans marked private or test. These two special cases are keyed of the org_admin_read_all and super_admin_read_all settings in the instance config (_dmproadmap.rb). If set to true, then the default case happens i.e. they get to see plans that are private or test. At present, these two settings will be the same (i.e. both true or both false) but they don't have to be e.g. you could envisage a policy that says org admins should not be able to see private plans but super admins should. So they need to be independent. This needs to be taken into account wherever we show plans to org_admin or superadmin. |
|
The way we manage which plans are available within the APIs may be of interest. The Pundit Policies define a 'Scope' that reviews the current user's permissions and their affiliation. Adding a similar scope method to the Here's an example of it being used in the controller:
|
|
@briri @raycarrick-ed DO NOT MERGE STILL IN PROGRESS. AS REQUIREMENTS EXPANDED AND CHANGED. KEEPING OPEN FOR THE CHANGES REQUESTED. |
|
CLOSING - All comments linked to https://github.com/DigitalCurationCentre/DMPonline-Service/issues/496 |
Changes:
In the search scope in the Plan model the clause
where(Role.creator_condition)
has been removed.
Paginable::PlansController method org_admin_other_user the paginable_renderiseblock has
scope: Plan.active(@user)
replaced by
scope: Plan.active(@user).where(Role.creator_condition).
In PublicPagesController method plan_index
@plans = Plan.publicly_visible.includes(:template)
has been replaced by
@plans = Plan.where(Role.creator_condition).publicly_visible.includes(:template).