Fix survey title link redirection after deadline

This commit is contained in:
Bernie Chiu 2013-10-11 17:04:03 +08:00 committed by Manson Wang
parent 8f65da0a04
commit 83a8433e52
7 changed files with 37 additions and 1 deletions

View File

@ -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

View File

@ -41,6 +41,16 @@ class Survey
before_save :check_deadline, :update_avliable_language
def topic
unless self.deadline && Time.now > self.deadline
('<a target="_blank" href="' + Rails.application.routes
.url_helpers.panel_survey_front_end_survey_path(self, :standalone => true) + '">' + self.title + '</a>').html_safe
else
('<a target="_blank" href="' + Rails.application.routes
.url_helpers.info_panel_survey_front_end_survey_path(self, :standalone => true) + '">' + self.title + '</a>').html_safe
end
end
def time_range
r = "#{self.postdate.to_date}"
r += "- #{self.deadline.to_date}" if self.deadline

View File

@ -0,0 +1,16 @@
<h3>問卷已結束!感謝您的參與!</h3>
<table class="table">
<tr>
<th>問卷標題</th>
<th>問卷說明</th>
<th>開始期間</th>
<th>結束期間</th>
</tr>
<tr>
<td><%= @survey.title %></td>
<td><%= truncate(@survey.description, to: 40) %></td>
<td><%= @survey.postdate.to_date %></td>
<td><%= @survey.deadline.to_date %></td>
</tr>
</table>

View File

@ -46,6 +46,7 @@ en:
title: Title
time_range: Date Range
result: Result
topic: Title
frontend:
survey: Survey Frontend

View File

@ -48,6 +48,7 @@ zh_tw:
time_range: 問卷期間
write: 填問卷
result: 結果
topic: 問卷標題
frontend:
survey: 問卷調查前台

View File

@ -24,6 +24,7 @@ Rails.application.routes.draw do
resources :surveys do
member do
get 'result'
get 'info'
end
end
end

View File

@ -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