From 1f6fbb0619206c095ba69422eb6eda3653f696ba Mon Sep 17 00:00:00 2001 From: "BOYA,CHIU" Date: Tue, 10 Aug 2021 09:40:26 +0800 Subject: [PATCH] fix error --- app/controllers/actives_controller.rb | 2 +- app/controllers/admin/actives_controller.rb | 2 +- app/models/act.rb | 3 ++- app/views/admin/actives/_index.html.erb | 17 ++++++++++++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/controllers/actives_controller.rb b/app/controllers/actives_controller.rb index ba2a138..edd21ea 100644 --- a/app/controllers/actives_controller.rb +++ b/app/controllers/actives_controller.rb @@ -6,7 +6,7 @@ class ActivesController < ApplicationController begin time_now = Time.now OrbitHelper.render_css_in_head(["active_front"]) - actives = Act.filter_by_categories.desc(:sign_start_date).page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) + 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' diff --git a/app/controllers/admin/actives_controller.rb b/app/controllers/admin/actives_controller.rb index c397dd8..94e7384 100644 --- a/app/controllers/admin/actives_controller.rb +++ b/app/controllers/admin/actives_controller.rb @@ -18,7 +18,7 @@ class Admin::ActivesController < OrbitAdminController def index @categories = @module_app.categories.enabled @filter_fields = filter_fields(@categories) - @table_fields = [:category, 'act.title', 'act.sign_up_time_range', 'act.act_time_range', 'act.sign_up_count', 'act.export'] + @table_fields = [:category, 'act.title', 'act.sign_up_time_range', 'act.act_time_range', 'act.postdate', 'act.end_date', 'act.sign_up_count', 'act.export'] if !params[:sort].blank? if params[:sort] == 'act_time_range' diff --git a/app/models/act.rb b/app/models/act.rb index 0c41a70..9f37667 100644 --- a/app/models/act.rb +++ b/app/models/act.rb @@ -74,6 +74,7 @@ class Act accepts_nested_attributes_for :act_signups, :allow_destroy => true scope :can_display, ->{any_of({:sign_start_date.lt=>Time.now, :sign_end_date.gt=>Time.now},{:sign_start_date.lt=>Time.now, :sign_end_date=>nil}).order_by([:is_top, :desc])} + scope :can_display_on_front, ->{any_of({:postdate.lt=>Time.now, :end_date.gt=>Time.now},{:postdate.lt=>Time.now, :end_date=>nil}).order_by(:is_top.desc, :postdate.desc, :sign_start_date.desc)} def update_user User.find(update_user_id) rescue nil @@ -84,7 +85,7 @@ class Act end def expired? - (self.sign_end_date < Time.now) rescue false + (self.end_date < Time.now) rescue false end def self.time_range(date1 = null, date2 = null) diff --git a/app/views/admin/actives/_index.html.erb b/app/views/admin/actives/_index.html.erb index 9078d6c..b18bd99 100644 --- a/app/views/admin/actives/_index.html.erb +++ b/app/views/admin/actives/_index.html.erb @@ -1,7 +1,11 @@ - + @@ -17,9 +21,14 @@ <% @acts.each do |act| %> - + + +
<%= act.category.title %> - <%= act.title %> + <%= act.category.title %> + + <% if act.expired? %> + <%= t(:expired) %> + <% end %> + <%= act.title %>
<%= Act.time_range(act.sign_start_date, act.sign_end_date) %> <%= Act.time_range(act.act_start_date, act.act_end_date) %><%= format_value(act.postdate,'yyyy-MM-dd') %>"><%= format_value(act.end_date,'yyyy-MM-dd') %> <%= act.act_signups.count %> <%= t('act.export') %>