add tags
This commit is contained in:
parent
6b551defce
commit
778a85ca2b
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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 )
|
||||
|
||||
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 )
|
||||
|
||||
elsif search.to_s.size > 0 and category_id.to_s.size < 1
|
||||
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
key = /#{search}/
|
||||
|
||||
find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
|
||||
else
|
||||
|
||||
find(:all).desc( :is_top, :postdate)
|
||||
|
||||
end
|
||||
|
||||
|
||||
find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
|
||||
else
|
||||
|
||||
find(:all).desc( :is_top, :postdate)
|
||||
|
||||
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
|
||||
|
@ -94,7 +94,7 @@ class Bulletin
|
|||
def title
|
||||
@title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
|
||||
end
|
||||
|
||||
|
||||
def subtitle
|
||||
@subtitle ||= I18nVariable.first(:conditions => {:key => 'subtitle', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<%= t('announcement.刪除已上傳檔案') %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :title %>
|
||||
<%= f.fields_for :title, (@bulletin.new_record? ? @bulletin.build_title : @bulletin.title ) do |f| %>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue