fix error

This commit is contained in:
BOYA,CHIU 2021-08-10 09:40:26 +08:00
parent 9aa88aa080
commit 1f6fbb0619
4 changed files with 18 additions and 6 deletions

View File

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

View File

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

View File

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

View File

@ -1,7 +1,11 @@
<script>
if(document.querySelectorAll("#orbit-bar").length==0) location.reload();
</script>
<style type="text/css">
.expired{
color: #BE2E2E;
}
</style>
<table class="table main-list">
<thead>
<tr class="sort-header">
@ -17,9 +21,14 @@
<tbody>
<% @acts.each do |act| %>
<tr>
<td><%= act.category.title %></td>
<td>
<a href="<%= page_for_act(act) %>?method=show_data" target="_blank"><%= act.title %></a>
<%= act.category.title %>
</td>
<td>
<% if act.expired? %>
<span class='label'><%= t(:expired) %></span>
<% end %>
<a href="<%= page_for_act(act) %>?method=show_data" target="_blank"><%= act.title %></a>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(act) %>
@ -31,6 +40,8 @@
</td>
<td><%= Act.time_range(act.sign_start_date, act.sign_end_date) %></td>
<td><%= Act.time_range(act.act_start_date, act.act_end_date) %></td>
<td><%= format_value(act.postdate,'yyyy-MM-dd') %></td>
<td class="<%= act.expired? ? "expired" : "" %>"><%= format_value(act.end_date,'yyyy-MM-dd') %></td>
<td><a href="/admin/actives/<%=act.id.to_s%>/act_signup"><%= act.act_signups.count %></a></td>
<td><a href="/admin/actives/<%=act.id.to_s%>/export?format=xlsx" target="_blank"><%= t('act.export') %></a></td>
</tr>