fix news approve and preview

This commit is contained in:
Matthew K. Fu JuYuan 2012-05-18 18:47:18 +08:00
parent a2637008e0
commit 6ce6577e83
14 changed files with 87 additions and 24 deletions

View File

@ -26,7 +26,7 @@
<%= content_tag :li, link_to(t('announcement.add_new'), new_panel_news_back_end_news_bulletin_path), :class => active_for_action('news_bulletins', 'new') %>
<%= content_tag :li, link_to(t('announcement.categories'), panel_news_back_end_news_bulletin_categorys_path), :class => active_for_action('news_bulletin_categorys', 'index') || active_for_ob_auths_object("NewsBulletinCategory") %>
<%= content_tag :li, link_to(t('announcement.tags'), panel_news_back_end_tags_path), :class => active_for_action('/panel/news/back_end/tags', 'index') %>
<%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_news_back_end_news_approval_setting_path), :class => active_for_action('news_approvals', 'setting') if (is_manager? rescue nil) %>
<%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_news_back_end_approval_setting_path), :class => active_for_action('news_approvals', 'setting') if (is_manager? rescue nil) %>
<%= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "news"}))), :class => active_for_app_auth('news') if (is_admin? rescue nil) %>
<% end -%>

View File

@ -31,9 +31,9 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
def update_setting
object_auth = update_setting_by_params
if object_auth.save!
flash[:notice] = "Update Done"
flash[:notice] = t("admin.object_auth.update_done")
else
flash[:notice] = "Update Failed"
flash[:notice] = t("admin.object_auth.update_failed")
end
end

View File

@ -38,7 +38,6 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
def preview_content
@bulletin = Bulletin.find params[:id]
get_categorys
render :show
end
protected

View File

@ -16,11 +16,9 @@
<%= select "category",'id',@options_from_collection_for_select_bulletin_categorys %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
<%= link_to t("announcement.bulletin.approval_user_list"), panel_announcement_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t("admin.roles") %>
<div class="clear">

View File

@ -4,7 +4,7 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
include AdminHelper
def preview_and_approve
@bulletin = NewsBulletin.find params[:bulletin_id]
@news_bulletin = NewsBulletin.find params[:news_bulletin_id]
end
def approve
@ -35,10 +35,27 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
end
def update_setting
object_auth = update_setting_by_params
if object_auth.save!
flash[:notice] = t("admin.object_auth.update_done")
else
flash[:notice] = t("admin.object_auth.update_failed")
end
end
def user_list
@news_bulletin_category = NewsBulletinCategory.find params[:category_id]
end
protected
def update_setting_by_params
category = NewsBulletinCategory.find params[:category_id]
privilege_users = params[:users].collect{|key,value| User.find key } rescue []
object_auth_ary = category.object_auths.where(title: 'fact_check') || (category.object_auths.create :title=> 'fact_check')
object_auth = object_auth_ary.first
object_auth.privilege_users = privilege_users
object_auth
end
def get_categorys(id = nil)
@news_bulletin_categorys = []

View File

@ -36,9 +36,8 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
end
def preview_content
@news_bulletins = NewsBulletin.find params[:id]
@news_bulletin = NewsBulletin.find params[:id]
get_categorys
render :show
end
protected

View File

@ -2,7 +2,7 @@ module Panel::News::BackEnd::NewsBulletinsHelper
def news_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_user = (news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) or is_manager? or is_admin?)
by_news_bulletin and by_user
end

View File

@ -0,0 +1,44 @@
<% if news_bulletin_category -%>
<div class="modal hide fade in" id="news_bulletin_category-<%=news_bulletin_category.id%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t("announcement.bulletin.approval_user_list") %></h3>
</div>
<div class="modal-body">
<div class="clear">
<% news_bulletin_category.get_object_auth_by_title('fact_check').auth_users.each do |user| %>
<div class="checkbox clear checked">
<div class='member-avatar'>
<% if user.avatar? %>
<%= image_tag(user.avatar.thumb.url,:class => "member-img") %>
<% else %>
<%= image_tag "person.png",:class => "member-img" %>
<% end %>
</div>
<%= label_tag "lab-user-#{user.id}", (user.name rescue ''),:class=>"member-name",:id=>nil -%>
</div>
<% end -%>
<divl>
</div>
<div class="modal-footer">
<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_category-<%=news_bulletin_category.id%>").on("show", function () {
});
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
});
</script>
</div>
</div>
<% end -%>

View File

@ -6,7 +6,7 @@
<% user.sub_roles.each do |sr| %>
<div class="for_unit" style="display:none;"> <%= sr.key %></div>
<% end %>
<%= content_tag :div,:data=>{'original-title'=>t('news.news_bulletin.approval_setting_window_title'),:content => "#{user.sub_roles.collect{|sr| sr.key}.join(',')}"},:class=>"checkbox clear" do %>
<%= content_tag :div,:data=>{'original-title'=>t('news.news_bulletin.approval_setting_window_title'),:content => "#{user.sub_roles.collect{|sr| sr.i18n_variable[I18n.locale]}.join(',')}"},:class=>"checkbox clear" do %>
<div class="check-icon">
</div>
<div class='member-avatar'>

View File

@ -4,11 +4,12 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/search" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %>
<%#= label_tag :fact_check_setting, t("news.news_bulletin.fact_check_setting") %>
<%= form_tag('', :remote => true) %>
<div class="subnav">
<ul class="nav nav-pills filter">
<%= form_tag('', :remote => true,:class => "prevent_enter_submit_form") %>
<div class="subnav clear">
<ul class="nav nav-pills filter pull-left">
<li class="accordion-group">
<div class="form-search" style="margin: 5px 10px;">
<%= label_tag :category, t("news.news_bulletin.category") %>
@ -17,14 +18,15 @@
</div>
</li>
</ul>
<%= link_to t("announcement.bulletin.approval_user_list"), panel_news_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t("admin.roles") %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag :action => "update_setting" do %>
<% form_tag panel_news_back_end_approval_setting_path do %>
<%= render :partial => "privilege_user", :locals => {:users => @users_array} %>
<div class="form-actions pagination-centered">
<%= submit_tag "Update", :class => 'btn' %>
<div class="form-actions form-fixed pagination-right">
<%= submit_tag "Update", :class => 'btn btn-primary' %>
</div>
<% end -%>
<% end -%>

View File

@ -0,0 +1 @@
alert( "<% flash.each do |key, msg| %><%= msg %><% end%>");

View File

@ -0,0 +1,2 @@
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_list',:locals => {:news_bulletin_category => @news_bulletin_category})) %>");
var start_modal_with_id = "news_bulletin_category-<%=@news_bulletin_category.id%>"

View File

@ -55,7 +55,7 @@
<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 %>
<% if news_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 %>
<li><%= link_to t('news.news_bulletin.approval'), panel_news_back_end_news_bulletin_approval_preview_path(news_bulletin),:class => 'preview_trigger' %></li><%#= #TODO add ancher so user can quick access into that part %>
<% end %>
</ul>

View File

@ -2,12 +2,13 @@ Rails.application.routes.draw do
namespace :panel do
namespace :news do
namespace :back_end do
match 'news_approval_setting' => "news_approvals#setting" ,:as => :news_approval_setting
match 'update_setting' => "news_approvals#update_setting" ,:as => :news_approval_update_setting
match 'public' => "news#public",:as => :public
match 'approval_setting' => "news_approvals#setting" ,:as => :approval_setting,:via => :get
match 'approval_setting' => "news_approvals#update_setting" ,:as => :approval_setting,:via => :post
match 'approval_setting' => "news_approvals#user_list" ,:as => :approval_user_list,:via => :put
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 "approve/:news_bulletin_id" => "news_approvals#preview_and_approve",:as => :approval_preview,:via => :put
match "approve/:news_bulletin_id" => "news_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