Merge branch 'design_team' into ldap
Conflicts: vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb
This commit is contained in:
commit
d4aea664e2
|
@ -24,6 +24,10 @@ $("#module_app_list select").live('change', function() {
|
||||||
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widgets');
|
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widgets');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#tag_list select").live('change', function() {
|
||||||
|
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_r_tag_options');
|
||||||
|
});
|
||||||
|
|
||||||
$('.part_kind').live('click', function() {
|
$('.part_kind').live('click', function() {
|
||||||
$('.part_kind_partial').hide();
|
$('.part_kind_partial').hide();
|
||||||
$('#part_' + $(this).attr('value')).show();
|
$('#part_' + $(this).attr('value')).show();
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Admin::PagePartsController < ApplicationController
|
||||||
@module_apps = ModuleApp.all(:conditions => {:enable_frontend => true})
|
@module_apps = ModuleApp.all(:conditions => {:enable_frontend => true})
|
||||||
@module_app = @part.module_app ? @part.module_app : @module_apps[0]
|
@module_app = @part.module_app ? @part.module_app : @module_apps[0]
|
||||||
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
|
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
|
||||||
@tag_objects = @r_tag.classify.constantize.all
|
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||||
case @module_app.key
|
case @module_app.key
|
||||||
when 'bulletin'
|
when 'bulletin'
|
||||||
@categories = BulletinCategory.all
|
@categories = BulletinCategory.all
|
||||||
|
@ -78,4 +78,12 @@ class Admin::PagePartsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reload_r_tag_options
|
||||||
|
@r_tag = (ModuleApp.find(params[:id]) rescue nil) || params[:id]
|
||||||
|
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||||
|
respond_to do |format|
|
||||||
|
format.js {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,11 +75,12 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def active_for_controllers(*controller_names)
|
def active_for_controllers(*controller_names)
|
||||||
controller_names.include?(controller.controller_name) ? 'active' : nil
|
(controller_names.include?(controller.controller_name) || controller_names.include?(request.fullpath)) ? 'active' : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_for_controllers(*controller_names)
|
def visible_for_controllers(*controller_names)
|
||||||
controller_names.include?(controller.controller_name) ? '' : 'hide'
|
puts controller_names
|
||||||
|
(controller_names.include?(controller.controller_name) || controller_names.include?(request.fullpath)) ? '' : 'hide'
|
||||||
end
|
end
|
||||||
|
|
||||||
def active_for_action(controller_name, action_name)
|
def active_for_action(controller_name, action_name)
|
||||||
|
|
|
@ -7,7 +7,7 @@ class PagePart
|
||||||
field :content
|
field :content
|
||||||
field :kind
|
field :kind
|
||||||
field :public_r_tag
|
field :public_r_tag
|
||||||
field :public_r_tag_object_id, :type => BSON::ObjectId, :default => nil
|
field :public_r_tag_object_id, :default => nil
|
||||||
field :widget_path
|
field :widget_path
|
||||||
|
|
||||||
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
<span id='tag_list'>
|
<span id='tag_list'>
|
||||||
<%= f.select :public_r_tag, LIST[:public_r_tags].collect{|tag| [t(tag), tag]}, :selected => @r_tag %>
|
<%= f.select :public_r_tag, LIST[:public_r_tags].collect{|tag| [t(tag), tag]}, {:selected => @r_tag}, {:rel => admin_page_parts_path} %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span id='name_list'>
|
<span id='name_list'>
|
||||||
<%= f.select :public_r_tag_object_id, options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %>
|
<% if @r_tag.eql?('sub_menu') %>
|
||||||
|
<%= f.select :public_r_tag_object_id, options_for_select([t(:horizontal), t(:vertical)], t(:horizontal)) %>
|
||||||
|
<% else %>
|
||||||
|
<%= f.select :public_r_tag_object_id, options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %>
|
||||||
|
<% end %>
|
||||||
</span>
|
</span>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<% if @r_tag.eql?('sub_menu') %>
|
||||||
|
$('#name_list select').html("<%= j options_for_select(t(:horizontal) => :horizontal, t(:vertical) => :vertical) %>")
|
||||||
|
<% else %>
|
||||||
|
$('#name_list select').html("<%= j options_from_collection_for_select(@tag_objects, :id, :title) %>")
|
||||||
|
<% end %>
|
|
@ -2,13 +2,13 @@
|
||||||
<%= link_to content_tag(:i, nil, :class => 'icons-purchase') + t('admin.purchase'), admin_purchases_path %>
|
<%= link_to content_tag(:i, nil, :class => 'icons-purchase') + t('admin.purchase'), admin_purchases_path %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%= content_tag :li, :class => active_for_controllers('bulletins', 'tags', 'bulletin_categorys', 'fact_checks') do -%>
|
<%= content_tag :li, :class => active_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'fact_checks') do -%>
|
||||||
<%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %>
|
<%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %>
|
||||||
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', 'tags', 'bulletin_categorys', 'fact_checks')) do -%>
|
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'fact_checks')) do -%>
|
||||||
<%= content_tag :li, link_to(t('announcement.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %>
|
<%= content_tag :li, link_to(t('announcement.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %>
|
||||||
<%= content_tag :li, link_to(t('announcement.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %>
|
<%= content_tag :li, link_to(t('announcement.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %>
|
||||||
<%= content_tag :li, link_to(t('announcement.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %>
|
<%= content_tag :li, link_to(t('announcement.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %>
|
||||||
<%= content_tag :li, link_to(t('announcement.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('panel/bulletin/back_end/tags', 'index') %>
|
<%= content_tag :li, link_to(t('announcement.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('/panel/announcement/back_end/tags', 'index') %>
|
||||||
<%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('fact_checks', 'setting') if (is_manager? rescue nil) %>
|
<%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('fact_checks', 'setting') if (is_manager? rescue nil) %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= content_tag :li, :class => active_for_controllers('web_links', 'tags', 'web_link_categorys') do -%>
|
<%= content_tag :li, :class => active_for_controllers('web_links', '/panel/web_resource/back_end/tags', 'web_link_categorys') do -%>
|
||||||
<%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), panel_web_resource_back_end_web_links_path %>
|
<%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), panel_web_resource_back_end_web_links_path %>
|
||||||
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('web_links', 'tags', 'web_link_categorys')) do -%>
|
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('web_links', '/panel/web_resource/back_end/tags', 'web_link_categorys')) do -%>
|
||||||
<%= content_tag :li, link_to(t('admin.announcement.all_articles'), panel_web_resource_back_end_web_links_path), :class => active_for_action('web_link', 'index') %>
|
<%= content_tag :li, link_to(t('admin.announcement.all_articles'), panel_web_resource_back_end_web_links_path), :class => active_for_action('web_link', 'index') %>
|
||||||
<%= content_tag :li, link_to(t('admin.announcement.add_new'), new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_link', 'new') %>
|
<%= content_tag :li, link_to(t('admin.announcement.add_new'), new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_link', 'new') %>
|
||||||
<%= content_tag :li, link_to(t('admin.announcement.categories'), panel_web_resource_back_end_web_link_categorys_path), :class => active_for_action('web_link_categorys', 'index') %>
|
<%= content_tag :li, link_to(t('admin.announcement.categories'), panel_web_resource_back_end_web_link_categorys_path), :class => active_for_action('web_link_categorys', 'index') %>
|
||||||
<%= content_tag :li, link_to(t('admin.announcement.tags'), panel_web_resource_back_end_tags_path), :class => active_for_action('panel/web_resource/back_end/tags', 'index') %>
|
<%= content_tag :li, link_to(t('admin.announcement.tags'), panel_web_resource_back_end_tags_path), :class => active_for_action('/panel/web_resource/back_end/tags', 'index') %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ markups:
|
||||||
|
|
||||||
public_r_tags:
|
public_r_tags:
|
||||||
- ad_banner
|
- ad_banner
|
||||||
|
- sub_menu
|
||||||
|
|
||||||
page_part_kinds:
|
page_part_kinds:
|
||||||
- text
|
- text
|
||||||
|
|
|
@ -77,6 +77,7 @@ Orbit::Application.routes.draw do
|
||||||
resources :page_parts do
|
resources :page_parts do
|
||||||
member do
|
member do
|
||||||
get 'reload_widgets'
|
get 'reload_widgets'
|
||||||
|
get 'reload_r_tag_options'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :purchases do
|
resources :purchases do
|
||||||
|
|
|
@ -106,4 +106,20 @@ module ParserCommon
|
||||||
page_menu.swap(fragment)
|
page_menu.swap(fragment)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# sub_menus
|
||||||
|
def parse_sub_menus(body = nil, page = nil, id = nil)
|
||||||
|
body.css('sub_menu').each do |sub_menu|
|
||||||
|
res = ''
|
||||||
|
res << "<ul>"
|
||||||
|
page.children.each do |child|
|
||||||
|
res << "<li>"
|
||||||
|
res << "<a href='#{child.full_name}'>#{child.i18n_variable[I18n.locale]}</a>"
|
||||||
|
res << "</li>"
|
||||||
|
end
|
||||||
|
res << "</ul>"
|
||||||
|
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
|
||||||
|
sub_menu.swap(fragment)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -91,12 +91,16 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
# GET /bulletins/1/edit
|
# GET /bulletins/1/edit
|
||||||
def edit
|
def edit
|
||||||
@bulletin = Bulletin.find(params[:id])
|
@bulletin = Bulletin.find(params[:id])
|
||||||
# @summary_variable = @bulletin.summary_variable
|
if @bulletin.is_rejected?
|
||||||
|
redirect_to :action => :index
|
||||||
|
else
|
||||||
|
# @summary_variable = @bulletin.summary_variable
|
||||||
|
|
||||||
@link_url = panel_announcement_back_end_bulletin_path(@bulletin)
|
@link_url = panel_announcement_back_end_bulletin_path(@bulletin)
|
||||||
|
|
||||||
get_categorys
|
get_categorys
|
||||||
get_tags
|
get_tags
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /bulletins
|
# POST /bulletins
|
||||||
|
@ -205,56 +209,59 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
# PUT /bulletins/1.xml
|
# PUT /bulletins/1.xml
|
||||||
def update
|
def update
|
||||||
|
|
||||||
if params[:bulletin_link]
|
if params[:bulletin_link]
|
||||||
|
|
||||||
@bulletin_link = BulletinLink.find(params[:id])
|
@bulletin_link = BulletinLink.find(params[:id])
|
||||||
|
|
||||||
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
|
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @bulletin_link.update_attributes(params[:bulletin_link])
|
if @bulletin_link.update_attributes(params[:bulletin_link])
|
||||||
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
|
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
|
||||||
format.js { render 'update_bulletin_link' }
|
format.js { render 'update_bulletin_link' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elsif params[:bulletin_file]
|
elsif params[:bulletin_file]
|
||||||
|
|
||||||
@bulletin_file = BulletinFile.find(params[:id])
|
@bulletin_file = BulletinFile.find(params[:id])
|
||||||
|
|
||||||
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
|
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @bulletin_file.update_attributes(params[:bulletin_file])
|
if @bulletin_file.update_attributes(params[:bulletin_file])
|
||||||
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
|
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
|
||||||
format.js { render 'update_bulletin_file' }
|
format.js { render 'update_bulletin_file' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@bulletin = Bulletin.find(params[:id])
|
@bulletin = Bulletin.find(params[:id])
|
||||||
|
|
||||||
@bulletin.update_user_id = current_user.id
|
@bulletin.update_user_id = current_user.id
|
||||||
|
|
||||||
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
|
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
|
||||||
# if params[:bulletin][:image_del] == '1'
|
# if params[:bulletin][:image_del] == '1'
|
||||||
# @bulletin.remove_image!
|
# @bulletin.remove_image!
|
||||||
# @bulletin.image_del = nil
|
# @bulletin.image_del = nil
|
||||||
# params[:bulletin][:image_del] = nil
|
# params[:bulletin][:image_del] = nil
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @bulletin.update_attributes(params[:bulletin])
|
||||||
|
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
|
||||||
|
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
|
||||||
|
format.js { render 'toggle_enable' }
|
||||||
|
format.xml { head :ok }
|
||||||
|
else
|
||||||
|
get_tags
|
||||||
|
get_categorys
|
||||||
|
format.html { render :action => "edit" }
|
||||||
|
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save
|
|
||||||
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
|
|
||||||
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
|
|
||||||
format.js { render 'toggle_enable' }
|
|
||||||
format.xml { head :ok }
|
|
||||||
else
|
|
||||||
format.html { render :action => "edit" }
|
|
||||||
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -335,7 +342,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
|
sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
|
||||||
bulletins = sorted.collect {|a| a[1] }
|
bulletins = sorted.collect {|a| a[1] }
|
||||||
when 'status'
|
when 'status'
|
||||||
bulletins = bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction])
|
bulletins = bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction]).order_by(:is_pending, params[:direction]).order_by(:is_checked, params[:direction]).order_by(:is_rejected, params[:direction])
|
||||||
when 'update_user_id'
|
when 'update_user_id'
|
||||||
user_ids = bulletins.distinct(:update_user_id)
|
user_ids = bulletins.distinct(:update_user_id)
|
||||||
users = User.find(user_ids) rescue nil
|
users = User.find(user_ids) rescue nil
|
||||||
|
@ -357,7 +364,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
sorted_titles = sorted.collect {|a| a[1] }
|
sorted_titles = sorted.collect {|a| a[1] }
|
||||||
a = params[:direction].eql?('asc') ? (sorted_titles + a) : (a + sorted_titles)
|
a = params[:direction].eql?('asc') ? (sorted_titles + a) : (a + sorted_titles)
|
||||||
bulletins = a.flatten
|
bulletins = a.flatten
|
||||||
end
|
end
|
||||||
if @filter
|
if @filter
|
||||||
@filter.each do |key, value|
|
@filter.each do |key, value|
|
||||||
case key
|
case key
|
||||||
|
@ -365,16 +372,23 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
a = Array.new
|
a = Array.new
|
||||||
bulletins.each do |bulletin|
|
bulletins.each do |bulletin|
|
||||||
value.each do |v|
|
value.each do |v|
|
||||||
a << bulletin if bulletin[v]
|
case v
|
||||||
|
when 'pending'
|
||||||
|
a << bulletin if bulletin.is_checked.nil?
|
||||||
|
when 'rejected'
|
||||||
|
a << bulletin if bulletin.is_checked.eql?(false)
|
||||||
|
else
|
||||||
|
a << bulletin if bulletin[v]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
bulletins = a
|
bulletins = a.uniq
|
||||||
when 'categories'
|
when 'categories'
|
||||||
a = Array.new
|
a = Array.new
|
||||||
bulletins.each do |bulletin|
|
bulletins.each do |bulletin|
|
||||||
a << bulletin if value.include?(bulletin.bulletin_category.id.to_s)
|
a << bulletin if value.include?(bulletin.bulletin_category.id.to_s)
|
||||||
end
|
end
|
||||||
bulletins = a
|
bulletins = a.uniq
|
||||||
when 'tags'
|
when 'tags'
|
||||||
a = Array.new
|
a = Array.new
|
||||||
bulletins.each do |bulletin|
|
bulletins.each do |bulletin|
|
||||||
|
@ -382,7 +396,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
a << bulletin if value.include?(tag.id.to_s)
|
a << bulletin if value.include?(tag.id.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
bulletins = a
|
bulletins = a.uniq
|
||||||
end if value.size > 0
|
end if value.size > 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,10 @@ class Bulletin
|
||||||
field :is_top, :type => Boolean, :default => false
|
field :is_top, :type => Boolean, :default => false
|
||||||
field :is_hot, :type => Boolean, :default => false
|
field :is_hot, :type => Boolean, :default => false
|
||||||
field :is_hidden, :type => Boolean, :default => false
|
field :is_hidden, :type => Boolean, :default => false
|
||||||
field :is_checked, :type => Boolean, :default => nil
|
field :is_checked, :type => Boolean, :default => false
|
||||||
|
field :is_pending, :type => Boolean, :default => true
|
||||||
|
field :is_rejected, :type => Boolean, :default => false
|
||||||
|
|
||||||
|
|
||||||
field :not_checked_reason
|
field :not_checked_reason
|
||||||
|
|
||||||
|
@ -42,7 +45,7 @@ class Bulletin
|
||||||
|
|
||||||
validates_presence_of :title
|
validates_presence_of :title
|
||||||
|
|
||||||
before_save :set_key
|
before_save :set_key, :update_status
|
||||||
|
|
||||||
after_save :save_bulletin_links
|
after_save :save_bulletin_links
|
||||||
after_save :save_bulletin_files
|
after_save :save_bulletin_files
|
||||||
|
@ -79,17 +82,6 @@ class Bulletin
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def status
|
|
||||||
case self.is_checked
|
|
||||||
when nil
|
|
||||||
I18n.t('announcement.bulletin.fact_check_pending')
|
|
||||||
when true
|
|
||||||
I18n.t('announcement.bulletin.fact_check_pass')
|
|
||||||
when false
|
|
||||||
I18n.t('announcement.bulletin.fact_check_not_pass')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_expired?
|
def is_expired?
|
||||||
Date.today > self.deadline ? true : false rescue false
|
Date.today > self.deadline ? true : false rescue false
|
||||||
#some dates might sat as nil so rescue false
|
#some dates might sat as nil so rescue false
|
||||||
|
@ -111,8 +103,12 @@ class Bulletin
|
||||||
self.is_checked
|
self.is_checked
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_check_rejected?
|
def is_pending?
|
||||||
self.is_checked == false
|
self.is_pending
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_rejected?
|
||||||
|
self.is_rejected
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,5 +166,17 @@ class Bulletin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_status
|
||||||
|
if !self.is_pending && !self.is_checked
|
||||||
|
self.is_pending = false
|
||||||
|
self.is_rejected = true
|
||||||
|
self.is_checked = false
|
||||||
|
elsif self.is_checked
|
||||||
|
self.is_pending = false
|
||||||
|
self.is_rejected = false
|
||||||
|
self.is_checked = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
|
@ -10,14 +10,22 @@
|
||||||
<% if bulletin.is_hidden? %>
|
<% if bulletin.is_hidden? %>
|
||||||
<span class="label"><%= t(:hidden) %></span>
|
<span class="label"><%= t(:hidden) %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= bulletin.status %>
|
<% if bulletin.is_pending? %>
|
||||||
|
<span class="label"><%= t(:pending) %></span>
|
||||||
|
<% end %>
|
||||||
|
<% if bulletin.is_checked? %>
|
||||||
|
<span class="label"><%= t(:checked) %></span>
|
||||||
|
<% end %>
|
||||||
|
<% if bulletin.is_rejected? %>
|
||||||
|
<span class="label"><%= t(:rejected) %></span>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= bulletin.bulletin_category.i18n_variable[I18n.locale] %></td>
|
<td><%= bulletin.bulletin_category.i18n_variable[I18n.locale] %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%>
|
<%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%>
|
||||||
<div class="quick-edit">
|
<div class="quick-edit">
|
||||||
<ul class="nav nav-pills hide">
|
<ul class="nav nav-pills hide">
|
||||||
<% unless bulletin.is_check_rejected?%>
|
<% unless bulletin.is_rejected?%>
|
||||||
<li><%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li>
|
<li><%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
|
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<div class="accordion-inner" data-toggle="buttons-checkbox">
|
<div class="accordion-inner" data-toggle="buttons-checkbox">
|
||||||
<%= link_to t(:is_top), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_top'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_top')}" %>
|
<%= link_to t(:top), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_top'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_top')}" %>
|
||||||
<%= link_to t(:is_hot), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hot'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_hot')}" %>
|
<%= link_to t(:hot), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hot'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_hot')}" %>
|
||||||
<%= link_to t(:is_hidden), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hidden'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_hidden')}" %>
|
<%= link_to t(:hidden), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hidden'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_hidden')}" %>
|
||||||
<%= link_to t(:is_checked), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_checked'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_checked')}" %>
|
<%= link_to t(:pending), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_pending'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_pending')}" %>
|
||||||
|
<%= link_to t(:passed), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_checked'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_checked')}" %>
|
||||||
|
<%= link_to t(:rejected), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_rejected'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_rejected')}" %>
|
||||||
</div>
|
</div>
|
||||||
<%= render :partial => 'clear_filters', :locals => {:type => 'status'} %>
|
<%= render :partial => 'clear_filters', :locals => {:type => 'status'} %>
|
|
@ -106,7 +106,7 @@
|
||||||
<%= t('announcement.bulletin.fact_check_pass') %>
|
<%= t('announcement.bulletin.fact_check_pass') %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<%= content_tag :label,:class => "radio inline" do -%>
|
<%= content_tag :label,:class => "radio inline" do -%>
|
||||||
<%= f.radio_button :is_checked, false, (@bulletin.is_checked.nil?? {:checked => true, :class => 'privacy'} : {})%>
|
<%= f.radio_button :is_checked, false, (!@bulletin.is_checked ? {:checked => true, :class => 'privacy'} : {})%>
|
||||||
<%= t('announcement.bulletin.fact_check_not_pass') %>
|
<%= t('announcement.bulletin.fact_check_not_pass') %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<div class="select-role">
|
<div class="select-role">
|
||||||
|
|
Reference in New Issue