-
-
Notifications
You must be signed in to change notification settings - Fork 198
Edit and Delete Member notes #2208
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
base: master
Are you sure you want to change the base?
Changes from all commits
bad8c03
cee823c
7d3ddd8
7647f90
6449fc9
c7c1e4d
9547e1e
7f5d510
f0465f0
86520a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,13 @@ class MemberNotePolicy < ApplicationPolicy | |
def create? | ||
user && (user.has_role?(:admin) || user.roles.where(resource_type: 'Chapter').any?) | ||
end | ||
|
||
def destroy? | ||
puts "Chapters: #{record.member.chapters.inspect}" | ||
user && (user.has_role?(:admin) || user == record.author || record.member.chapters.any? { |chapter| user.has_role?(:organiser, chapter) }) | ||
end | ||
|
||
def update? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jazzygasper just one quick question. Is the intention here to allow admins and organisers to update the note of another admin/organiser? In that case this won't work for organisers, only admins. See line 3 above in the create? method. We need to check for the admin and organiser roles to allow for that. If the intention was to allow admins to update anyone's notes but organisers to only update their own notes, this is fine. Just wanted to clarify before I approved. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @matyikriszta Yeah my original idea was for admins to update anyone’s notes, and organisers only their own. But I'm happy to change it so any organiser can update any note, or restrict it to organisers updating notes from their own chapter. What do you think is best? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jazzygasper I think we should go with the second option, e.g. organisers updating notes from their own chapter. I think this might be useful in the case if an organiser leaves but a note they left needs to be updated. Other organisers from the same chapter should be able to do this without having to ping an admin. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jazzygasper are you okay to make the suggested changes? |
||
user && (user.has_role?(:admin) || user == record.author || record.member.chapters.any? { |chapter| user.has_role?(:organiser, chapter) }) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
.row.d-flex.align-items-start.note | ||
.col-2.col-md-1 | ||
%span.fa-stack.text-primary | ||
%i.fas.fa-circle.fa-stack-2x | ||
%i.fas.fa-pencil-alt.fa-stack-1x.fa-inverse | ||
= link_to '#', class: "btn btn-sm p-0 me-2", turbo: false, 'data-bs-toggle': 'modal', 'data-bs-target': "#edit-note-modal-#{action.id}" do | ||
%span.fa-stack.text-primary | ||
%i.fas.fa-circle.fa-stack-2x | ||
%i.fas.fa-pencil-alt.fa-stack-1x.fa-inverse | ||
.col-9.col-md-11 | ||
%strong Note added by #{link_to(action.author.full_name, admin_member_path(action.author))} | ||
%blockquote.blockquote.mb-0=action.note | ||
.date | ||
.d-flex.align-items-center.justify-content-between | ||
= l(action.created_at, format: :website_format) | ||
= link_to admin_member_note_path(action), method: :delete, data: { confirm: "Are you sure you want to delete this note?" }, class: "btn btn-sm btn-outline-danger" do | ||
%i.fas.fa-trash | ||
= render partial: 'note', locals: { note: action, member: @member } |
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.
@jazzygasper can we remove the puts statement please?