Fix cfp create and error display
This commit is contained in:
parent
4e395a0d7a
commit
e3d21de1cb
4 changed files with 23 additions and 13 deletions
|
|
@ -5,28 +5,38 @@ class Admin::CallforpapersController < ApplicationController
|
||||||
@cfp = @conference.call_for_papers
|
@cfp = @conference.call_for_papers
|
||||||
if @cfp.nil?
|
if @cfp.nil?
|
||||||
@cfp = CallForPapers.new
|
@cfp = CallForPapers.new
|
||||||
|
@url = admin_conference_callforpapers_path(@conference.short_title)
|
||||||
|
else
|
||||||
|
@url = admin_conference_callforpaper_path(@conference.short_title, @cfp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@cfp = @conference.call_for_papers
|
@cfp = @conference.call_for_papers
|
||||||
@cfp.update_attributes(params[:call_for_papers])
|
if @cfp.update_attributes(params[:call_for_papers])
|
||||||
redirect_to(admin_conference_callforpapers_path(
|
redirect_to(admin_conference_callforpapers_path(
|
||||||
id: @conference.short_title),
|
@conference.short_title),
|
||||||
notice: 'Call for Papers was successfully updated.')
|
notice: 'Call for Papers was successfully updated.')
|
||||||
|
else
|
||||||
|
flash.now[:error] = 'Call for Papers update failed. ' + @cfp.errors.full_messages.map {|e| e.humanize + "."}.join(" ")
|
||||||
|
|
||||||
|
@url = admin_conference_callforpaper_path(@conference.short_title, @cfp)
|
||||||
|
render action: "index"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@cfp = CallForPapers.new(params[:call_for_papers])
|
@cfp = CallForPapers.new(params[:call_for_papers])
|
||||||
@conference.call_for_papers = @cfp
|
@cfp.conference_id = @conference.id
|
||||||
if @cfp.save
|
if @cfp.save
|
||||||
redirect_to(admin_conference_callforpapers_path(
|
redirect_to(admin_conference_callforpapers_path(
|
||||||
id: @conference.short_title),
|
@conference.short_title),
|
||||||
notice: 'Call for Papers was successfully updated.')
|
notice: 'Call for Papers was successfully created.')
|
||||||
else
|
else
|
||||||
redirect_to(admin_conference_callforpapers_path(
|
flash.now[:error] = 'Call for Papers creation failed. ' + @cfp.errors.full_messages.map {|e| e.humanize + "."}.join(" ")
|
||||||
id: @conference.short_title),
|
|
||||||
error: 'Call for Papers failed.')
|
@url = admin_conference_callforpapers_path(@conference.short_title)
|
||||||
|
render action: "index"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ class CallForPapers < ActiveRecord::Base
|
||||||
attr_accessible :start_date, :end_date, :hard_deadline, :description, :schedule_changes, :rating, :rating_desc, :schedule_public
|
attr_accessible :start_date, :end_date, :hard_deadline, :description, :schedule_changes, :rating, :rating_desc, :schedule_public
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
|
|
||||||
validates_presence_of :start_date, :end_date, :hard_deadline
|
validates_presence_of :start_date, :end_date, :hard_deadline, :description
|
||||||
validates :rating, :numericality => { :greater_than_or_equal_to => 0, :less_than_or_equal_to => 10 }
|
validates :rating, :numericality => { :greater_than_or_equal_to => 0, :less_than_or_equal_to => 10 }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
.col-md-3
|
.col-md-3
|
||||||
= render 'admin/conference/sidebar'
|
= render 'admin/conference/sidebar'
|
||||||
.col-md-9
|
.col-md-9
|
||||||
= semantic_form_for(@cfp, :url => admin_conference_callforpaper_path(@conference.short_title, @conference.call_for_papers),:html => {:multipart => true}) do |f|
|
= semantic_form_for(@cfp, url: @url,:html => {:multipart => true}) do |f|
|
||||||
= f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" }
|
= f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" }
|
||||||
= f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" }
|
= f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" }
|
||||||
= f.input :hard_deadline, :as => :string, :input_html => { :id => "cfp-hard-datepicker", :readonly => "readonly" }
|
= f.input :hard_deadline, :as => :string, :input_html => { :id => "cfp-hard-datepicker", :readonly => "readonly" }
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ Osem::Application.routes.draw do
|
||||||
resources :social_events, only: [:show, :update, :index]
|
resources :social_events, only: [:show, :update, :index]
|
||||||
resources :supporter_levels, only: [:show, :update, :index]
|
resources :supporter_levels, only: [:show, :update, :index]
|
||||||
resources :emails, only: [:show, :update, :index]
|
resources :emails, only: [:show, :update, :index]
|
||||||
resources :callforpapers, only: [:show, :update, :index]
|
resources :callforpapers, only: [:create, :update, :index]
|
||||||
put "/questions/update_conference" => "questions#update_conference"
|
put "/questions/update_conference" => "questions#update_conference"
|
||||||
resources :questions
|
resources :questions
|
||||||
resources :events do
|
resources :events do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue