diff --git a/app/assets/stylesheets/forms.css b/app/assets/stylesheets/forms.css
new file mode 100644
index 00000000..9588390f
--- /dev/null
+++ b/app/assets/stylesheets/forms.css
@@ -0,0 +1,8 @@
+#error_explanation {
+ border-color: #9d3515;
+ background-color: #FCEDE9;
+}
+
+.error {
+ color: #9d3515;
+}
diff --git a/app/controllers/event_instances_controller.rb b/app/controllers/event_instances_controller.rb
index 46f7d34e..004d8ca3 100644
--- a/app/controllers/event_instances_controller.rb
+++ b/app/controllers/event_instances_controller.rb
@@ -7,9 +7,12 @@ def new
def create
@event_instance = EventInstance.new(event_instance_params)
if verify_recaptcha(model: @event_instance) && @event_instance.save
- redirect_to speakers_path
+ flash[:notice] = 'Event created successfully!'
+
+ redirect_to events_path
else
@events = Event.all.order(name: :asc)
+
render 'new'
end
end
diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb
index c037072d..178147b7 100644
--- a/app/controllers/proposals_controller.rb
+++ b/app/controllers/proposals_controller.rb
@@ -17,6 +17,8 @@ def new
def create
@proposal = Proposal.new(proposal_params)
if verify_recaptcha(model: @proposal) && @proposal.save
+ flash[:notice] = 'Proposal created successfully!'
+
redirect_to proposal_path(@proposal)
else
@speakers = speakers
@@ -32,6 +34,8 @@ def edit
def update
@proposal = Proposal.find(params[:id])
if verify_recaptcha(model: @proposal) && @proposal.update(proposal_params)
+ flash[:notice] = 'Proposal updated successfully!'
+
redirect_to proposal_path(@proposal)
else
@speakers = speakers
diff --git a/app/controllers/speakers_controller.rb b/app/controllers/speakers_controller.rb
index 3e616000..b50e8282 100644
--- a/app/controllers/speakers_controller.rb
+++ b/app/controllers/speakers_controller.rb
@@ -14,6 +14,8 @@ def new
def create
@speaker = Speaker.new(speaker_params)
if verify_recaptcha(model: @speaker) && @speaker.save
+ flash[:notice] = 'Speaker created successfully!'
+
redirect_to speakers_path
else
render :new
diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb
index d0eefc53..0b69604a 100644
--- a/app/controllers/submissions_controller.rb
+++ b/app/controllers/submissions_controller.rb
@@ -8,10 +8,13 @@ def new
def create
@submission = Submission.new(submission_params)
if verify_recaptcha(model: @submission) && @submission.save
+ flash[:notice] = 'Submission created successfully!'
+
redirect_to proposal_path(@submission.proposal)
else
@proposal = @submission.proposal
@events = Event.all.order('name ASC')
+
render 'new'
end
end
@@ -25,9 +28,10 @@ def update
@submission = Submission.find(params[:id])
@proposal = @submission.proposal
if verify_recaptcha(model: @submission) && @submission.update(submission_params)
+ flash[:notice] = 'Submission updated successfully!'
+
redirect_to proposal_path(@proposal)
else
- flash[:alert] = 'Failed to update submission'
render 'edit'
end
end
diff --git a/app/views/event_instances/new.html.erb b/app/views/event_instances/new.html.erb
index 3d43c18e..925f8e4f 100644
--- a/app/views/event_instances/new.html.erb
+++ b/app/views/event_instances/new.html.erb
@@ -1,12 +1,6 @@
<% if @event_instance.errors.any? %>
-
-
We couldn't save this event because:
-
- <% @event_instance.errors.full_messages.each do |msg| %>
- - <%= msg %>
- <% end %>
-
-
+ <%= render "shared/form_error_display", errors: @event_instance.errors,
+ object_type: "event" %>
<% end %>
<%= form_for @event_instance do |f| %>
diff --git a/app/views/proposals/edit.html.erb b/app/views/proposals/edit.html.erb
index 3e239f8d..87879e64 100644
--- a/app/views/proposals/edit.html.erb
+++ b/app/views/proposals/edit.html.erb
@@ -1,12 +1,6 @@
<% if @proposal.errors.any? %>
-
-
We couldn't update this proposal because:
-
- <% @proposal.errors.full_messages.each do |msg| %>
- - <%= msg %>
- <% end %>
-
-
+ <%= render "shared/form_error_display", errors: @proposal.errors,
+ object_type: "proposal" %>
<% end %>
Edit a proposal
diff --git a/app/views/proposals/new.html.erb b/app/views/proposals/new.html.erb
index e8eec265..ce540193 100644
--- a/app/views/proposals/new.html.erb
+++ b/app/views/proposals/new.html.erb
@@ -1,12 +1,6 @@
<% if @proposal.errors.any? %>
-
-
We couldn't save this proposal because:
-
- <% @proposal.errors.full_messages.each do |msg| %>
- - <%= msg %>
- <% end %>
-
-
+ <%= render "shared/form_error_display", errors: @proposal.errors,
+ object_type: "proposal" %>
<% end %>
Add a proposal
diff --git a/app/views/shared/_form_error_display.html.erb b/app/views/shared/_form_error_display.html.erb
new file mode 100644
index 00000000..7abaf823
--- /dev/null
+++ b/app/views/shared/_form_error_display.html.erb
@@ -0,0 +1,13 @@
+<%-# locals: errors, object_type %>
+
+
diff --git a/app/views/speakers/new.html.erb b/app/views/speakers/new.html.erb
index 32924882..6783dc56 100644
--- a/app/views/speakers/new.html.erb
+++ b/app/views/speakers/new.html.erb
@@ -1,13 +1,8 @@
<% if @speaker.errors.any? %>
-
-
We couldn't save this speaker because:
-
- <% @speaker.errors.full_messages.each do |msg| %>
- - <%= msg %>
- <% end %>
-
-
+ <%= render "shared/form_error_display", errors: @speaker.errors,
+ object_type: "speaker" %>
<% end %>
+
Add a speaker
<%= form_for @speaker, url: {action: 'create'} do |f| %>
<%= f.text_field :name, placeholder: "Speaker's name" %>
diff --git a/app/views/submissions/edit.html.erb b/app/views/submissions/edit.html.erb
index 8a4c06eb..a876210e 100644
--- a/app/views/submissions/edit.html.erb
+++ b/app/views/submissions/edit.html.erb
@@ -1,3 +1,8 @@
+<% if @submission.errors.any? %>
+ <%= render "shared/form_error_display", errors: @submission.errors,
+ object_type: "submission" %>
+<% end %>
+
Edit submission
<%= "#{@proposal.title} at #{@submission.event_instance.name_and_year}" %>
diff --git a/app/views/submissions/new.html.erb b/app/views/submissions/new.html.erb
index 4399aadd..b21ce860 100644
--- a/app/views/submissions/new.html.erb
+++ b/app/views/submissions/new.html.erb
@@ -1,12 +1,6 @@
<% if @submission.errors.any? %>
-
-
We couldn't save this submission because:
-
- <% @submission.errors.full_messages.each do |msg| %>
- - <%= msg %>
- <% end %>
-
-
+ <%= render "shared/form_error_display", errors: @submission.errors,
+ object_type: "submission" %>
<% end %>
Add a submission
@@ -14,12 +8,22 @@
<%= form_for @submission, url: {action: 'create'} do |f| %>
<%= f.hidden_field(:proposal_id, value: @proposal.id) %>
<%= f.grouped_collection_select(:event_instance_id, @events, :instances, :name, :id, :name_and_year) %>
- <%= f.label(:result_accepted, "Accepted") %>
- <%= f.radio_button(:result, :accepted) %>
- <%= f.label(:result_rejected, "Rejected") %>
- <%= f.radio_button(:result, :rejected) %>
- <%= f.label(:result_waitlisted, "Waitlisted") %>
- <%= f.radio_button(:result, :waitlisted) %>
+
+ <%= f.label :result_accepted do %>
+ <%= f.radio_button(:result, :accepted) %>
+ Accepted
+ <% end %>
+
+ <%= f.label :result_rejected do %>
+ <%= f.radio_button(:result, :rejected) %>
+ Rejected
+ <% end %>
+
+ <%= f.label :result_waitlisted do %>
+ <%= f.radio_button(:result, :waitlisted) %>
+ Waitlisted
+ <% end %>
+
<%= recaptcha_tags %>
<%= f.submit "Add submission" %>
<% end %>
diff --git a/spec/controllers/event_instances_controller_spec.rb b/spec/controllers/event_instances_controller_spec.rb
index f4e2888b..69f601f5 100644
--- a/spec/controllers/event_instances_controller_spec.rb
+++ b/spec/controllers/event_instances_controller_spec.rb
@@ -17,7 +17,7 @@
it 'creates a new instance' do
expect(EventInstance).to have_received(:new).with(strong_params(event_id: event.id.to_s, year: '2017'))
end
- it { should redirect_to(speakers_path) }
+ it { should redirect_to(events_path) }
end
context 'for a new event' do
@@ -31,7 +31,7 @@
expect(EventInstance).to have_received(:new).with(strong_params(new_parent_event_name: 'The Nu Conference',
year: '2018'))
end
- it { should redirect_to(speakers_path) }
+ it { should redirect_to(events_path) }
end
end