diff --git a/app/controllers/survey_controller.rb b/app/controllers/survey_controller.rb new file mode 100644 index 00000000..f22a4fb3 --- /dev/null +++ b/app/controllers/survey_controller.rb @@ -0,0 +1,13 @@ +class SurveyController < ApplicationController + load_resource :conference, find_by: :short_title + load_and_authorize_resource + + def show + + end + + def reply + + end + +end diff --git a/app/models/ability.rb b/app/models/ability.rb index 2c1914be..0a4ec9e2 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -92,6 +92,9 @@ class Ability # can manage the commercials of their own events can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id) + + # can view and reply a survey + can [:show, :reply], Survey, surveyable_type: 'Conference', surveyable_id: user.registrations.pluck(:conference_id) end # Abilities for signed in users with roles diff --git a/app/views/admin/surveys/_survey_question.html.haml b/app/views/admin/surveys/_survey_question.html.haml index 399ebd27..067f0374 100644 --- a/app/views/admin/surveys/_survey_question.html.haml +++ b/app/views/admin/surveys/_survey_question.html.haml @@ -14,11 +14,12 @@ choices ) - if survey_question.mandatory %span.fa.fa-asterisk.text-danger - %p.pull-right - = link_to edit_admin_conference_survey_survey_question_path(@conference.short_title, @survey, survey_question) do - %span.fa.fa-edit - = link_to admin_conference_survey_survey_question_path(@conference.short_title, @survey, survey_question), method: :delete, data: { confirm: 'Are you sure you want to delete this question?' } do - %span.fa.fa-times + - if can? :edit, @survey + %p.pull-right + = link_to edit_admin_conference_survey_survey_question_path(@conference.short_title, @survey, survey_question) do + %span.fa.fa-edit + = link_to admin_conference_survey_survey_question_path(@conference.short_title, @survey, survey_question), method: :delete, data: { confirm: 'Are you sure you want to delete this question?' } do + %span.fa.fa-times .panel-body - if survey_question.boolean? %input{type: 'radio', name: 'radio'} diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index add392ad..710079a4 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -48,7 +48,7 @@ %ul - @conference.surveys.for_registration.each do |survey| %li - = link_to survey.title, "#" + = link_to survey.title, conference_survey_path(@conference.short_title, survey) - if @registration.events.any? .row diff --git a/app/views/survey/show.html.haml b/app/views/survey/show.html.haml new file mode 100644 index 00000000..568089fc --- /dev/null +++ b/app/views/survey/show.html.haml @@ -0,0 +1,18 @@ +.row + .col-md-12 + .page-header + %h1 + Survey #{@survey.title} + - if can? :edit, @survey + = link_to 'Edit Survey', admin_conference_survey_path(@conference.short_title, @survey), class: 'btn btn-primary pull-right' + %p.text-muted + From: + = @survey.start_date + to + = @survey.end_date +.row + .col-md-12 + - @survey.survey_questions.each.with_index(1) do |survey_question, index| + .row + .col-md-12 + = render partial: 'admin/surveys/survey_question', locals: { survey_question: survey_question, index: index } diff --git a/config/routes.rb b/config/routes.rb index 72fa4871..02a46547 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -96,6 +96,9 @@ Osem::Application.routes.draw do end resources :conference, only: [:index, :show] do + resources :survey, only: [:show] do + post :reply + end resource :program, only: [] do resources :proposal, except: :destroy do get 'commercials/render_commercial' => 'commercials#render_commercial'