This commit is contained in:
unknown 2012-02-15 10:37:07 +08:00
parent 6b551defce
commit 778a85ca2b
7 changed files with 38 additions and 52 deletions

View File

@ -21,4 +21,8 @@ class I18nVariable
I18nVariable.first(:conditions => {:key => locale})[I18n.locale]
end
def self.from_locale(locale)
I18nVariable.first(:conditions => {:key => locale})[I18n.locale]
end
end

View File

@ -1,18 +0,0 @@
# encoding: utf-8
class Announcement
include Mongoid::Document
include Mongoid::Timestamps
field :category, :type => String
field :title, :type => String
field :subtitle, :type => String
field :text, :type => String
field :postdate , :type => Date
field :deadline , :type => Date
# embeds_many :comments
validates_presence_of :category, :title, :subtitle, :text
end

View File

@ -41,38 +41,38 @@ class Bulletin
def self.search( search = nil, category_id = nil )
if category_id.to_s.size > 0 and search.to_s.size > 0
if category_id.to_s.size > 0 and search.to_s.size > 0
key = /#{search}/
find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate )
find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate )
elsif category_id.to_s.size > 0 and search.to_s.size < 1
elsif category_id.to_s.size > 0 and search.to_s.size < 1
find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate )
find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate )
elsif search.to_s.size > 0 and category_id.to_s.size < 1
elsif search.to_s.size > 0 and category_id.to_s.size < 1
key = /#{search}/
find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
else
find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
else
find(:all).desc( :is_top, :postdate)
find(:all).desc( :is_top, :postdate)
end
end
end
def self.widget_datas
date_now = Time.now
date_now = Time.now
# 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)
# 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)
# where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate)
# 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)
end

View File

@ -18,7 +18,7 @@
<tr>
<td><%= post.postdate %></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[I18n.locale], panel_announcement_front_end_bulletin_path(post) %>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
</tr>

View File

@ -17,19 +17,19 @@
</li>
<li>
<b><%= t('announcement.title') %></b>
<%= @bulletin.title %>
<%= @bulletin.title[I18n.locale] %>
</li>
<li>
<%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %>
<%= link_to image_tag(@bulletin.image.url, :size => "320x240"), @bulletin.image.url, {:target => '_blank', :title => @bulletin.image_filename} if @bulletin.image.file %>
<%= link_to image_tag(@bulletin.image.url, :size => "320x240"), @bulletin.image.url, {:target => '_blank', :title => @bulletin.image_identifier} if @bulletin.image.file %>
</li>
<li>
<b><%= t('announcement.subtitle') %></b>
<%= @bulletin.subtitle %>
<%= @bulletin.subtitle[I18n.locale] %>
</li>
<li>
<b><%= t('announcement.text') %></b>
<%= @bulletin.text %>
<%= @bulletin.text[I18n.locale] %>
</li>
<li>
<li>
@ -54,4 +54,4 @@
</li>
<%= link_back %>
<%#= link_back %>

View File

@ -10,8 +10,8 @@
<% @bulletins.each do |post| %>
<li>
<div class="news_img"><%= image_tag(post.image.url, :size => "290x130") if post.image.file %></div>
<h3 class="h3 news_title"><%= post.title %></h3>
<p class="news_wrap"><%= post.subtitle %></p>
<h3 class="h3 news_title"><%= post.title[I18n.locale] %></h3>
<p class="news_wrap"><%= post.subtitle[I18n.locale] %></p>
</li>
<% end %>
</ul>