From 83a8433e52db02859b2567d1d5dbf7c31e7b953e Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Fri, 11 Oct 2013 17:04:03 +0800 Subject: [PATCH] Fix survey title link redirection after deadline --- .../panel/survey/front_end/surveys_controller.rb | 6 ++++++ .../built_in_modules/survey/app/models/survey.rb | 10 ++++++++++ .../panel/survey/front_end/surveys/info.html.erb | 16 ++++++++++++++++ .../survey/config/locales/en.yml | 1 + .../survey/config/locales/zh_tw.yml | 1 + vendor/built_in_modules/survey/config/routes.rb | 1 + vendor/built_in_modules/survey/init.rb | 3 ++- 7 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/info.html.erb diff --git a/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb b/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb index 847fa430d..69f157b50 100644 --- a/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb +++ b/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb @@ -110,4 +110,10 @@ class Panel::Survey::FrontEnd::SurveysController < OrbitWidgetController end end + def info + redirect_standalone result_panel_survey_front_end_survey_path(params[:id], :standalone => 'true') do + @survey = ::Survey.find params[:id] + end + end + end \ No newline at end of file diff --git a/vendor/built_in_modules/survey/app/models/survey.rb b/vendor/built_in_modules/survey/app/models/survey.rb index 4f271eeef..f94c43766 100644 --- a/vendor/built_in_modules/survey/app/models/survey.rb +++ b/vendor/built_in_modules/survey/app/models/survey.rb @@ -41,6 +41,16 @@ class Survey before_save :check_deadline, :update_avliable_language + def topic + unless self.deadline && Time.now > self.deadline + ('' + self.title + '').html_safe + else + ('' + self.title + '').html_safe + end + end + def time_range r = "#{self.postdate.to_date}" r += "- #{self.deadline.to_date}" if self.deadline diff --git a/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/info.html.erb b/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/info.html.erb new file mode 100644 index 000000000..27ef9712d --- /dev/null +++ b/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/info.html.erb @@ -0,0 +1,16 @@ +

問卷已結束!感謝您的參與!

+ + + + + + + + + + + + + + +
問卷標題問卷說明開始期間結束期間
<%= @survey.title %><%= truncate(@survey.description, to: 40) %><%= @survey.postdate.to_date %><%= @survey.deadline.to_date %>
\ No newline at end of file diff --git a/vendor/built_in_modules/survey/config/locales/en.yml b/vendor/built_in_modules/survey/config/locales/en.yml index 041c29842..7847c4a9c 100644 --- a/vendor/built_in_modules/survey/config/locales/en.yml +++ b/vendor/built_in_modules/survey/config/locales/en.yml @@ -46,6 +46,7 @@ en: title: Title time_range: Date Range result: Result + topic: Title frontend: survey: Survey Frontend diff --git a/vendor/built_in_modules/survey/config/locales/zh_tw.yml b/vendor/built_in_modules/survey/config/locales/zh_tw.yml index a118012b3..654262e30 100644 --- a/vendor/built_in_modules/survey/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/survey/config/locales/zh_tw.yml @@ -48,6 +48,7 @@ zh_tw: time_range: 問卷期間 write: 填問卷 result: 結果 + topic: 問卷標題 frontend: survey: 問卷調查前台 diff --git a/vendor/built_in_modules/survey/config/routes.rb b/vendor/built_in_modules/survey/config/routes.rb index c33b36333..6c2ba6162 100644 --- a/vendor/built_in_modules/survey/config/routes.rb +++ b/vendor/built_in_modules/survey/config/routes.rb @@ -24,6 +24,7 @@ Rails.application.routes.draw do resources :surveys do member do get 'result' + get 'info' end end end diff --git a/vendor/built_in_modules/survey/init.rb b/vendor/built_in_modules/survey/init.rb index 72e60452a..6f5a0f4d5 100644 --- a/vendor/built_in_modules/survey/init.rb +++ b/vendor/built_in_modules/survey/init.rb @@ -23,7 +23,8 @@ module Faq enable ["typeA"] query 'Survey.any_of( {:postdate.lte => Time.now} )' # link_field :title, {:method => 'panel_survey_front_end_survey_path',:args=>:self} - field :title + # field :title + field :topic field :time_range field :write field :result