Remove intervention controller, route and policy
This commit is contained in:
@ -1,55 +0,0 @@
|
||||
class InterventionsController < ApplicationController
|
||||
include CommonBehavior
|
||||
|
||||
before_action :set_intervention, only: MEMBER_ACTIONS
|
||||
|
||||
def authorize!
|
||||
authorize(@intervention || @interventions)
|
||||
end
|
||||
private :authorize!
|
||||
|
||||
def create
|
||||
#@intervention = Intervention.new(intervention_params)
|
||||
#authorize!
|
||||
#create_and_respond(object: @intervention)
|
||||
end
|
||||
|
||||
def destroy
|
||||
destroy_and_respond(object: @intervention)
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def intervention_params
|
||||
params[:intervention].permit(:name) if params[:intervention].present?
|
||||
end
|
||||
private :intervention_params
|
||||
|
||||
def index
|
||||
@interventions = Intervention.all.paginate(page: params[:page])
|
||||
authorize!
|
||||
end
|
||||
|
||||
def new
|
||||
#@intervention = Intervention.new
|
||||
#authorize!
|
||||
end
|
||||
|
||||
def set_intervention
|
||||
@intervention = Intervention.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
private :set_intervention
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def update
|
||||
update_and_respond(object: @intervention, params: intervention_params)
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
end
|
@ -1,29 +0,0 @@
|
||||
class InterventionPolicy < AdminOrAuthorPolicy
|
||||
def batch_update?
|
||||
admin?
|
||||
end
|
||||
|
||||
def show?
|
||||
admin? || teacher?
|
||||
end
|
||||
|
||||
[:clone?, :destroy?, :edit?, :update?].each do |action|
|
||||
define_method(action) { admin? || author?}
|
||||
end
|
||||
|
||||
def reload?
|
||||
everyone
|
||||
end
|
||||
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
if @user.admin?
|
||||
@scope.all
|
||||
elsif @user.teacher?
|
||||
@scope.where('user_id = ? OR public = TRUE', @user.id)
|
||||
else
|
||||
@scope.none
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,6 +0,0 @@
|
||||
= form_for(@intervention) do |f|
|
||||
= render('shared/form_errors', object: @intervention)
|
||||
.form-group
|
||||
= f.label(:name)
|
||||
= f.text_field(:name, class: 'form-control', required: true)
|
||||
.actions = render('shared/submit_button', f: f, object: @intervention)
|
@ -1,15 +0,0 @@
|
||||
h1 = Intervention.model_name.human(count: 2)
|
||||
|
||||
.table-responsive
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th = t('activerecord.attributes.intervention.name')
|
||||
th = t('shared.actions')
|
||||
tbody
|
||||
- @interventions.each do |intervention|
|
||||
tr
|
||||
td = link_to_if policy(intervention).show?, intervention.name
|
||||
td = link_to(t('shared.show'), intervention) if policy(intervention).show?
|
||||
|
||||
= render('shared/pagination', collection: @interventions)
|
@ -1,4 +0,0 @@
|
||||
h1
|
||||
= @intervention.name
|
||||
|
||||
= row(label: 'intervention.name', value: @intervention.name)
|
@ -115,14 +115,6 @@ Rails.application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
resources :interventions do
|
||||
member do
|
||||
post :clone
|
||||
get :reload
|
||||
post :submit
|
||||
end
|
||||
end
|
||||
|
||||
resources :external_users, only: [:index, :show], concerns: :statistics do
|
||||
resources :exercises, concerns: :statistics
|
||||
member do
|
||||
|
Reference in New Issue
Block a user