mirror of
https://github.com/Evolix/chexpire.git
synced 2024-05-03 17:25:09 +02:00
Removed obsolete CheckNotifications controller
This commit is contained in:
parent
cb57fee73c
commit
c2cd9f5786
|
@ -1,47 +0,0 @@
|
||||||
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
|
||||||
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
|
||||||
|
|
||||||
class CheckNotificationsController < ApplicationController
|
|
||||||
before_action :authenticate_user!
|
|
||||||
before_action :set_notification, except: [:create]
|
|
||||||
|
|
||||||
def create
|
|
||||||
check = Check.find(params[:check_id])
|
|
||||||
@notification = check.notifications.build(notification_params)
|
|
||||||
authorize @notification
|
|
||||||
|
|
||||||
if @notification.save
|
|
||||||
flash[:notice] = "Your notification has been saved."
|
|
||||||
redirect_to check_path
|
|
||||||
else
|
|
||||||
flash.now[:alert] = "An error occured."
|
|
||||||
render "checks/edit"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
@notification.destroy!
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.js
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_notification
|
|
||||||
# joins the check because policy use the check relation
|
|
||||||
@notification = Notification
|
|
||||||
.joins(:check)
|
|
||||||
.find_by!(id: params[:id], check_id: params[:check_id])
|
|
||||||
authorize @notification
|
|
||||||
end
|
|
||||||
|
|
||||||
def notification_params
|
|
||||||
params.require(:notification).permit(:channel, :recipient, :interval)
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_path
|
|
||||||
edit_check_path(check_id: params[:check_id])
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,3 +0,0 @@
|
||||||
<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
|
|
||||||
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
|
|
||||||
document.querySelector("[data-notification-id='<%= @notification.id %>']").remove();
|
|
|
@ -7,7 +7,6 @@ Rails.application.routes.draw do
|
||||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||||
|
|
||||||
resources :checks, except: [:show] do
|
resources :checks, except: [:show] do
|
||||||
resources :check_notifications, only: [:destroy]
|
|
||||||
collection do
|
collection do
|
||||||
post :supports, format: :json
|
post :supports, format: :json
|
||||||
end
|
end
|
||||||
|
@ -24,7 +23,6 @@ end
|
||||||
# == Route Map
|
# == Route Map
|
||||||
#
|
#
|
||||||
# Prefix Verb URI Pattern Controller#Action
|
# Prefix Verb URI Pattern Controller#Action
|
||||||
# check_check_notification DELETE /checks/:check_id/check_notifications/:id(.:format) check_notifications#destroy
|
|
||||||
# supports_checks POST /checks/supports(.:format) checks#supports
|
# supports_checks POST /checks/supports(.:format) checks#supports
|
||||||
# checks GET /checks(.:format) checks#index
|
# checks GET /checks(.:format) checks#index
|
||||||
# POST /checks(.:format) checks#create
|
# POST /checks(.:format) checks#create
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
|
||||||
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
|
||||||
|
|
||||||
require "test_helper"
|
|
||||||
|
|
||||||
class CheckNotificationsControllerTest < ActionDispatch::IntegrationTest
|
|
||||||
# test "the truth" do
|
|
||||||
# assert true
|
|
||||||
# end
|
|
||||||
end
|
|
Loading…
Reference in a new issue