announcement widget page
This commit is contained in:
		
							parent
							
								
									4cfae9c107
								
							
						
					
					
						commit
						2c8940e350
					
				|  | @ -9,7 +9,11 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController | ||||||
|   # GET /bulletins.xml |   # GET /bulletins.xml | ||||||
|    |    | ||||||
|   def index |   def index | ||||||
|     @bulletins = Bulletin.desc("postdate") |    | ||||||
|  | 	date_now = Time.now | ||||||
|  | 	 | ||||||
|  |     @bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate) | ||||||
|  | 
 | ||||||
| 	get_categorys | 	get_categorys | ||||||
|   end |   end | ||||||
|    |    | ||||||
|  |  | ||||||
|  | @ -61,11 +61,13 @@ class Bulletin | ||||||
| 
 | 
 | ||||||
|   def self.widget_datas |   def self.widget_datas | ||||||
|    |    | ||||||
| 	date_now = Date.today | 	date_now = Time.now | ||||||
| 	 | 	 | ||||||
|     # find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :postdate) |     # find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :postdate) | ||||||
| 	where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate) | 	# where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate) | ||||||
| 	# any_of({ :title => "test" },{:deadline => nil, :title => "123"}) | 	# any_of({ :title => "test" },{:deadline => nil, :title => "123"}) | ||||||
|  | 	any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).limit(5) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|   end |   end | ||||||
|   |   | ||||||
|  |  | ||||||
|  | @ -7,18 +7,14 @@ | ||||||
| 
 | 
 | ||||||
| 	<table> | 	<table> | ||||||
| 	  <tr> | 	  <tr> | ||||||
| 		<th><%= t('bulletin.status') %></th> |  | ||||||
| 		<th><%= t('bulletin.postdate') %></th> | 		<th><%= t('bulletin.postdate') %></th> | ||||||
| 		<th><%= t('bulletin.deadline') %></th> |  | ||||||
| 		<th><%= t('bulletin.category') %></th> | 		<th><%= t('bulletin.category') %></th> | ||||||
| 		<th><%= t('bulletin.title') %></th> | 		<th><%= t('bulletin.title') %></th> | ||||||
| 	  </tr> | 	  </tr> | ||||||
| 
 | 
 | ||||||
| 	<% @bulletins.each do |post| %> | 	<% @bulletins.each do |post| %> | ||||||
| 	  <tr> | 	  <tr> | ||||||
| 		<td></td> |  | ||||||
| 		<td><%= post.postdate %></td> | 		<td><%= post.postdate %></td> | ||||||
| 		<td><%= (post.deadline) ? post.deadline : t('bulletin.no_deadline') %></td> |  | ||||||
| 		<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td> | 		<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td> | ||||||
| 		<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post) %> | 		<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post) %> | ||||||
| 		<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> | 		<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> | ||||||
|  |  | ||||||
|  | @ -50,7 +50,7 @@ | ||||||
| 	</li> | 	</li> | ||||||
| 	<li> | 	<li> | ||||||
|   <b><%= t('announcement.最後修改時間') %></b> |   <b><%= t('announcement.最後修改時間') %></b> | ||||||
|   <%= @bulletin.updated_at %> |   <%= @bulletin.updated_at.strftime("%Y-%m-%d %H:%I:%S") %> | ||||||
| 	</li> | 	</li> | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue