mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Add survey with target after_event
This commit is contained in:
parent
e1adf28081
commit
9908f88570
10 changed files with 45 additions and 9 deletions
|
|
@ -3,7 +3,7 @@
|
|||
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 :survey
|
||||
load_and_authorize_resource through: :survey
|
||||
|
||||
def new
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ module Admin
|
|||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@surveys = @conference.surveys
|
||||
@surveys = @conference.surveys + Survey.where(surveyable: @conference.program.events)
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class ProposalsController < ApplicationController
|
|||
def show
|
||||
@event_schedule = @event.event_schedules.find_by(schedule_id: @program.selected_schedule_id)
|
||||
@speakers_ordered = @event.speakers_ordered
|
||||
@surveys_after_event = @event.surveys.after_event.select(&:active?)
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
|||
|
|
@ -785,6 +785,16 @@ class Conference < ApplicationRecord
|
|||
short_title
|
||||
end
|
||||
|
||||
##
|
||||
# Returns true or false, if the event is already over or not
|
||||
#
|
||||
# ====Returns
|
||||
# * +true+ -> If the event is over
|
||||
# * +false+ -> If the event is not over yet
|
||||
def ended?
|
||||
end_date < Time.current
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Returns a different html colour for every i and consecutive colors are
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class Event < ApplicationRecord
|
|||
has_many :votes, dependent: :destroy
|
||||
has_many :voters, through: :votes, source: :user
|
||||
has_many :commercials, as: :commercialable, dependent: :destroy
|
||||
has_many :surveys, as: :surveyable, dependent: :destroy
|
||||
belongs_to :event_type
|
||||
|
||||
has_many :events_registrations
|
||||
|
|
|
|||
|
|
@ -5,12 +5,30 @@ class Survey < ActiveRecord::Base
|
|||
has_many :survey_questions, dependent: :destroy
|
||||
has_many :survey_submissions, dependent: :destroy
|
||||
|
||||
enum target: [:after_conference, :during_registration]
|
||||
enum target: [:after_conference, :during_registration, :after_event]
|
||||
validates :title, presence: true
|
||||
|
||||
##
|
||||
# Finds active surveys
|
||||
# * if a survey has either start or end date, but not both
|
||||
# check is performed only on the attribute that exists
|
||||
# * if a survey does not have start/end dates, then it is marked active
|
||||
# further check is expected, where appropriate, depending on the survey's target
|
||||
# ====Returns
|
||||
# * +true+ -> If the survey is active (will accept replies)
|
||||
# * +false+ -> If the survey is closed
|
||||
def active?
|
||||
return false unless start_date && end_date
|
||||
now = Time.now.in_time_zone(surveyable.timezone)
|
||||
now >= start_date && now <= end_date
|
||||
return true unless start_date || end_date
|
||||
# Find timezone of conference (survyeable is Conference or Event)
|
||||
timezone = surveyable.is_a?(Conference) ? surveyable.timezone : surveyable.conference.timezone
|
||||
now = Time.current.in_time_zone(timezone)
|
||||
|
||||
if start_date && end_date
|
||||
now >= start_date && now <= end_date
|
||||
elsif start_date && !end_date
|
||||
now >= start_date
|
||||
elsif !start_date && end_date
|
||||
now <= end_date
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
class: 'rating myrating'
|
||||
- else
|
||||
= rating_stars(event.user_rating(current_user), max_rating, voted: true)
|
||||
= (Voting period is closed)
|
||||
(Voting period is closed)
|
||||
|
||||
- if show_votes
|
||||
- unless votes.blank?
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@
|
|||
%b State
|
||||
%th
|
||||
.fa.fa-comment
|
||||
%th Add Survey
|
||||
- @events.each do |event|
|
||||
= render 'datatable_row',
|
||||
event: event,
|
||||
|
|
|
|||
|
|
@ -52,5 +52,5 @@
|
|||
= link_to 'Unsubscribe', conference_subscriptions_path(conference.short_title), method: :delete, class: 'btn btn-default'
|
||||
- if current_user && current_user.physical_tickets.by_conference(conference).any?
|
||||
= link_to 'My Tickets', conference_physical_tickets_path(conference.short_title), class: 'btn btn-default'
|
||||
- surveys = conference.surveys.after_conference.select(&:active?)
|
||||
= link_to 'Surveys', conference_surveys_path(conference.short_title), class: 'btn btn-default' if surveys.any?
|
||||
- surveys_after_conference = conference.surveys.after_conference.select(&:active?)
|
||||
= link_to 'Surveys', conference_surveys_path(conference.short_title), class: 'btn btn-default' if surveys_after_conference.any? && conference.ended?
|
||||
|
|
|
|||
|
|
@ -122,3 +122,8 @@
|
|||
%dt Room:
|
||||
%dd
|
||||
= event.room.name
|
||||
.row
|
||||
.col-md-12
|
||||
- if @surveys_after_event.any? && @event.ended?
|
||||
.page-header
|
||||
= render partial: 'surveys/list', locals: { surveys: @surveys_after_event, conference: @conference }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue