Added moderation, report and approval buttons for admins, uploaders and anonymous people

This commit is contained in:
Christoph Haas 2016-04-07 18:44:12 +02:00
parent 014a840493
commit 9bb9cf1f5d
5 changed files with 43 additions and 10 deletions

View file

@ -1,5 +1,5 @@
class PackagesController < ApplicationController
before_action :authenticate_user!, only: [:moderate]
before_action :authenticate_user!, only: [:moderate, :moderate_screenshot]
def list
@packages = query_packages
@ -96,6 +96,28 @@ class PackagesController < ApplicationController
@screenshot = Screenshot.find(params[:id])
@screenshot.description = params[:description]
@screenshot.save!
flash['notice'] = "Description updated."
redirect_to package_path
end
# Receive an anonymous report from a user to have a screenshot removed.
def report_screenshot
@screenshot = Screenshot.find(params[:id])
@screenshot.delete_reason = params[:delete_reason]
@screenshot.markedfordelete = true
@screenshot.save!
flash['notice'] = "Screenshot reported. The moderators will deal with it."
redirect_to package_path
end
# Publish a screenshot from the moderation queue
def approve_screenshot
@screenshot = Screenshot.find(params[:id])
@screenshot.delete_reason = nil
@screenshot.markedfordelete = false
@screenshot.approved = true
@screenshot.save!
flash['notice'] = "Screenshot approved."
redirect_to package_path
end