mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-18 06:01:12 +00:00
Add surveys; custom generated by admins
Available during registration or after conference Co-authored-by: Shyukri <shshyukriev@suse.com> Co-authored-by: Henne <hvogel@opensuse.org> Co-authored-by: Moises <mdeniz@suse.com>
This commit is contained in:
parent
4e742d170f
commit
9f3c0eff5d
43 changed files with 701 additions and 17 deletions
52
app/controllers/admin/survey_questions_controller.rb
Normal file
52
app/controllers/admin/survey_questions_controller.rb
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
module Admin
|
||||
class SurveyQuestionsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :survey, through: :conference
|
||||
load_and_authorize_resource through: :survey
|
||||
|
||||
def new
|
||||
@survey_question = @survey.survey_questions.new(min_choices: 1, max_choices: 1)
|
||||
@url = admin_conference_survey_survey_questions_path(@conference.short_title, @survey)
|
||||
end
|
||||
|
||||
def create
|
||||
@survey_question = @survey.survey_questions.new(survey_question_params)
|
||||
if @survey_question.save
|
||||
redirect_to admin_conference_survey_path(@conference.short_title, @survey), notice: 'Successfully created Survey Question.'
|
||||
else
|
||||
@url = admin_conference_survey_survey_questions_path(@conference.short_title, @survey)
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
# GET questions/1/edit
|
||||
def edit
|
||||
@url = admin_conference_survey_survey_question_path(@conference.short_title, @survey, @survey_question)
|
||||
end
|
||||
|
||||
# PUT questions/1
|
||||
def update
|
||||
if @survey_question.update_attributes(survey_question_params)
|
||||
redirect_to admin_conference_survey_path(@conference.short_title, @survey), notice: 'Successfully updated Survey Question.'
|
||||
else
|
||||
@url = admin_conference_survey_survey_question_path(@conference.short_title, @survey, @survey_question)
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE questions/1
|
||||
def destroy
|
||||
if @survey_question.destroy
|
||||
redirect_to admin_conference_survey_path(@conference.short_title, @survey), notice: 'Successfully deleted Survey Question.'
|
||||
else
|
||||
redirect_to admin_conference_survey_path(@conference.short_title, @survey), error: "Can't delete this Survey Question"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def survey_question_params
|
||||
params.require(:survey_question).permit(:title, :kind, :possible_answers, :min_choices, :max_choices, :mandatory)
|
||||
end
|
||||
end
|
||||
end
|
||||
48
app/controllers/admin/surveys_controller.rb
Normal file
48
app/controllers/admin/surveys_controller.rb
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
module Admin
|
||||
class SurveysController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@surveys = @conference.surveys
|
||||
end
|
||||
|
||||
def new
|
||||
@survey = Survey.new(survey_params)
|
||||
@url = admin_conference_surveys_path(@conference.short_title)
|
||||
end
|
||||
|
||||
def create
|
||||
@survey = Survey.new(survey_params)
|
||||
if @survey.save
|
||||
redirect_to new_admin_conference_survey_survey_question_path(@conference.short_title, @survey), notice: 'Successfully created survey'
|
||||
else
|
||||
redirect_to new_admin_conference_survey_survey_question_path(@conference.short_title, @survey), error: 'Could not create survey.' + @survey.errors.full_messates.to_sentence
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@url = admin_conference_survey_path(@conference.short_title, @survey)
|
||||
end
|
||||
|
||||
def update
|
||||
if @survey.update_attributes(survey_params)
|
||||
redirect_to admin_conference_surveys_path(@conference.short_title)
|
||||
else
|
||||
@url = admin_conference_survey_path(@conference.short_title, @survey)
|
||||
render action: :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@survey.destroy
|
||||
redirect_to admin_conference_surveys_path(@conference.short_title)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def survey_params
|
||||
params.require(:survey).permit(:title, :description, :target, :start_date, :end_date, :surveyable_type, :surveyable_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue