Allow hiding and un-hiding of screenshot by moderators
This commit is contained in:
parent
f31502c333
commit
5d0e4a520e
6 changed files with 62 additions and 10 deletions
|
|
@ -176,6 +176,40 @@ class PackagesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def hide_screenshot
|
||||
# Is the user allowed to hide this screenshot?
|
||||
@screenshot = Screenshot.find(params[:id])
|
||||
|
||||
# Check if the user is allowed to change this screenshot
|
||||
# - Is this the user's own screenshot? (anonymous)
|
||||
if can? :hide, @screenshot
|
||||
auditlog "Screenshot #{@screenshot.id} hidden",
|
||||
package: @screenshot.package
|
||||
@screenshot.hide!
|
||||
flash['notice'] = "Screenshot hidden."
|
||||
redirect_back(fallback_location: package_path(name: @screenshot.package.name))
|
||||
else
|
||||
head :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
def unhide_screenshot
|
||||
# Is the user allowed to unhide this screenshot?
|
||||
@screenshot = Screenshot.find(params[:id])
|
||||
|
||||
# Check if the user is allowed to change this screenshot
|
||||
# - Is this the user's own screenshot? (anonymous)
|
||||
if can? :unhide, @screenshot
|
||||
auditlog "Screenshot #{@screenshot.id} un-hidden",
|
||||
package: @screenshot.package
|
||||
@screenshot.unhide!
|
||||
flash['notice'] = "Screenshot un-hidden."
|
||||
redirect_back(fallback_location: package_path(name: @screenshot.package.name))
|
||||
else
|
||||
head :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
def delete_screenshot
|
||||
# Is the user allowed to delete the screenshot?
|
||||
@screenshot = Screenshot.find(params[:id])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue