Copy changes into news after merge

This commit is contained in:
Christophe Vilayphiou 2012-05-04 18:49:07 +08:00
parent 15bc4d4268
commit e9b337a385
17 changed files with 210 additions and 77 deletions

View File

@ -3,6 +3,7 @@
<% if (bulletin.create_user_id == current_user.id) || is_manager? %>
<%= check_box_tag 'to_delete[]', bulletin.id, false, :class => "checkbox_in_list" %>
<% end -%>
</td>
<td>
<div class="label-group">
<div class="label-td">
@ -35,26 +36,26 @@
<ul class="nav nav-pills hide">
<% if (bulletin.create_user_id == current_user.id) || is_manager? %>
<% if current_user.admin? || (!bulletin.is_rejected? && !bulletin.is_checked?) %>
<li><%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><%= link_to t(:basic), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'basic'), :remote => true %></li>
<li><%= link_to t(:picture), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'picture'), :remote => true %></li>
<li><%= link_to t(:tags), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'tags'), :remote => true %></li>
<li><%= link_to t(:link), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'links'), :remote => true %></li>
<li><%= link_to t(:file), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'files'), :remote => true %></li>
</ul>
</li>
<%#= debugger %>
<%#= a=1 %>
<% end %>
<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<% if current_user.admin? || (!bulletin.is_rejected? && !bulletin.is_checked?) %>
<li><%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><%= link_to t(:basic), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'basic'), :remote => true %></li>
<li><%= link_to t(:picture), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'picture'), :remote => true %></li>
<li><%= link_to t(:tags), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'tags'), :remote => true %></li>
<li><%= link_to t(:link), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'links'), :remote => true %></li>
<li><%= link_to t(:file), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'files'), :remote => true %></li>
</ul>
</li>
<%#= debugger %>
<%#= a=1 %>
<% end %>
<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<% end -%>
<% if show_approval_link(bulletin) %>
<li><%= link_to t('announcement.bulletin.approval'), panel_announcement_back_end_bulletin_approval_preview_path(bulletin),:class => 'preview_trigger' %></li><%#= #TODO add ancher so user can quick access into that part %>
<li><%= link_to t('announcement.bulletin.approval'), panel_announcement_back_end_bulletin_approval_preview_path(bulletin),:class => 'preview_trigger' %></li><%#= #TODO add ancher so user can quick access into that part %>
<% end %>
</ul>
</div>

View File

@ -1,7 +1,16 @@
class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
before_filter :authenticate_user!
before_filter :is_admin?
include AdminHelper
def preview_and_approve
@bulletin = NewsBulletin.find params[:bulletin_id]
end
def approve
end
def setting
@news_bulletin_categorys = NewsBulletinCategory.all
if params.has_key?(:category_id)

View File

@ -1,5 +1,8 @@
class Panel::News::BackEnd::NewsBulletinCategorysController < OrbitBackendController
before_filter :for_app_manager,:except => [:index]
def index
@news_bulletin_categorys = NewsBulletinCategory.all
@news_bulletin_category = NewsBulletinCategory.new(:display => 'List')

View File

@ -1,7 +1,10 @@
class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
before_filter :authenticate_user!
before_filter :is_admin?
# before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_news_bulletins]
def index
# @news_bulletins = NewsBulletin.all
@ -39,6 +42,10 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
@news_bulletin_link = NewsBulletinLink.new
@link_url = panel_news_back_end_news_bulletins_path
@news_bulletins.delete_if{ |news_bulletin|
news_bulletin.is_pending == true && (!news_bulletin.bulletin_category.authed_users('fact_check').include?(current_user) || news_bulletin.create_user_id!=current_user.id)
}
@news_bulletin_file = NewsBulletinFile.new
@file_url = panel_news_back_end_news_bulletins_path
@ -75,17 +82,19 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
def new
@news_bulletin = NewsBulletin.new
@link_url = panel_news_back_end_news_bulletins_path
@link_url = panel_news_back_end_news_bulletins_path
# @news_bulletin.news_bulletin_files.build
# @news_bulletin.news_bulletin_files.new
get_categorys
get_tags
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @news_bulletin }
if get_categorys.empty?
flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
redirect_to :action => :index
else
get_tags
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @news_bulletin }
end
end
end
@ -311,10 +320,11 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
def get_categorys(id = nil)
@news_bulletin_categorys = []
@unit_list_for_anc = UnitListForAnc.all
if(is_manager? || is_admin?)
@news_bulletin_categorys = (id ? NewsBulletinCategory.find(id).to_a : NewsBulletinCategory.excludes('disabled' => true))
elsif is_sub_manager?
@news_bulletin_categorys = NewsBulletinCategory.authed_for_user(current_user,'submit_new')
@news_bulletin_categorys = NewsBulletinCategory.authed_for_user(current_user,'submit')
end
end

View File

@ -24,10 +24,19 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
end
def show
@news_bulletin = NewsBulletin.can_display.where(_id: params[:id]).first
get_categorys
if params[:preview] == "true"
preview_content
else
@news_bulletins = NewsBulletin.can_display.where(_id: params[:id]).first
get_categorys
end
end
def preview_content
@news_bulletins = NewsBulletin.find params[:id]
get_categorys
render :show
end
protected

View File

@ -0,0 +1,14 @@
module Panel::News::BackEnd::NewsBulletinCategorysHelper
include ActionView::Helpers::UrlHelper
def show_submit_permission_link(news_bulletin_category)
oa = news_bulletin_category.get_object_auth_by_title('submit')
if oa.nil?
news_bulletin_category.object_auths.new(title: 'submit' ).save
oa = news_bulletin_category.get_object_auth_by_title('submit')
end
link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa)
end
end

View File

@ -0,0 +1,9 @@
module Panel::News::BackEnd::NewsBulletinsHelper
def show_approval_link(news_bulletin)
by_news_bulletin = (!news_bulletin.is_expired? and !news_bulletin.is_checked?)
by_user = news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) or is_manager?
by_news_bulletin and by_user
end
end

View File

@ -33,6 +33,7 @@ class NewsBulletin
mount_uploader :image, ImageUploader
belongs_to :news_bulletin_category
belongs_to :unit_list_for_anc
# embeds_many :news_bulletin_links, :cascade_callbacks => true
# embeds_many :news_bulletin_files, :cascade_callbacks => true

View File

@ -0,0 +1,69 @@
<% if news_bulletin -%>
<div class="modal hide fade in banner-preview" id="news_bulletin-<%=news_bulletin.id%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t("modal.preview") %></h3>
</div>
<div class="modal-body">
<p class="news_bulletin_slideshow">
<iframe src=<%= panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => news_bulletin.news_bulletin_category.id ,:preview=>true) %> style="width:1024px;height:300px" >
</iframe>
<%# preview_block_ad_images_helper(news_bulletin).each do |ad_image| -%>
<%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => news_bulletin.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || news_bulletin.context || " ")) %>
<%# end -%>
</p>
</div>
<div class="modal-footer">
<%= form_for news_bulletin, :url => panel_news_back_end_news_bulletin_path(news_bulletin), :html => {:class => 'clear'} do |f| %>
<%= f.label :approval_stat, t('announcement.bulletin.approval_stat') %>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
<%= t('announcement.bulletin.approval_pass') %>
<% end -%>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, false, (!@news_bulletin.is_checked ? {:checked => true, :class => 'privacy'} : {})%>
<%= t('announcement.bulletin.approval_not_pass') %>
<% end -%>
<%= label :is_checked_false, t('announcement.bulletin.approval_not_pass_reason') %>
<%= f.text_field :not_checked_reason %>
<%= f.submit t('announcement.bulletin.submit_approval'),:class=>"btn"%>
<% end %>
<a href="#" class="btn" data-dismiss="modal"><%= t("modal.close") %></a>
</div>
<div>
<script type="text/javascript" src="/static/kernel.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// $("#news_bulletin-<%#=news_bulletin.title.dehumanize%>").on("show", function () {
// $("#news_bulletin-<%#=news_bulletin.title.dehumanize%>").find(".news_bulletin_slideshow").cycle({delay: -1000, fx: "<%#= news_bulletin.ad_fx.nil?? "fade": news_bulletin.ad_fx %>", timeoutFn: getTimeout });
// });
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
$("iframe").load(function(){
// Get the body element
var frameBody = $("iframe").contents().find("body");
// Get all links inside the BODY tag
$('a', frameBody).click(function(e){
//Disable all default actions
e.preventDefault();
});
$('input', frameBody).attr("disabled", true);
});
});
</script>
</div>
</div>
<% end -%>

View File

@ -0,0 +1,5 @@
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_approve',:locals => {:news_bulletin => @news_bulletin})) %>");
var start_modal_with_id = "news_bulletin-<%=@news_bulletin.id%>";
$("#"+start_modal_with_id).css("width","1050px");
$("#"+start_modal_with_id).css("height","768px");
$("#"+start_modal_with_id).css("margin","-270px 0 0 -550px");

View File

@ -4,8 +4,14 @@
<%= news_bulletin_category.key %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('news_bulletin_category.edit'), edit_panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :remote => true %></li>
<li><%= link_to t('news_bulletin_category.delete'), panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :confirm => t('news.sure?'), :method => :delete, :remote => true %></li>
<%if is_manager? || is_admin? %>
<li><%= show_submit_permission_link(news_bulletin_category) %></li>
<% end %>
<% if is_admin?%>
<li><%= link_to t('bulletin_category.edit'), edit_panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :remote => true %></li>
<li><%= link_to t('bulletin_category.delete'), panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<% end %>
</ul>
</div>
</td>

View File

@ -17,7 +17,7 @@
</tbody>
</table>
<div id="form"><%= render :partial => "form" %></div>
<div id="form"><%= render :partial => "form" if is_manager? %></div>

View File

@ -105,28 +105,6 @@
<a class="action"><i title="A" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-link icons-white"></i>Audit</h3>
<div class="widget-content">
<% if is_manager? || @news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) || current_user.admin? %>
<div class="controls">
<%= f.label :approval_stat, t('news.news_bulletin.approval_stat') %>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
<%= t('news.news_bulletin.approval_pass') %>
<% end -%>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, false, (!@news_bulletin.is_checked ? {:checked => true, :class => 'privacy'} : {})%>
<%= t('news.news_bulletin.approval_not_pass') %>
<% end -%>
<div class="select-role">
<%= label :is_checked_false, t('news.news_bulletin.approval_not_pass_reason') %>
<%= f.text_field :not_checked_reason %>
</div>
</div>
<% end %>
</div>
</div>
<% elsif current_user.admin? %>
<%= f.hidden_field :is_checked,:value => true%>
@ -139,7 +117,10 @@
<div id="post-body">
<div id="post-body-content" class="clear">
<%= f.label :unit_list_for_anc%>
<%= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
<%= f.label :category %>
<%= f.select :news_bulletin_category_id, @news_bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>

View File

@ -1,5 +1,9 @@
<tr id="<%= dom_id news_bulletin %>" class="with_action">
<td><%= check_box_tag 'to_delete[]', news_bulletin.id, false, :class => "checkbox_in_list" %></td>
<td>
<% if (news_bulletin.create_user_id == current_user.id) || is_manager? %>
<%= check_box_tag 'to_delete[]', news_bulletin.id, false, :class => "checkbox_in_list" %>
<% end -%>
</td>
<td>
<div class="label-group">
<div class="label-td">
@ -27,27 +31,33 @@
<td><%= news_bulletin.news_bulletin_category.i18n_variable[I18n.locale] %></td>
<td>
<%= 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 ''%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if current_user.admin? || (!news_bulletin.is_rejected? && !news_bulletin.is_checked?) %>
<li><%= link_to t('news_bulletin.edit'), edit_panel_news_back_end_news_bulletin_path(news_bulletin) %></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><%= link_to t(:basic), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'basic'), :remote => true %></li>
<li><%= link_to t(:picture), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'picture'), :remote => true %></li>
<li><%= link_to t(:tags), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'tags'), :remote => true %></li>
<li><%= link_to t(:link), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'links'), :remote => true %></li>
<li><%= link_to t(:file), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'files'), :remote => true %></li>
</ul>
</li>
<%#= debugger %>
<%#= a=1 %>
<% if (news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) or is_manager?) and !news_bulletin.is_expired? %>
<li><%= link_to t('news.news_bulletin.approval'), edit_panel_news_back_end_news_bulletin_path(news_bulletin) %></li><%#= #TODO add ancher so user can quick access into that part %>
<% end %>
<% if (news_bulletin.create_user_id == current_user.id) || is_manager? %>
<% if current_user.admin? || (!news_bulletin.is_rejected? && !news_bulletin.is_checked?) %>
<li><%= link_to t('news_bulletin.edit'), edit_panel_news_back_end_news_bulletin_path(news_bulletin) %></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><%= link_to t(:basic), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'basic'), :remote => true %></li>
<li><%= link_to t(:picture), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'picture'), :remote => true %></li>
<li><%= link_to t(:tags), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'tags'), :remote => true %></li>
<li><%= link_to t(:link), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'links'), :remote => true %></li>
<li><%= link_to t(:file), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'files'), :remote => true %></li>
</ul>
</li>
<%#= debugger %>
<%#= a=1 %>
<% end %>
<li class="dropdown"><%= link_to t('news_bulletin.delete'), panel_news_back_end_news_bulletin_path(news_bulletin), :confirm => t('news.sure?'), :method => :delete, :remote => true %></li>
<% end %>
<li class="dropdown"><%= link_to t('news_bulletin.delete'), panel_news_back_end_news_bulletin_path(news_bulletin), :confirm => t('news.sure?'), :method => :delete, :remote => true %></li>
<% if show_approval_link(news_bulletin) %>
<li><%= link_to t('news.news_bulletin.approval'), panel_news_back_end_news_bulletin_approval_preview_path(news_bulletin) %></li><%#= #TODO add ancher so user can quick access into that part %>
<% end %>
</ul>
</div>
</td>

View File

@ -26,5 +26,7 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "news_bulletin_form" %>
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %>

View File

@ -4,7 +4,7 @@
<div class="info1">
<span class="date"><%= @news_bulletin.postdate %></span>
&nbsp;|&nbsp;
<a href="" class="unit"><%= User.find(@news_bulletin.create_user_id).name %></a>
<a href="" class="unit"><%= @news_bulletin.unit_list_for_anc.title[I18n.locale] rescue '' %></a>
</div>
</div>
<div class="news_image">

View File

@ -6,6 +6,8 @@ Rails.application.routes.draw do
match 'update_setting' => "news_approvals#update_setting" ,:as => :news_approval_update_setting
resources :news_bulletins do
match "approve/:news_bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put
match "approve/:news_bulletin_id" => "approvals#approve",:as => :approve,:via => :post
match "link_quick_add/:news_bulletin_id" => "news_bulletins#link_quick_add" ,:as => :link_quick_add
match "link_quick_edit/:news_bulletin_id" => "news_bulletins#link_quick_edit" ,:as => :link_quick_edit
member do
@ -31,7 +33,9 @@ Rails.application.routes.draw do
resources :tags
end
namespace :front_end do
resources :news_bulletins
resources :news_bulletins # do
# match "preview" => "news_bulletins#preview_content",:as => :get_preview_content
# end
end
namespace :widget do
match "news_bulletins" => "news_bulletins#index"