Remove i18n_variable for news

This commit is contained in:
Christophe Vilayphiou 2012-07-26 03:37:07 +08:00
parent 875fad848c
commit e33afc0822
34 changed files with 134 additions and 192 deletions

View File

@ -78,6 +78,69 @@ namespace :migrate do
end end
p 'End UnitListForAnc' p 'End UnitListForAnc'
p '====================================================='
p '====================================================='
p 'Start NewsBulletin'
news_bulletins = NewsBulletin.admin_manager_all
i = 1
news_bulletins.each do |news_bulletin|
p "#{i}/#{news_bulletins.size} - #{news_bulletin.id}"
title = I18nVariable.first(:conditions => {:key => 'title', :language_value_id => news_bulletin.id, :language_value_type => news_bulletin.class})
news_bulletin.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
subtitle = I18nVariable.first(:conditions => {:key => 'subtitle', :language_value_id => news_bulletin.id, :language_value_type => news_bulletin.class})
news_bulletin.subtitle_translations = {'en' => subtitle['en'], 'zh_tw' => subtitle['zh_tw']} if subtitle
text = I18nVariable.first(:conditions => {:key => 'text', :language_value_id => news_bulletin.id, :language_value_type => news_bulletin.class})
news_bulletin.text_translations = {'en' => text['en'], 'zh_tw' => text['zh_tw']} if text
news_bulletin.save(:validate => false)
i += 1
end
p 'End NewsBulletin'
p '====================================================='
p 'Start NewsBulletinCategory'
categories = NewsBulletinCategory.admin_manager_all
i = 1
categories.each do |category|
p "#{i}/#{categories.size} - #{category.id}"
title = I18nVariable.first(:conditions => {:language_value_id => category.id, :language_value_type => category.class})
category.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
category.save(:validate => false)
i += 1
end
p 'End NewsBulletinCategory'
p '====================================================='
p 'Start NewsBulletinFile'
files = NewsBulletinFile.all
i = 1
files.each do |file|
p "#{i}/#{files.size} - #{file.id}"
description = I18nVariable.first(:conditions => {:language_value_id => file.id, :language_value_type => file.class})
file.description_translations = {'en' => description['en'], 'zh_tw' => description['zh_tw']} if description
title = I18nVariable.first(:conditions => {:language_value_id => file.id, :language_value_type => file.class})
file.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
file.save(:validate => false)
i += 1
end
p 'End NewsBulletinFile'
p '====================================================='
p 'Start NewsBulletinLink'
links = NewsBulletinLink.all
i = 1
links.each do |link|
p "#{i}/#{links.size} - #{link.id}"
title = I18nVariable.first(:conditions => {:language_value_id => link.id, :language_value_type => link.class})
link.title_translations = {'en' => title['en'], 'zh_tw' => title['zh_tw']} if title
link.save(:validate => false)
i += 1
end
p 'End NewsBulletinLink'
end end
end end

View File

@ -26,7 +26,7 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
def setting def setting
@sys_users = User.all(conditions: {admin: false}).includes(:avatar) @sys_users = User.all(conditions: {admin: false}).includes(:avatar)
@news_bulletin_categorys = NewsBulletinCategory.all @news_bulletin_categorys = NewsBulletinCategory.all
@options_from_collection_for_select_news_bulletin_categorys = @news_bulletin_categorys.collect{|bc| [bc.i18n_variable[I18n.locale],bc.id] } @options_from_collection_for_select_news_bulletin_categorys = @news_bulletin_categorys.collect{|bc| [bc.title,bc.id] }
if params.has_key? :news_category if params.has_key? :news_category
@news_bulletin_categorys = NewsBulletinCategory.find params[:news_category][:id] @news_bulletin_categorys = NewsBulletinCategory.find params[:news_category][:id]
else else

View File

@ -14,9 +14,9 @@ module Panel::News::BackEnd::NewsBulletinsHelper
def show_news_bulletin_title_at_index (news_bulletin) def show_news_bulletin_title_at_index (news_bulletin)
if news_bulletin.is_checked? if news_bulletin.is_checked?
link_to news_bulletin.title[I18n.locale], panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => news_bulletin.news_bulletin_category.id) rescue '' link_to news_bulletin.title, panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => news_bulletin.news_bulletin_category.id) rescue ''
else else
news_bulletin.title[I18n.locale] news_bulletin.title
end end
end end

View File

@ -18,9 +18,9 @@ class NewsBulletin
is_impressionable :counter_cache => { :column_name => :view_count } is_impressionable :counter_cache => { :column_name => :view_count }
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy field :title, localize: true
has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy field :subtitle, localize: true
has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy field :text, localize: true
has_and_belongs_to_many :tags, :class_name => "NewsTag" has_and_belongs_to_many :tags, :class_name => "NewsTag"
field :postdate , :type => DateTime field :postdate , :type => DateTime
@ -59,7 +59,7 @@ class NewsBulletin
validates_presence_of :title validates_presence_of :title
before_save :set_key, :update_status before_save :update_status
after_save :save_news_bulletin_links after_save :save_news_bulletin_links
after_save :save_news_bulletin_files after_save :save_news_bulletin_files
@ -182,19 +182,6 @@ class NewsBulletin
end end
end end
end end
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
def text
@text ||= I18nVariable.first(:conditions => {:key => 'text', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
def self.filter(news_bulletins) def self.filter(news_bulletins)
news_bulletins.each do |news_bulletin| news_bulletins.each do |news_bulletin|
@ -208,18 +195,6 @@ class NewsBulletin
end end
protected protected
def set_key
if title && title.new_record?
title.key = 'title'
end
if subtitle && subtitle.new_record?
subtitle.key = 'subtitle'
end
if text && text.new_record?
text.key = 'text'
end
end
def update_status def update_status
if !self.is_pending if !self.is_pending

View File

@ -16,11 +16,11 @@ class NewsBulletinCategory
field :key field :key
field :display field :display
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy field :title, localize: true
has_many :news_bulletins has_many :news_bulletins
def pp_object def pp_object
i18n_variable[I18n.locale] title
end end
def self.from_id(id) def self.from_id(id)

View File

@ -5,36 +5,13 @@ class NewsBulletinFile
mount_uploader :file, AssetUploader mount_uploader :file, AssetUploader
# field :filetitle field :title, localize: true
# field :description field :description, localize: true
has_one :filetitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :description, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
# field :to_save, :type => Boolean # field :to_save, :type => Boolean
field :should_destroy, :type => Boolean field :should_destroy, :type => Boolean
belongs_to :news_bulletin belongs_to :news_bulletin
# embedded_in :news_bulletin # embedded_in :news_bulletin
before_save :set_key
def filetitle
@filetitle ||= I18nVariable.first(:conditions => {:key => 'filetitle', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
def description
@description ||= I18nVariable.first(:conditions => {:key => 'description', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
protected
def set_key
if filetitle && filetitle.new_record?
filetitle.key = 'filetitle'
end
if description && description.new_record?
description.key = 'description'
end
end
end end

View File

@ -4,12 +4,9 @@ class NewsBulletinLink
include Mongoid::Timestamps include Mongoid::Timestamps
field :url field :url
# field :name field :title, localize: true
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
field :should_destroy, :type => Boolean field :should_destroy, :type => Boolean
# embedded_in :news_bulletin
belongs_to :news_bulletin belongs_to :news_bulletin
end end

View File

@ -3,7 +3,7 @@ class NewsTag < Tag
has_and_belongs_to_many :news_bulletins has_and_belongs_to_many :news_bulletins
def get_visible_news_bulletins(sort = :name) def get_visible_news_bulletins(sort = :title)
date_now = Time.now date_now = Time.now
self.news_bulletins.where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort) self.news_bulletins.where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort)
end end

View File

@ -2,14 +2,9 @@
<%= stylesheet_link_tag "inc/permission-checkbox" %> <%= stylesheet_link_tag "inc/permission-checkbox" %>
<% end %> <% end %>
<% content_for :page_specific_javascript do %> <% content_for :page_specific_javascript do %>
<<<<<<< HEAD
<%= javascript_include_tag "bootstrap" %> <%= javascript_include_tag "bootstrap" %>
<%#= javascript_include_tag "inc/permission-checkbox" %>
<%#= javascript_include_tag "inc/search" %>
=======
<%= javascript_include_tag "inc/permission-checkbox" %> <%= javascript_include_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/search" %> <%= javascript_include_tag "inc/search" %>
>>>>>>> 291d5e3a03ba7da62ceb5e3b18012f0c9198dfba
<% end %> <% end %>
<%#= label_tag :fact_check_setting, t("news.news_bulletin.fact_check_setting") %> <%#= label_tag :fact_check_setting, t("news.news_bulletin.fact_check_setting") %>
<%= form_tag('', :remote => true) %> <%= form_tag('', :remote => true) %>

View File

@ -1,15 +0,0 @@
<h1><%= news_bulletin_category.key %></h1>
<table>
<tr>
<th><%= t('news_bulletin.status') %></th>
<th><%= t('news_bulletin.category') %></th>
<th><%= t('news_bulletin.title') %></th>
<th><%= t('news_bulletin.postdate') %></th>
<th><%= t('news_bulletin.deadline') %></th>
<th><%= t('news_bulletin.action') %></th>
</tr>
<% news_bulletin_category.news_bulletins.each do |post| %>
<%= render :partial => 'panel/news/back_end/news_bulletins/news_bulletins', :locals => {:post => post,:approval_allow=>true} %>
<% end %>
</table>

View File

@ -1,50 +0,0 @@
<%= render 'panel/news/back_end/news_bulletins/filter' %>
<table id="bulettin_sort_list" class="table main-list">
<%= render 'panel/news/back_end/news_bulletins/news_bulletins' %>
</table>
<div class="form-actions">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_news_back_end_news_bulletin_path, :class => 'btn btn-primary' %>
</div>
<!--
<% content_for :secondary do %>
<%#= render :partial => '/panel/news/back_end/news_secondary' %>
<% end -%>
<%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<fieldset><legend><%= t('news_bulletin.search') %></legend>
<%= form_for :news_bulletin, :action => 'search', :method => 'get', :url => panel_news_back_end_news_bulletins_path do |f| %>
<%#= f.select :news_bulletin_category_id, @news_bulletin_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ] },{ :include_blank => t('news_bulletin.select') }%>
Category <%#= select_tag "category_id", options_for_select(@news_bulletin_categorys.collect{|t| [t.i18n_variable[I18n.locale], t.id]}), :prompt => t('news_bulletin.select') %>
KeyWord <%#= text_field_tag :search, params[:search], :id => 'search_field' %>
<%= submit_tag "Search", :name => nil %>
<% end %>
</fieldset>
<br />
<br />
<h1><%= t('news_bulletin.list_news') %></h1>
<div id="check_block">
<h1>Check Please</h1>
<%#= render :partial => "list_table", :collection => @news_bulletin_categorys_check,:as => :news_bulletin_category%>
</div>
<br />
-->

View File

@ -10,12 +10,12 @@
</div> </div>
<div id="widget-title"> <div id="widget-title">
<%= f.fields_for :i18n_variable, (@news_bulletin_category.new_record? ? @news_bulletin_category.build_i18n_variable : @news_bulletin_category.i18n_variable) do |f| %> <%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> <%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge' %> <%= f.text_field locale, :class => 'input-xxlarge', :value => (@news_bulletin_category.title_translations[locale] rescue nil) %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@ -15,6 +15,6 @@
</div> </div>
</td> </td>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<td><%= news_bulletin_category.i18n_variable[locale] rescue nil %></td> <td><%= news_bulletin_category.title_translations[locale] rescue nil %></td>
<% end %> <% end %>
</tr> </tr>

View File

@ -7,12 +7,12 @@
<%= f.text_field :key %> <%= f.text_field :key %>
</div> </div>
<div id="widget-title"> <div id="widget-title">
<%= f.fields_for :i18n_variable, news_bulletin_category.i18n_variable do |f| %> <%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> <%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge' %> <%= f.text_field locale, :class => 'input-xxlarge', :value => (news_bulletin_category.title_translations[locale] rescue nil) %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@ -11,7 +11,7 @@
<%= f.file_field :file %> <%= f.file_field :file %>
<%= f.label :file_title %> <%= f.label :file_title %>
<%= f.text_field :filetitle %> <%= f.text_field :title %>
<%= f.label :file_description %> <%= f.label :file_description %>
<%= f.text_field :description %> <%= f.text_field :description %>

View File

@ -1,6 +1,6 @@
<div class="accordion-inner" data-toggle="buttons-checkbox"> <div class="accordion-inner" data-toggle="buttons-checkbox">
<% @news_bulletin_categories.each do |category| -%> <% @news_bulletin_categories.each do |category| -%>
<%= link_to category.i18n_variable[I18n.locale], panel_news_back_end_news_bulletins_path(:filter => @filter, :new_filter => {:type => 'categories', :id => category.id}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn js_history#{is_filter_active?('categories', category.id)}" %> <%= link_to category.title, panel_news_back_end_news_bulletins_path(:filter => @filter, :new_filter => {:type => 'categories', :id => category.id}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn js_history#{is_filter_active?('categories', category.id)}" %>
<% end -%> <% end -%>
</div> </div>
<%= render :partial => 'clear_filters', :locals => {:type => 'categories'} %> <%= render :partial => 'clear_filters', :locals => {:type => 'categories'} %>

View File

@ -119,10 +119,10 @@
<div id="post-body-content" class="clear"> <div id="post-body-content" class="clear">
<%= f.label :unit_list_for_anc,t('news.news_bulletin.unit_name')%> <%= f.label :unit_list_for_anc,t('news.news_bulletin.unit_name')%>
<%= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title[I18n.locale], t.id ]}, {:prompt => t("news.news_bulletin.ut_prompt")}, :class => "input-medium" %> <%= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title, t.id ]}, {:prompt => t("news.news_bulletin.ut_prompt")}, :class => "input-medium" %>
<%= f.label :category,t('news.news_bulletin.category') %> <%= f.label :category,t('news.news_bulletin.category') %>
<%= f.select :news_bulletin_category_id, @news_bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %> <%= f.select :news_bulletin_category_id, @news_bulletin_categorys.collect{|t| [ t.title, t.id ]}, {}, :class => "input-medium" %>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<%# @site_valid_locales.each_with_index do |locale, i| %> <%# @site_valid_locales.each_with_index do |locale, i| %>
@ -140,25 +140,25 @@
<div class="title"> <div class="title">
<%= f.label :title, t('news.news_bulletin.title')%> <%= f.label :title, t('news.news_bulletin.title')%>
<%= f.fields_for :title, (@news_bulletin.new_record? ? @news_bulletin.build_title : @news_bulletin.title ) do |f| %> <%= f.fields_for :title_translations do |f| %>
<%= I18nVariable.from_locale(locale) %> <%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title' %> <%= f.text_field locale, :class=>'post-title', :value => (@news_bulletin.title_translations[locale] rescue nil) %>
<% end %> <% end %>
</div> </div>
<div class="editor"> <div class="editor">
<%= f.label :subtitle, t('news.news_bulletin.subtitle') %> <%= f.label :subtitle, t('news.news_bulletin.subtitle') %>
<%= f.fields_for :subtitle, (@news_bulletin.new_record? ? @news_bulletin.build_subtitle : @news_bulletin.subtitle ) do |f| %> <%= f.fields_for :subtitle_translations do |f| %>
<%= I18nVariable.from_locale(locale) %> <%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %> <%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea', :value => (@news_bulletin.subtitle_translations[locale] rescue nil) %>
<% end %> <% end %>
</div> </div>
<div class="editor"> <div class="editor">
<%= f.label :text, t('news.news_bulletin.text') %> <%= f.label :text, t('news.news_bulletin.text') %>
<%= f.fields_for :text, (@news_bulletin.new_record? ? @news_bulletin.build_text : @news_bulletin.text ) do |f| %> <%= f.fields_for :text_translations do |f| %>
<%= I18nVariable.from_locale(locale) %> <%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %> <%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea', :value => (@news_bulletin.text_translations[locale] rescue nil) %>
<% end %> <% end %>
</div> </div>

View File

@ -16,11 +16,11 @@
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>"> <div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<%= f.fields_for :filetitle, (form_news_bulletin_file.new_record? ? form_news_bulletin_file.build_filetitle : form_news_bulletin_file.filetitle ) do |f| %> <%= f.fields_for :title_translations do |f| %>
<div class="control-group"> <div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label> <label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :id => "link-#{locale}" %> <%= f.text_field locale, :id => "link-#{locale}", :value => (form_news_bulletin_file.title_translations[locale] rescue nil) %>
</div> </div>
</div> </div>
<% end %> <% end %>
@ -40,11 +40,11 @@
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>"> <div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<%= f.fields_for :description, (form_news_bulletin_file.new_record? ? form_news_bulletin_file.build_description : form_news_bulletin_file.description ) do |f| %> <%= f.fields_for :description_translations do |f| %>
<div class="control-group"> <div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label> <label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :id => "link-#{locale}" %> <%= f.text_field locale, :id => "link-#{locale}", :value => (form_news_bulletin_file.description_translations[locale] rescue nil) %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@ -17,11 +17,11 @@
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>"> <div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<%= f.fields_for :i18n_variable, (form_news_bulletin_link.new_record? ? form_news_bulletin_link.build_i18n_variable : form_news_bulletin_link.i18n_variable) do |f| %> <%= f.fields_for :title_translations do |f| %>
<div class="control-group"> <div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label> <label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %> <%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge", :value => (form_news_bulletin_link.title_translations[locale] rescue nil) %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@ -1,7 +1,7 @@
<tr id="<%= dom_id list_news_bulletin_file %>"> <tr id="<%= dom_id list_news_bulletin_file %>">
<td><%= list_news_bulletin_file.file.file ? ( link_to list_news_bulletin_file.filetitle.zh_tw, list_news_bulletin_file.file.url, {:target => '_blank', :title => list_news_bulletin_file.description.zh_tw} ) : list_news_bulletin_file.filetitle.zh_tw %></td> <td><%= list_news_bulletin_file.file.file ? ( link_to list_news_bulletin_file.title_translations['zh_tw'], list_news_bulletin_file.file.url, {:target => '_blank', :title => list_news_bulletin_file.description_translations['zh_tw']} ) : list_news_bulletin_file.title_translations['zh_tw'] %></td>
<td><%= list_news_bulletin_file.file.file ? ( link_to list_news_bulletin_file.filetitle.en, list_news_bulletin_file.file.url, {:target => '_blank', :title => list_news_bulletin_file.description.en} ) : list_news_bulletin_file.filetitle.en %></td> <td><%= list_news_bulletin_file.file.file ? ( link_to list_news_bulletin_file.title_translations['en'], list_news_bulletin_file.file.url, {:target => '_blank', :title => list_news_bulletin_file.description_translations['en']} ) : list_news_bulletin_file.title_translations['en'] %></td>
<td> <td>
<a href="<%= panel_news_back_end_news_bulletin_file_quick_edit_path(list_news_bulletin_file) %>#modal-file" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a> <a href="<%= panel_news_back_end_news_bulletin_file_quick_edit_path(list_news_bulletin_file) %>#modal-file" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a>
<span class="action"> <span class="action">

View File

@ -1,6 +1,6 @@
<tr id="<%= dom_id list_news_bulletin_link %>"> <tr id="<%= dom_id list_news_bulletin_link %>">
<td><%= link_to list_news_bulletin_link.i18n_variable.zh_tw, list_news_bulletin_link.url, :target => '_blank' %></td> <td><%= link_to list_news_bulletin_link.title_translations['zh_tw'], list_news_bulletin_link.url, :target => '_blank' %></td>
<td><%= link_to list_news_bulletin_link.i18n_variable.en, list_news_bulletin_link.url, :target => '_blank' %></td> <td><%= link_to list_news_bulletin_link.title_translations['en'], list_news_bulletin_link.url, :target => '_blank' %></td>
<td> <td>
<a href="<%= panel_news_back_end_news_bulletin_link_quick_edit_path(list_news_bulletin_link) %>#modal-link" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a> <a href="<%= panel_news_back_end_news_bulletin_link_quick_edit_path(list_news_bulletin_link) %>#modal-link" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a>
<span class="action"> <span class="action">

View File

@ -28,7 +28,7 @@
</div> </div>
</div> </div>
</td> </td>
<td><%= news_bulletin.news_bulletin_category.i18n_variable[I18n.locale] rescue nil %></td> <td><%= news_bulletin.news_bulletin_category.title rescue nil %></td>
<td> <%= show_news_bulletin_title_at_index news_bulletin%> <td> <%= show_news_bulletin_title_at_index news_bulletin%>
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills hide"> <ul class="nav nav-pills hide">

View File

@ -13,23 +13,23 @@
</div> </div>
</div> </div>
<%= f.fields_for :filetitle, (@news_bulletin_file.new_record? ? @news_bulletin_file.build_filetitle : @news_bulletin_file.filetitle ) do |f| %> <%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<label for="file-<%= locale %>" class="control-label">Name <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label> <label for="file-<%= locale %>" class="control-label">Name <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :id => "file-#{locale}", :class => "input-xlarge" %> <%= f.text_field locale, :id => "file-#{locale}", :class => "input-xlarge", :value => (@news_bulletin_file.title_translations[locale] rescue nil) %>
</div> </div>
</div> </div>
<% end %> <% end %>
<% end %> <% end %>
<%= f.fields_for :description, (@news_bulletin_file.new_record? ? @news_bulletin_file.build_description : @news_bulletin_file.description ) do |f| %> <%= f.fields_for :description_translations do |f| %>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<label for="file-<%= locale %>" class="control-label">Description <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label> <label for="file-<%= locale %>" class="control-label">Description <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :id => "file-#{locale}", :class => "input-xlarge" %> <%= f.text_field locale, :id => "file-#{locale}", :class => "input-xlarge", :value => (@news_bulletin_file.description_translations[locale] rescue nil) %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@ -14,13 +14,13 @@
</div> </div>
</div> </div>
<%= f.fields_for :i18n_variable, (@news_bulletin_link.new_record? ? @news_bulletin_link.build_i18n_variable : @news_bulletin_link.i18n_variable) do |f| %> <%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<%= label_tag "link-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> <%= label_tag "link-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls"> <div class="controls">
<%#= f.text_field locale, :class => 'input-xxlarge' %> <%#= f.text_field locale, :class => 'input-xxlarge' %>
<%= f.text_field locale %> <%= f.text_field locale, :value => (@news_bulletin_link.title_translations[locale] rescue nil) %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@ -3,18 +3,18 @@
<div class="control-group"> <div class="control-group">
<label class="control-label"><%= t(:category) %></label> <label class="control-label"><%= t(:category) %></label>
<div class="controls"> <div class="controls">
<%= f.select :news_bulletin_category_id, @news_bulletin_categories.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => 'input-large' %> <%= f.select :news_bulletin_category_id, @news_bulletin_categories.collect {|t| [ t.title, t.id ]}, {}, :class => 'input-large' %>
</div> </div>
</div> </div>
</div> </div>
<div id="widget-title"> <div id="widget-title">
<%= f.fields_for :title, news_bulletin.title do |f| %> <%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> <%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge' %> <%= f.text_field locale, :class => 'input-xxlarge', :value => (news_bulletin.title_translations[locale] rescue nil) %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@ -1,7 +1,7 @@
<ul> <ul>
<li> <li>
<b><%= t('news.category') %></b> <b><%= t('news.category') %></b>
<%= @news_bulletin.news_bulletin_category.i18n_variable[I18n.locale] rescue nil %> <%= @news_bulletin.news_bulletin_category.title rescue nil %>
</li> </li>
<li> <li>
<b><%= t('news.postdate') %></b> <b><%= t('news.postdate') %></b>
@ -9,7 +9,7 @@
</li> </li>
<li> <li>
<b><%= t('news.title') %></b> <b><%= t('news.title') %></b>
<%= @news_bulletin.title[I18n.locale] %> <%= @news_bulletin.title %>
</li> </li>
<li> <li>
<%#= image_tag(@news_bulletin.image.url, :size => "320x240") if @news_bulletin.image.file %> <%#= image_tag(@news_bulletin.image.url, :size => "320x240") if @news_bulletin.image.file %>
@ -17,23 +17,23 @@
</li> </li>
<li> <li>
<b><%= t('news.subtitle') %></b> <b><%= t('news.subtitle') %></b>
<%= @news_bulletin.subtitle[I18n.locale].html_safe %> <%= @news_bulletin.subtitle.html_safe %>
</li> </li>
<li> <li>
<b><%= t('news.text') %></b> <b><%= t('news.text') %></b>
<%= @news_bulletin.text[I18n.locale].html_safe %> <%= @news_bulletin.text.html_safe %>
</li> </li>
<li> <li>
<li> <li>
<b><%= t('news.link') %></b> <b><%= t('news.link') %></b>
<% @news_bulletin.news_bulletin_links.each do | blink | %> <% @news_bulletin.news_bulletin_links.each do | blink | %>
<%= link_to blink.i18n_variable[I18n.locale], blink.url, :target => '_blank' %> <%= link_to blink.title, blink.url, :target => '_blank' %>
<% end %> <% end %>
</li> </li>
<li> <li>
<b><%= t('news.file') %></b> <b><%= t('news.file') %></b>
<% @news_bulletin.news_bulletin_files.each do | bfile | %> <% @news_bulletin.news_bulletin_files.each do | bfile | %>
<%= link_to bfile.filetitle[I18n.locale], bfile.file.url, {:target => '_blank', :title => bfile.description[I18n.locale]} if bfile.file.file %> <%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
<% end %> <% end %>
</li> </li>
<li> <li>

View File

@ -3,7 +3,7 @@
<%= flash_messages %> <%= flash_messages %>
<% if @current_category %> <% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] %></h1> <h1 class="h1"><%= @current_category.title %></h1>
<% else %> <% else %>
<h1 class="h1"><%= t('news.news') %></h1> <h1 class="h1"><%= t('news.news') %></h1>
<% end %> <% end %>
@ -19,8 +19,8 @@
<tr> <tr>
<td><%= image_tag post.image rescue nil %></td> <td><%= image_tag post.image rescue nil %></td>
<td> <td>
<%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %> <%= link_to post.title, panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %>
<%= post.subtitle[I18n.locale].html_safe %> <%= post.subtitle.html_safe %>
</td> </td>
<td><%= display_date(post.postdate) %></td> <td><%= display_date(post.postdate) %></td>
</tr> </tr>

View File

@ -1,10 +1,10 @@
<% # encoding: utf-8 %> <% # encoding: utf-8 %>
<h1 class="h1"><%= @news_bulletin.title[I18n.locale] %></h1> <h1 class="h1"><%= @news_bulletin.title %></h1>
<div class="info"> <div class="info">
<div class="info1"> <div class="info1">
<span class="pull-right"><%= dislpay_view_count(@news_bulletin) %></span> <span class="pull-right"><%= dislpay_view_count(@news_bulletin) %></span>
<span class="date"><%= display_date(@news_bulletin.postdate) %></span> <span class="date"><%= display_date(@news_bulletin.postdate) %></span>
<% unit = @news_bulletin.unit_list_for_anc.title[I18n.locale] rescue nil %> <% unit = @news_bulletin.unit_list_for_anc.title rescue nil %>
<%= " | " if unit %> <%= " | " if unit %>
<a href="" class="unit"><%= unit %></a> <a href="" class="unit"><%= unit %></a>
</div> </div>
@ -14,7 +14,7 @@
<%= link_to image_tag(@news_bulletin.image.url, :size => "320x240"), @news_bulletin.image.url, {:target => '_blank', :title => @news_bulletin.image_identifier} if @news_bulletin.image.file %> <%= link_to image_tag(@news_bulletin.image.url, :size => "320x240"), @news_bulletin.image.url, {:target => '_blank', :title => @news_bulletin.image_identifier} if @news_bulletin.image.file %>
</div> </div>
<div class="news_paragraph"> <div class="news_paragraph">
<%= @news_bulletin.text[I18n.locale].html_safe %> <%= @news_bulletin.text.html_safe %>
</div> </div>
<div class="linkAndFile"> <div class="linkAndFile">
<% if @news_bulletin.news_bulletin_links.size > 0 %> <% if @news_bulletin.news_bulletin_links.size > 0 %>
@ -22,7 +22,7 @@
<i class="icons-link"></i> <i class="icons-link"></i>
<div class="showLink"> <div class="showLink">
<% @news_bulletin.news_bulletin_links.each do | blink | %> <% @news_bulletin.news_bulletin_links.each do | blink | %>
<%= link_to blink.i18n_variable[I18n.locale], blink.url, :target => '_blank' %> <%= link_to blink.title, blink.url, :target => '_blank' %>
<% end %> <% end %>
</div> </div>
</div> </div>
@ -32,7 +32,7 @@
<i class="icons-paperclip"></i> <i class="icons-paperclip"></i>
<div class="showFile"> <div class="showFile">
<% @news_bulletin.news_bulletin_files.each do | bfile | %> <% @news_bulletin.news_bulletin_files.each do | bfile | %>
<%= link_to bfile.filetitle[I18n.locale], bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %> <%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@ -15,8 +15,8 @@
<tr> <tr>
<td><%= image_tag post.image %></td> <td><%= image_tag post.image %></td>
<td> <td>
<%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %> <%= link_to post.title, panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %>
<%= post.subtitle[I18n.locale].html_safe %> <%= post.subtitle.html_safe %>
</td> </td>
<td><%= display_date(post.postdate) %></td> <td><%= display_date(post.postdate) %></td>
</tr> </tr>

View File

@ -1,6 +1,6 @@
<% @news_bulletins.each do |news_bulletin| %> <% @news_bulletins.each do |news_bulletin| %>
<li> <li>
<%= link_to news_bulletin.title[I18n.locale], panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => news_bulletin.news_bulletin_category_id) %> <%= link_to news_bulletin.title, panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => news_bulletin.news_bulletin_category_id) %>
</li> </li>
<% end %> <% end %>

View File

@ -1,6 +1,6 @@
<% @web_links.each do |web_link| %> <% @web_links.each do |web_link| %>
<li> <li>
<%= link_to web_link.name[I18n.locale], web_link.url %> <%= link_to web_link.title, web_link.url %>
</li> </li>
<% end %> <% end %>

View File

@ -9,7 +9,7 @@
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<% @news_bulletin_categorys.each do |category| %> <% @news_bulletin_categorys.each do |category| %>
<li> <li>
<%= link_to category.i18n_variable[I18n.locale], panel_news_front_end_news_bulletins_path(:category_id => category.id) %> <%= link_to category.title, panel_news_front_end_news_bulletins_path(:category_id => category.id) %>
</li> </li>
<% end %> <% end %>
</ul> </ul>
@ -20,8 +20,8 @@
<% @news_bulletins.each do |post| %> <% @news_bulletins.each do |post| %>
<li> <li>
<div class="news_img"><%= image_tag(post.image.url, :size => "290x130") if post.image.file %></div> <div class="news_img"><%= image_tag(post.image.url, :size => "290x130") if post.image.file %></div>
<h3 class="h3 news_title"><%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post, :category_id => post.news_bulletin_category_id) %></h3> <h3 class="h3 news_title"><%= link_to post.title, panel_news_front_end_news_bulletin_path(post, :category_id => post.news_bulletin_category_id) %></h3>
<p class="news_wrap"><%= post.subtitle[I18n.locale].html_safe %></p> <p class="news_wrap"><%= post.subtitle.html_safe %></p>
</li> </li>
<% end %> <% end %>
</ul> </ul>

View File

@ -17,7 +17,7 @@
<div class="news_next">next</div> <div class="news_next">next</div>
<ul class="news_list"> <ul class="news_list">
<% tag.news_bulletins.each do |post| %> <% tag.news_bulletins.each do |post| %>
<li><%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post) %></li> <li><%= link_to post.title, panel_news_front_end_news_bulletin_path(post) %></li>
<% end %> <% end %>
</ul> </ul>
</div> </div>

View File

@ -4,7 +4,7 @@
<ul class="list"> <ul class="list">
<% @news_bulletin_categorys.each do |category| %> <% @news_bulletin_categorys.each do |category| %>
<li class="<%= category.id.to_s.eql?(params[:category_id]) ? 'active' : nil %>"> <li class="<%= category.id.to_s.eql?(params[:category_id]) ? 'active' : nil %>">
<%= link_to category.i18n_variable[I18n.locale], panel_news_front_end_news_bulletins_path(:category_id => category.id) %> <%= link_to category.title, panel_news_front_end_news_bulletins_path(:category_id => category.id) %>
</li> </li>
<% end %> <% end %>
</ul> </ul>