Remove attr_accessible from Program and Cfp, final fixes after introducing strong params
This commit is contained in:
parent
62a7e724a2
commit
a0d045e156
8 changed files with 95 additions and 105 deletions
|
|
@ -26,11 +26,11 @@ module Admin
|
|||
|
||||
def update
|
||||
@cfp = @program.cfp
|
||||
@cfp.assign_attributes(params[:cfp])
|
||||
@cfp.assign_attributes(cfp_params)
|
||||
|
||||
send_mail_on_cfp_dates_updates = @cfp.notify_on_cfp_date_update?
|
||||
|
||||
if @cfp.update_attributes(params[:cfp])
|
||||
if @cfp.update_attributes(cfp_params)
|
||||
Mailbot.delay.send_on_cfps_dates_updates(@conference) if send_mail_on_cfp_dates_updates
|
||||
redirect_to(admin_conference_program_cfp_path(@conference.short_title),
|
||||
notice: 'Call for papers successfully updated.')
|
||||
|
|
@ -52,7 +52,7 @@ module Admin
|
|||
private
|
||||
|
||||
def cfp_params
|
||||
params[:cfp]
|
||||
params.require(:cfp).permit(:start_date, :end_date)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ module Admin
|
|||
def update
|
||||
authorize! :update, @conference.program
|
||||
@program = @conference.program
|
||||
@program.assign_attributes(params[:program])
|
||||
@program.assign_attributes(program_params)
|
||||
# send_mail_on_schedule_public = @program.notify_on_schedule_public?
|
||||
|
||||
if @program.update_attributes(params[:program])
|
||||
if @program.update_attributes(program_params)
|
||||
# Mailbot.delay.send_on_schedule_public(@conference) if send_mail_on_schedule_public
|
||||
redirect_to(admin_conference_program_path(@conference.short_title),
|
||||
notice: 'The program was successfully updated.')
|
||||
|
|
@ -26,7 +26,7 @@ module Admin
|
|||
private
|
||||
|
||||
def program_params
|
||||
params[:program]
|
||||
params.require(:program).permit(:rating, :schedule_public, :schedule_fluid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class ProposalController < ApplicationController
|
|||
|
||||
params[:event].delete :user
|
||||
|
||||
@event = Event.new(params[:event])
|
||||
@event = Event.new(event_params)
|
||||
@event.program = @program
|
||||
|
||||
@event.event_users.new(user: current_user,
|
||||
|
|
|
|||
|
|
@ -38,10 +38,6 @@ class Program < ActiveRecord::Base
|
|||
accepts_nested_attributes_for :difficulty_levels, allow_destroy: true
|
||||
accepts_nested_attributes_for :rooms, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true
|
||||
|
||||
attr_accessible :schedule_fluid, :rating,
|
||||
:schedule_public, :include_cfp_in_splash, :conference_id,
|
||||
:event_types_attributes, :difficulty_levels_attributes, :rooms_attributes, :tracks_attributes
|
||||
|
||||
# validates :conference_id, presence: true, uniqueness: true
|
||||
validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 }
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
class Cfp < ActiveRecord::Base
|
||||
belongs_to :program
|
||||
|
||||
attr_accessible :start_date, :end_date, :program_id
|
||||
|
||||
validates :program_id, presence: true, uniqueness: true
|
||||
validates :start_date, :end_date, presence: true
|
||||
validate :before_end_of_conference
|
||||
|
|
|
|||
|
|
@ -36,10 +36,6 @@ class Program < ActiveRecord::Base
|
|||
accepts_nested_attributes_for :tracks, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true
|
||||
accepts_nested_attributes_for :difficulty_levels, allow_destroy: true
|
||||
|
||||
attr_accessible :schedule_fluid, :rating,
|
||||
:schedule_public, :include_cfp_in_splash, :conference_id,
|
||||
:event_types_attributes, :difficulty_levels_attributes, :tracks_attributes
|
||||
|
||||
# validates :conference_id, presence: true, uniqueness: true
|
||||
validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 }
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
%br
|
||||
#{pluralize(event.voters.length, 'voter')}
|
||||
%br
|
||||
- @program.cfp.rating.times do |counter|
|
||||
- @program.rating.times do |counter|
|
||||
- if event.average_rating.to_f.round == counter+1
|
||||
= label_tag "label_rating", "", :class => "avgrating", :avgrate => true
|
||||
= javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue