announcement widget page

This commit is contained in:
unknown 2012-01-20 16:36:25 +08:00
parent 2c8940e350
commit 68ad208777
4 changed files with 32 additions and 11 deletions

View File

@ -6,9 +6,12 @@ class Bulletin
include Mongoid::MultiParameterAttributes
# field :category_id, :type => Integer
field :title
field :subtitle
field :text
# field :title
has_one :title_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :subtitle_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :text_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
# field :subtitle
# field :text
field :postdate , :type => Date
field :deadline , :type => Date
field :url
@ -28,7 +31,7 @@ class Bulletin
accepts_nested_attributes_for :bulletin_files, :allow_destroy => true
validates_presence_of :title
validates_presence_of :title_variable
after_save :save_bulletin_files

View File

@ -18,17 +18,35 @@
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
<%#= f.text_field :title %>
<%= f.fields_for :title_variable, (@bulletin.new_record? ? @bulletin.build_title_variable : @bulletin.title_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= f.text_field locale, :style => "width:130px" %>
<% end %>
<% end %>
</div>
<div class="field">
<%= f.label :subtitle %><br />
<%= f.text_area :subtitle, :rows => 10, :cols => 40 %>
<%#= f.text_area :subtitle, :rows => 10, :cols => 40 %>
<%= f.fields_for :subtitle_variable, (@bulletin.new_record? ? @bulletin.build_subtitle_variable : @bulletin.subtitle_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= f.text_area locale, :rows => 10, :cols => 40 %>
<% end %>
<% end %>
</div>
<div class="field">
<%= f.label :text %><br />
<%= f.text_area :text, :rows => 10, :cols => 40 %>
<%#= f.text_area :text, :rows => 10, :cols => 40 %>
<%= f.fields_for :text_variable, (@bulletin.new_record? ? @bulletin.build_text_variable : @bulletin.text_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= f.text_area locale, :rows => 10, :cols => 40 %>
<% end %>
<% end %>
</div>
<div class="field">

View File

@ -60,7 +60,7 @@
<td><%= (post.deadline) ? post.deadline : t('bulletin.no_deadline') %></td>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td>
<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_variable[I18n.locale], panel_announcement_back_end_bulletin_path(post) %>
</td>
<td>
<%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(post) %> |

View File

@ -17,7 +17,7 @@
</li>
<li>
<b><%= t('announcement.title') %></b>
<%= @bulletin.title %>
<%= @bulletin.title_variable[I18n.locale] %>
</li>
<li>
<%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %>
@ -25,11 +25,11 @@
</li>
<li>
<b><%= t('announcement.subtitle') %></b>
<%= @bulletin.subtitle %>
<%= @bulletin.subtitle_variable[I18n.locale] %>
</li>
<li>
<b><%= t('announcement.text') %></b>
<%= @bulletin.text %>
<%= @bulletin.text_variable[I18n.locale] %>
</li>
<li>
<li>