Authorisation management using CanCanCan added

This commit is contained in:
Christoph Haas 2021-02-28 21:36:46 +01:00
parent 51be4a4777
commit 7a3b65fe50
24 changed files with 211 additions and 295 deletions

View file

@ -1,7 +1,13 @@
// Button that reveals a dropdown/modal for moderation/reporting
- if can?(:destroy, screenshot) || can?(:approve, screenshot)
.text
span.label.secondary
= status_text(screenshot)
.button-group.small.align-center
- if (screenshot_uploaded_by_current_user?(screenshot) || (current_user && current_user.is_admin?))
- if can?(:destroy, screenshot)
a.button.small.bordered.radius.alert[
href=delete_screenshot_path(screenshot.id)
onclick="return confirm('Really delete the screenshot?');"
@ -15,29 +21,15 @@
/ href='#'
/ ] #{fa_icon 'star'} Make primary
- if not screenshot.approved
- if current_user && current_user.is_admin?
- unless screenshot.approved
- if can?(:approve, screenshot)
a.button.small.success[
href=approve_screenshot_path(screenshot.id)
method='post'
] Approve
/ - elsif screenshot.markedfordelete
/ a.button.small.success[
/ href=approve_screenshot_path(screenshot.id)
/ method='post'
/ ] Keep
] #{fa_icon 'check'} Approve
/ Display additional information to admins
p Status: #{screenshot.adminstatus}
p Uploader IP=#{screenshot.uploaderip}
p Uploader Token=#{session[:token]}
p Uploaded #{screenshot.age} ago (#{screenshot.created_at})
/ TODO: Move reporting screenshots to an extra page with a form and captcha
/ - else
/ / Allow anonymous users to report inappropriate screenshots
/ = form_tag(report_screenshot_path(screenshot.id))
/ = text_area_tag 'delete_reason', nil, class: 'input-group-field', maxlength: 100, rows: 3, cols: 50
/ = submit_tag 'Request removal', class: 'button alert'
/ p Status: #{screenshot.adminstatus}
/ p Uploader IP=#{screenshot.uploaderip}
/ p Uploader Token=#{session[:token]}
/ p Uploaded #{time_ago_in_words(screenshot.created_at)} ago (#{screenshot.created_at})