145 lines
4.1 KiB
Ruby
145 lines
4.1 KiB
Ruby
class ActivesController < ApplicationController
|
|
|
|
helper MemberHelper
|
|
|
|
def index
|
|
begin
|
|
time_now = Time.now
|
|
OrbitHelper.render_css_in_head(["active_front"])
|
|
actives = Act.filter_by_categories.can_display_on_front.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
|
|
|
acts = actives.collect do |a|
|
|
link_to_show = OrbitHelper.url_to_show(a.to_param) + '?method=show_data'
|
|
title_text = a.title
|
|
title = "<a href=\"#{link_to_show}\" target=\"_blank\">#{title_text}</a>"
|
|
sign_up = a.signup_show
|
|
statuses = a.statuses_with_classname.collect do |status|
|
|
{
|
|
"status" => status["name"],
|
|
"status-class" => "status-#{status['classname']}"
|
|
}
|
|
end
|
|
act_start_date = (a.act_start_date.blank? ? "" : a.act_start_date.strftime('%Y-%m-%d %H:%M') rescue "")
|
|
act_end_date = (a.act_end_date.blank? ? t(:no_deadline) : a.act_end_date.strftime('%Y-%m-%d %H:%M') rescue "")
|
|
act_duration_date = act_start_date.blank? ? act_end_date : "#{act_start_date} ~ #{act_end_date}"
|
|
|
|
sign_start_date = (a.sign_start_date.blank? ? "" : 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 "")
|
|
sign_duration_date = sign_start_date.blank? ? sign_end_date : "#{sign_start_date} ~ #{sign_end_date}"
|
|
|
|
desc = a.image_description
|
|
desc = (desc.blank? ? "active image" : desc)
|
|
|
|
{
|
|
"link_to_show" => link_to_show,
|
|
"title_text" => title_text,
|
|
"statuses" => statuses,
|
|
"title" => title,
|
|
"subtitle" => a.subtitle,
|
|
"img_src" => a.image.thumb.url || "/assets/announcement-default.jpg",
|
|
"img_description" => desc,
|
|
"category" => a.category.title,
|
|
"sign_duration_date" => sign_duration_date,
|
|
"sign_start_date" => sign_start_date,
|
|
"sign_end_date" => sign_end_date,
|
|
"act_duration_date" => act_duration_date,
|
|
"act_start_date" => act_start_date,
|
|
"act_end_date" => act_end_date,
|
|
'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 ""),
|
|
'sign_up' => sign_up
|
|
}
|
|
end
|
|
_display = acts.count == 0 ? "hide" : ''
|
|
{
|
|
"acts" => acts,
|
|
"extras" => {
|
|
"display" => _display,
|
|
"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
|
|
}
|
|
rescue => e
|
|
puts [e,e.backtrace]
|
|
end
|
|
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])
|
|
|
|
{
|
|
'act' => act,
|
|
'sign_up' => act.signup_show,
|
|
'time_now' => time_now,
|
|
'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 "")
|
|
}
|
|
|
|
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(id: nil)
|
|
|
|
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 |