2014-11-10 02:24:07 +00:00
|
|
|
class ActivesController < ApplicationController
|
|
|
|
|
|
|
|
helper MemberHelper
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
|
|
|
time_now = Time.now
|
|
|
|
|
|
|
|
actives = Act.filter_by_categories.desc(:sign_start_date).page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
|
|
|
|
|
|
|
acts = actives.collect do |a|
|
|
|
|
|
|
|
|
title = ('<a href="'+ OrbitHelper.url_to_show(a.to_param) + '?method=show_data" target="_blank">' + a.title + '</a>').html_safe
|
|
|
|
|
2015-11-20 12:08:11 +00:00
|
|
|
if (!a.sign_up.blank? and a.sign_start_date <= time_now and ( a.sign_end_date >= time_now or a.sign_end_date.nil? ) rescue false)
|
2014-11-10 02:24:07 +00:00
|
|
|
sign_up = ('<a href="'+ OrbitHelper.url_to_show(a.to_param) + '" target="_blank">' + t('act.sign_up') + '</a>').html_safe
|
|
|
|
elsif a.sign_up.blank?
|
|
|
|
sign_up = t('act.sign_up_not_open')
|
2015-11-20 12:08:11 +00:00
|
|
|
elsif (a.sign_start_date > time_now rescue false)
|
2014-11-10 02:24:07 +00:00
|
|
|
sign_up = t('act.sign_up_not_yet')
|
|
|
|
else
|
|
|
|
sign_up = t('act.sign_up_overdue')
|
|
|
|
end
|
|
|
|
|
|
|
|
{
|
|
|
|
"title" => title,
|
|
|
|
"category" => a.category.title,
|
2015-11-20 12:08:11 +00:00
|
|
|
"sign_start_date" => (a.sign_start_date.strftime('%Y-%m-%d %H:%M') rescue ""),
|
|
|
|
"sign_end_date" => ((a.sign_end_date ? a.sign_end_date.strftime('%Y-%m-%d %H:%M') : t(:no_deadline)) rescue ""),
|
|
|
|
"act_start_date" => (a.act_start_date.strftime('%Y-%m-%d %H:%M') rescue ""),
|
|
|
|
"act_end_date" => (a.act_end_date ? a.act_end_date.strftime('%Y-%m-%d %H:%M') : t(:no_deadline) rescue ""),
|
|
|
|
'sign_up_time_range' => (Act.time_range(a.sign_start_date, a.sign_end_date) rescue ""),
|
|
|
|
'sign_up_time_range' => (Act.time_range(a.sign_start_date, a.sign_end_date) rescue ""),
|
|
|
|
'act_time_range' => (Act.time_range(a.act_start_date, a.act_end_date) rescue ""),
|
2014-11-10 02:24:07 +00:00
|
|
|
'sign_up' => sign_up
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"acts" => acts,
|
|
|
|
"extras" => {
|
|
|
|
"widget-title"=>t('act.active'),
|
|
|
|
"th_title" => t('act.title'),
|
|
|
|
"th_act_time_range" => t('act.act_time_range'),
|
|
|
|
"th_sign_up_time_range" => t('act.sign_up_time_range'),
|
|
|
|
"th_category" => t(:category),
|
|
|
|
"th_sign_up" => t('act.sign_up')
|
|
|
|
},
|
|
|
|
"total_pages" => actives.total_pages
|
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def show_privacy
|
|
|
|
|
|
|
|
params = OrbitHelper.params
|
|
|
|
|
|
|
|
act = Act.find_by(uid: params[:uid])
|
|
|
|
|
|
|
|
active_agreement = ActAgreement.first
|
|
|
|
|
|
|
|
{
|
|
|
|
'act' => act,
|
|
|
|
"active_agreement" => active_agreement
|
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def show_data
|
|
|
|
|
|
|
|
time_now = Time.now
|
|
|
|
|
|
|
|
params = OrbitHelper.params
|
|
|
|
|
|
|
|
act = Act.find_by(uid: params[:uid])
|
|
|
|
|
2015-11-20 12:08:11 +00:00
|
|
|
if (!act.sign_up.blank? and act.sign_start_date <= time_now and ( act.sign_end_date >= time_now or act.sign_end_date.nil? ) rescue false)
|
2014-11-10 02:24:07 +00:00
|
|
|
sign_up = ('<a href="'+ OrbitHelper.url_to_show(act.to_param) + '" target="_blank">' + t('act.sign_up') + '</a>').html_safe
|
|
|
|
elsif act.sign_up.blank?
|
|
|
|
sign_up = t('act.sign_up_not_open')
|
2015-11-20 12:08:11 +00:00
|
|
|
elsif (act.sign_start_date > time_now rescue false)
|
2014-11-10 02:24:07 +00:00
|
|
|
sign_up = t('act.sign_up_not_yet')
|
|
|
|
else
|
|
|
|
sign_up = t('act.sign_up_overdue')
|
|
|
|
end
|
|
|
|
|
|
|
|
{
|
|
|
|
'act' => act,
|
|
|
|
'sign_up' => sign_up,
|
|
|
|
'time_now' => time_now,
|
2015-11-20 12:08:11 +00:00
|
|
|
'sign_up_time_range' => (Act.time_range(act.sign_start_date, act.sign_end_date) rescue ""),
|
|
|
|
'act_time_range' => (Act.time_range(act.act_start_date, act.act_end_date) rescue "")
|
2014-11-10 02:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
params = OrbitHelper.params
|
|
|
|
|
|
|
|
module_app = ModuleApp.where(:key => "active").first
|
|
|
|
|
|
|
|
categories = module_app.categories
|
|
|
|
|
|
|
|
act = Act.find_by(uid: params[:uid])
|
|
|
|
|
|
|
|
act_signup = ActSignup.new
|
|
|
|
|
|
|
|
time_now = Time.now
|
|
|
|
|
|
|
|
{
|
|
|
|
"act" => act,
|
|
|
|
"act_signup" => act_signup,
|
|
|
|
"time_now" => time_now
|
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
|
|
|
@act_signup = ActSignup.new(act_signup_params)
|
|
|
|
|
|
|
|
if gotcha_valid? && @act_signup.save
|
|
|
|
redirect_to "#{params[:referer_url]}/?method=signup_ok"
|
|
|
|
else
|
|
|
|
redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def signup_ok
|
|
|
|
end
|
|
|
|
|
|
|
|
def act_signup_params
|
|
|
|
params.require(:act_signup).permit!
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|