Surveys: Grooming of messages to user
This commit is contained in:
parent
0646e41a82
commit
4d5bb42331
2 changed files with 19 additions and 5 deletions
|
|
@ -16,7 +16,7 @@ class SurveysController < ApplicationController
|
||||||
|
|
||||||
def reply
|
def reply
|
||||||
unless can? :reply, @survey
|
unless can? :reply, @survey
|
||||||
redirect_to conference_survey_path(@conference, @survey), alert: 'This survey is currently closed'
|
redirect_to conference_survey_path(@conference, @survey), alert: 'This survey is not available'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -33,13 +33,22 @@ class SurveysController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
user_survey_submission = @survey.survey_submissions.find_by(user: current_user)
|
user_survey_submission = @survey.survey_submissions.find_by(user: current_user)
|
||||||
if user_survey_submission
|
begin
|
||||||
user_survey_submission.update_attributes(updated_at: Time.current)
|
if user_survey_submission
|
||||||
else
|
user_survey_submission.update_attributes(updated_at: Time.current)
|
||||||
@survey.survey_submissions.create!(user: current_user)
|
else
|
||||||
|
@survey.survey_submissions.create!(user: current_user)
|
||||||
|
end
|
||||||
|
rescue => error
|
||||||
|
Rails.logger.info "Could not save submission reply for user #{current_user.email} with error: #{error.message}"
|
||||||
|
flash[:error] = "Something went wrong, please try again!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless flash[:error]
|
||||||
|
flash[:success] = 'Thank you for your submission!'
|
||||||
|
end
|
||||||
|
|
||||||
redirect_back(fallback_location: root_path)
|
redirect_back(fallback_location: root_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -26,3 +26,8 @@
|
||||||
.row
|
.row
|
||||||
.col-md-10.col-md-offset-1
|
.col-md-10.col-md-offset-1
|
||||||
= f.submit 'Submit', class: 'btn btn-primary pull-right', disabled: !(can? :reply, @survey)
|
= f.submit 'Submit', class: 'btn btn-primary pull-right', disabled: !(can? :reply, @survey)
|
||||||
|
.pull-left
|
||||||
|
- if @survey.during_registration?
|
||||||
|
= link_to 'Back to Registration', conference_conference_registration_path(@conference)
|
||||||
|
- elsif @survey.after_event?
|
||||||
|
= link_to 'Back', conference_program_proposal_path(@conference, @survey.surveyable)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue