Showing survey for users and handling authorization
This commit is contained in:
parent
9ce4ba6f6b
commit
67bccf0195
6 changed files with 44 additions and 6 deletions
13
app/controllers/survey_controller.rb
Normal file
13
app/controllers/survey_controller.rb
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
18
app/views/survey/show.html.haml
Normal file
18
app/views/survey/show.html.haml
Normal file
|
|
@ -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 }
|
||||
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue