Remove i18n_variable for page_content

This commit is contained in:
Christophe Vilayphiou 2012-07-26 03:47:14 +08:00
parent e33afc0822
commit 4a6b9fbe64
7 changed files with 26 additions and 11 deletions

View File

@ -141,6 +141,21 @@ namespace :migrate do
end end
p 'End NewsBulletinLink' p 'End NewsBulletinLink'
p '====================================================='
p '====================================================='
p 'Start PageContext'
page_contexts = PageContext.admin_manager_all
i = 1
page_contexts.each do |page_context|
p "#{i}/#{page_contexts.size} - #{page_context.id}"
context = I18nVariable.first(:conditions => {:language_value_id => page_context.id, :language_value_type => page_context.class})
page_context.context_translations = {'en' => context['en'], 'zh_tw' => context['zh_tw']} if context
page_context.save(:validate => false)
i += 1
end
p 'End PageContext'
end end
end end

View File

@ -9,7 +9,7 @@ class PageContext
is_impressionable :counter_cache => { :column_name => :view_count } is_impressionable :counter_cache => { :column_name => :view_count }
has_one :context, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy field :context, localize: true
field :create_user_id field :create_user_id
field :update_user_id field :update_user_id
@ -26,7 +26,7 @@ class PageContext
ObjectAuthTitlesOptions = %W{Edit} ObjectAuthTitlesOptions = %W{Edit}
def pp_object def pp_object
page.i18n_variable[I18n.locale] page.title
end end
def is_top? def is_top?

View File

@ -6,7 +6,7 @@
<div id="post-body-content"> <div id="post-body-content">
<div class="title"> <div class="title">
<%= f.label :name %> <%= f.label :name %>
<%= @page_context.page.i18n_variable[I18n.locale] %> <%= @page_context.page.title %>
</div> </div>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
@ -23,9 +23,9 @@
<div class="title"> <div class="title">
<%= f.label :context %> <%= f.label :context %>
<%= f.fields_for :context, (@page_context.new_record? ? @page_context.build_context : @page_context.context ) do |f| %> <%= f.fields_for :context_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 => (@page_context.context_translations[locale] rescue nil) %>
<% end %> <% end %>
</div> </div>

View File

@ -1,7 +1,7 @@
<tr id="<%= dom_id page_context %>" class="with_action"> <tr id="<%= dom_id page_context %>" class="with_action">
<td> <td>
<%= page_context.page.path %></br> <%= page_context.page.path %></br>
<%= page_context.page.i18n_variable[I18n.locale] %> <%= page_context.page.title %>
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills hide"> <ul class="nav nav-pills hide">
<%if is_manager? || is_admin? || page_context.authed_users(:edit).include?(current_user)%> <%if is_manager? || is_admin? || page_context.authed_users(:edit).include?(current_user)%>

View File

@ -2,7 +2,7 @@
<tr id="<%= dom_id view_page_context %>" class="with_action"> <tr id="<%= dom_id view_page_context %>" class="with_action">
<td> <td>
<%= view_page_context.page.i18n_variable[I18n.locale] %> <%= view_page_context.page.title %>
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills hide"> <ul class="nav nav-pills hide">
<li><%= link_to t('view_page_context.show'), panel_page_content_back_end_page_context_path(view_page_context) %></li> <li><%= link_to t('view_page_context.show'), panel_page_content_back_end_page_context_path(view_page_context) %></li>

View File

@ -9,11 +9,11 @@
<ul> <ul>
<li> <li>
<b><%= t('page_content.name') %></b> <b><%= t('page_content.name') %></b>
<%= @page_context.page.i18n_variable[I18n.locale] %> <%= @page_context.page.title %>
</li> </li>
<li> <li>
<b><%= t('page_content.context') %></b> <b><%= t('page_content.context') %></b>
<%= @page_context.context[I18n.locale].html_safe %> <%= @page_context.context.html_safe %>
</li> </li>
<li> <li>
<b><%= t('page_content.張貼者') %></b> <b><%= t('page_content.張貼者') %></b>

View File

@ -4,8 +4,8 @@
<p id="notice"><%= flash_messages %></p> <p id="notice"><%= flash_messages %></p>
<div class="view_count pull-right"><%= dislpay_view_count(@page_context) %></div> <div class="view_count pull-right"><%= dislpay_view_count(@page_context) %></div>
<h1 class="h1"><%= @page_context.page.i18n_variable[I18n.locale] rescue nil %></h1> <h1 class="h1"><%= @page_context.page.title rescue nil %></h1>
<div class="page_content"><%= @page_context.context[I18n.locale].html_safe rescue nil %></div> <div class="page_content"><%= @page_context.context.html_safe rescue nil %></div>