-
-
Save Killavus/c2d304c7737711397daa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Threats::SubscriptionsController < ApplicationController | |
def show | |
if current_user.role.analyst? | |
view_data = service.view_data(params[:threat_id]) | |
render locals: {threat: view_data.threat, categories: view_data.categories} | |
else | |
redirect_to root_path, alert: 'You are not allowed to access this page.' | |
end | |
end | |
def update | |
if current_user.role.analyst? | |
respond_with service.(params[:threat_id], params[:threat]), location: threats_path, notice: "Threat subscriptions were updated successfully." | |
else | |
redirect_to root_path, alert: 'You are not allowed to access this page.' | |
end | |
end | |
private | |
def service | |
SubscribeThreatToServiceArea.new(Threat, ServiceArea) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment