Merge commit '6b248a949b44b6e4dc908f29f4f08c3a821210cd' into sidebar_config

Conflicts:
	app/models/user/attribute_value.rb
	app/views/layouts/_side_bar_content.html.erb
	vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
This commit is contained in:
Matthew K. Fu JuYuan committed 2012-11-26 17:55:53 +08:00
commit 3d573680b2
1006 files changed
+5883 -12004

No files matched your search

@@ -1,18 +1,14 @@
class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
before_filter :for_app_manager,:except => [:index]
before_filter :set_module_app
def set_module_app
@module_app = ModuleApp.where(:title=>'Announcement').first
end
before_filter :for_app_manager,:except => [:index,:get_categorys_json,:get_bulletins_json]
def index
@bulletin_categorys = get_categories_for_index("BulletinCategory")
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
@bulletin_category = BulletinCategory.new(:display => 'List')
@url = panel_announcement_back_end_bulletin_categorys_path
@url = panel_announcement_back_end_bulletin_categorys_path
respond_to do |format|
format.html # index.html.erb
# format.xml { render :xml => @bulletins }
@@ -20,6 +16,48 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
end
end
def get_categorys_json
categorys = BulletinCategory.all
data = Array.new
categorys.each do |c|
data << {
category: c.title,
link: "http://#{request.host_with_port}#{panel_announcement_back_end_bulletin_category_get_bulletins_json_path(c)}"
}
end
#render :json => @data.to_json
#to print readable json
render :json => JSON.pretty_generate(data)
end
def get_bulletins_json
bulletin = BulletinCategory.find(params[:bulletin_category_id]).bulletins
p bulletin
data = Array.new
bulletin.each do |b|
deadline = b.deadline
if not deadline.nil?
deadline = display_date_time(deadline)
else
deadline = I18n.t("no_deadline")
end
data << {
title: b.title,
link: "http://#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(b, :category_id => b.bulletin_category.id)}",
postdate: display_date_time(b.postdate),
deadline: deadline,
tag: b.sorted_tags.to_a,
}
end
render :json => JSON.pretty_generate(data)
end
# GET /bulletins/1
# GET /bulletins/1.xml
def show
@@ -45,23 +83,23 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
end
def quick_edit
# debugger
# debugger
@bulletin_category = BulletinCategory.find(params[:bulletin_category_id])
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
respond_to do |format|
format.js
end
end
# GET /bulletins/1/edit
def edit
@bulletin_category = BulletinCategory.find(params[:id])
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
respond_to do |format|
format.html
@@ -92,8 +130,8 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
# PUT /bulletins/1.xml
def update
@bulletin_category = BulletinCategory.find(params[:id])
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
respond_to do |format|
if @bulletin_category.update_attributes(params[:bulletin_category])
@@ -4,8 +4,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
before_filter :clean_values, :only => [:create, :update]
# before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,]
# before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,]
before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_bulletins]
before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
@@ -15,13 +15,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
def preview
#@preview_obj = Preview.create(:object=>params[:news_bulletin],:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
bulletin = Bulletin.new params
@preview_obj = bulletin.to_preview
@preview_obj.save
render '/shared/preview/preview.html.erb',:layout=>false
end
def index
# @bulletins = Bulletin.all
# @bulletins = Bulletin.desc("postdate desc")
@@ -52,10 +52,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin_link = BulletinLink.new
@link_url = panel_announcement_back_end_bulletins_path
@bulletin_file = BulletinFile.new
@file_url = panel_announcement_back_end_bulletins_path
respond_to do |format|
format.html # index.html.erb
format.js { }
@@ -84,13 +84,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin = session[:in_validate_object]
session[:in_validate_object] = {}
end
@link_url = panel_announcement_back_end_bulletins_path
get_tags
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @bulletin }
end
format.html # new.html.erb
format.xml { render :xml => @bulletin }
end
end
# GET /bulletins/1/edit
@@ -100,85 +100,82 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
redirect_to :action => :index
else
# @summary_variable = @bulletin.summary_variable
@link_url = panel_announcement_back_end_bulletin_path(@bulletin)
get_tags
@link_url = panel_announcement_back_end_bulletin_path(@bulletin)
get_tags
end
end
# POST /bulletins
# POST /bulletins.xml
def create
get_tags
if params[:bulletin_link]
@bulletin_link = BulletinLink.new(params[:bulletin_link])
get_tags
if params[:bulletin_link]
respond_to do |format|
if @bulletin_link.save
format.js { render 'create_bulletin_link' }
end
end
elsif params[:bulletin_file]
@bulletin_file = BulletinFile.new(params[:bulletin_file])
@bulletin_link = BulletinLink.new(params[:bulletin_link])
respond_to do |format|
if @bulletin_file.save
format.js { render 'create_bulletin_file' }
end
end
else
@bulletin = Bulletin.new(params[:bulletin])
@bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
@bulletin.create_user_id = current_user.id
@bulletin.update_user_id = current_user.id
if(is_manager? || is_admin?)
@bulletin.is_checked = true
@bulletin.is_rejected = false
@bulletin.de_pending
end
respond_to do |format|
if @bulletin_link.save
format.js { render 'create_bulletin_link' }
end
end
respond_to do |format|
if @bulletin.save
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
# format.js
format.js {
@info = {"success"=>"true","redirect_url"=>panel_announcement_back_end_bulletins_url}
flash[:notice] = t('bulletin.create_bulletin_success')
render "/shared/preview/after_create.js.erb"
}
else
format.html { render :action => "new" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
format.js {
@info = {"success"=>"false","redirect_url"=>new_panel_announcement_back_end_bulletin_url(:bulletin => @bulletin)}
session[:in_validate_object] = @bulletin
render "/shared/preview/after_create.js.erb"
}
end
end
end
elsif params[:bulletin_file]
@bulletin_file = BulletinFile.new(params[:bulletin_file])
respond_to do |format|
if @bulletin_file.save
format.js { render 'create_bulletin_file' }
end
end
else
@bulletin = Bulletin.new(params[:bulletin])
@bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
@bulletin.create_user_id = current_user.id
@bulletin.update_user_id = current_user.id
if(is_manager? || is_admin?)
@bulletin.is_checked = true
@bulletin.is_rejected = false
@bulletin.de_pending
end
respond_to do |format|
if @bulletin.save
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
# format.js
format.js {
@info = {"success"=>"true","redirect_url"=>panel_announcement_back_end_bulletins_url}
flash[:notice] = t('bulletin.create_bulletin_success')
render "/shared/preview/after_create.js.erb"
}
else
format.html { render :action => "new" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
format.js {
@info = {"success"=>"false","redirect_url"=>new_panel_announcement_back_end_bulletin_url(:bulletin => @bulletin)}
session[:in_validate_object] = @bulletin
render "/shared/preview/after_create.js.erb"
}
end
end
end
end
def link_quick_add
def link_quick_add
@bulletin_link = BulletinLink.new
@link_url = panel_announcement_back_end_bulletins_path
@bulletin_link.bulletin_id = params[:bulletin_id]
respond_to do |format|
format.js
end
end
def link_quick_edit
@@ -189,14 +186,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
end
def file_quick_add
def file_quick_add
@bulletin_file = BulletinFile.new
@file_url = panel_announcement_back_end_bulletins_path
@bulletin_file.bulletin_id = params[:bulletin_id]
respond_to do |format|
format.js
end
end
def file_quick_edit
@@ -211,75 +207,71 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# PUT /bulletins/1.xml
def update
if params[:bulletin_link]
@bulletin_link = BulletinLink.find(params[:id])
if params[:bulletin_link]
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
@bulletin_link = BulletinLink.find(params[:id])
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
respond_to do |format|
if @bulletin_link.update_attributes(params[:bulletin_link])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js { render 'update_bulletin_link' }
end
end
elsif params[:bulletin_file]
@bulletin_file = BulletinFile.find(params[:id])
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
respond_to do |format|
if @bulletin_link.update_attributes(params[:bulletin_link])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js { render 'update_bulletin_link' }
end
end
respond_to do |format|
if @bulletin_file.update_attributes(params[:bulletin_file])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js { render 'update_bulletin_file' }
end
end
else
@bulletin = Bulletin.find(params[:id])
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
# if params[:bulletin][:image_del] == '1'
# @bulletin.remove_image!
# @bulletin.image_del = nil
# params[:bulletin][:image_del] = nil
# end
elsif params[:bulletin_file]
@bulletin_file = BulletinFile.find(params[:id])
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
respond_to do |format|
if @bulletin_file.update_attributes(params[:bulletin_file])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js { render 'update_bulletin_file' }
end
end
else
@bulletin = Bulletin.find(params[:id])
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
# if params[:bulletin][:image_del] == '1'
# @bulletin.remove_image!
# @bulletin.image_del = nil
# params[:bulletin][:image_del] = nil
# end
delete_out_invalid_date_from_params
respond_to do |format|
if @bulletin.update_attributes(params[:bulletin])
if(is_manager? || is_admin?)
@bulletin.is_checked = true
@bulletin.is_rejected = false
@bulletin.de_pending!
end
# if (params[:bulletin][:is_checked] == "false")
# @bulletin.is_rejected = true
# @bulletin.save!
# end
# if (@bulletin.deadline < @bulletin.postdate rescue nil)
# @bulletin.deadline = nil
# @bulletin.update_user_id = current_user.id
# @bulletin.save!
# end
# 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
format.html { render :action => "edit" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end
end
delete_out_invalid_date_from_params
respond_to do |format|
if @bulletin.update_attributes(params[:bulletin])
if(is_manager? || is_admin?)
@bulletin.is_checked = true
@bulletin.is_rejected = false
@bulletin.de_pending!
end
# if (params[:bulletin][:is_checked] == "false")
# @bulletin.is_rejected = true
# @bulletin.save!
# end
# if (@bulletin.deadline < @bulletin.postdate rescue nil)
# @bulletin.deadline = nil
# @bulletin.update_user_id = current_user.id
# @bulletin.save!
# end
# 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
format.html { render :action => "edit" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end
end
end
end
@@ -291,7 +283,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin.destroy
respond_to do |format|
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
# format.xml { head :ok }
format.js
@@ -299,21 +291,21 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
# def top_edit
# Bulletin.where(id: params[:id]).update_all( is_top: true )
# respond_to do |format|
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
# format.xml { head :ok }
# end
# Bulletin.where(id: params[:id]).update_all( is_top: true )
# respond_to do |format|
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
# format.xml { head :ok }
# end
# end
def load_quick_edit
@bulletin = Bulletin.find(params[:id])
@type = params[:type]
@bulletin_categories = BulletinCategory.all
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
get_tags
end
@@ -325,9 +317,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end
protected
def delete_out_invalid_date_from_params
if((params[:bulletin]["deadline(1i)"] && params[:bulletin]["deadline(1i)"].blank?) or (params[:bulletin]["deadline(2i)"] && params[:bulletin]["deadline(2i)"].blank?) or (params[:bulletin]["deadline(3i)"] && params[:bulletin]["deadline(3i)"].blank?))
params[:bulletin].delete("deadline(1i)")
@@ -361,10 +353,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# redirect_to :action => :index
# end
# end
def get_tags
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
end
def clean_values
@@ -377,5 +369,4 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end rescue nil
end
end
end
@@ -31,14 +31,14 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
date_now = Time.now
if !@category_id.blank?
@bulletins = Bulletin.can_display.where(:bulletin_category_id => @category_id).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:bulletin_category_id => @category_id).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
@current_category = BulletinCategory.from_id(@category_id) rescue nil
elsif !params[:tag_id].blank?
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
@bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
@bulletins = @tag.bulletins.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
else
@bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
end
get_categorys
@@ -18,9 +18,14 @@ module Panel::Announcement::BackEnd::BulletinsHelper
end
def show_delete_link(bulletin)
by_bulletin = (bulletin.create_user_id == current_user.id)
by_user = (is_manager? or is_admin?)
by_bulletin or by_user
if !current_user.nil?
by_bulletin = (bulletin.create_user_id == current_user.id )
by_user = (is_manager? or is_admin?)
by_bulletin or by_user
else
false
end
end
def show_bulletin_title_at_index (bulletin)
+1 -14
View File
@@ -10,6 +10,7 @@ class Bulletin
BelongsToCategory = :bulletin_category
include OrbitCoreLib::BelongsToCategoryMayDisable
include OrbitCoreLib::Preview
is_impressionable :counter_cache => { :column_name => :view_count }
field :title, localize: true
@@ -21,7 +22,6 @@ class Bulletin
field :postdate , :type => DateTime
field :deadline , :type => DateTime
# field :url
field :cache_dept,type: Hash
field :create_user_id
field :update_user_id, :class_name => "User"
@@ -42,12 +42,6 @@ class Bulletin
scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
mount_uploader :image, ImageUploader
# belongs_to :unit_list_for_anc
# embeds_many :bulletin_links, :cascade_callbacks => true
# embeds_many :bulletin_files, :cascade_callbacks => true
has_many :bulletin_links, :autosave => true, :dependent => :destroy
has_many :bulletin_files, :autosave => true, :dependent => :destroy
@@ -58,9 +52,6 @@ class Bulletin
validates :title, :at_least_one => true
before_save :check_deadline, :update_avliable_language, :clean_values
before_create :update_avliable_language
before_save :fetch_dept
searchable do
text :titles do
@@ -240,10 +231,6 @@ class Bulletin
end
end
end
def fetch_dept
self.cache_dept = (User.find(self.create_user_id).cache_dept rescue nil) if self.new_record?
end
def clean_values
self.bulletin_links.each do |link|
@@ -7,6 +7,38 @@
<div id="sub-wiget">
<div id="widget-picture" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Upload pictures" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-picture icons-white"></i><%= t('nccu.picture') %></h3>
<div class="widget-content clear">
<div class="control-group">
<!-- <img class="pull-left upload-picture" src="/assets/default-img.png" /> -->
<div class="upload-picture">
<% if @bulletin.image %>
<%= image_tag @bulletin.image rescue ''%>
<% else %>
<img class="pull-left upload-picture" src="/assets/default-img.png" />
<% end %>
</div>
<span class="alert widgetInfo"><%= t("ad.widget_info_for_ad_image_size", :best_size=> "290px x 150px") %></span>
<div class="controls file-upload input-prepend">
<%= t(:browse) %>
<%= f.file_field :image, :id => "input-upload", :class => '', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %>
<!-- <span id='fu' class="file-name"></span>
<br>
<input name='fu' class="input-medium" type="text">
<br> -->
<% if @bulletin.image.file %>
<%= f.check_box :remove_image %>
<%= t(:delete_file) %>
<% end %>
</div>
</div>
</div>
</div>
<div id="widget-date" class="widget-box widget-size-300">
<div class="widget-action clear">
<a href="#" class="action"><i title="Set the announcement to start and end dates" class="icon-exclamation-sign icon-white tip"></i></a>
@@ -127,6 +159,13 @@
<% end %>
</div>
<div class="editor">
<%= f.label :subtitle, t(:subtitle) %>
<%= f.fields_for :subtitle_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :rows => 5, :style=>"width:100%", :value => (@bulletin.subtitle_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="editor">
<%= f.label :text ,t(:text)%>
@@ -214,23 +253,6 @@
<p><%= t("sys.limit_of_upload_file_size",:best_size => '3MB') %></p>
<p><%= t("sys.preview_only_for_img") %></p>
</div>
<fieldset>
<input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="300000" />
<div id="filedrag">
<div class="point">Drop files here
<span>or</span>
<label class="file-select" for="fileselect">select from a folder
<!-- <input type="file" class="upload" id="fileselect" name="fileselect[]" multiple="multiple" /> -->
<%= f.fields_for @bulletin.bulletin_files.build, do |f| %>
<%= f.file_field :file, :multiple => true, :class => 'upload', :id => 'fileselect' %>
<% end %>
</label>
</div>
</div>
<div id="submitbutton">
<button type="submit">Upload Files</button>
</div>
</fieldset>
<div>
<table class="table table-condensed">
<thead>
@@ -16,12 +16,6 @@
</div>
</div>
<div id="news_bulletin_file_qe">
<div id="modal-file" class="modal fade">
<%#= render :partial => "bulletin_file_qe" %>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "bulletin_form" %>
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
@@ -225,39 +225,40 @@
</ul>
</div>
<table class="table table-bordered">
<tr>
<%= content_tag (:th) do %>
<%= t(:category) %>
<% end if (!params[:search_query].blank? or params[:category_id].blank?)-%>
<th><%= t(:title) %></th>
<th><%= t(:postdate) %></th>
</tr>
<% if !params[:name].blank?%>
<%= t("search.unit_get",:unit_name => params[:name],:item_num=>@bulletins.count) %>
<% end %>
<table class="table table-bordered">
<tr>
<%= content_tag (:th) do %>
<%= t(:category) %>
<% end if (!params[:search_query].blank? or params[:category_id].blank?)-%>
<th><%= t(:title) %></th>
<th><%= t(:postdate) %></th>
</tr>
<% if !params[:name].blank?%>
<%= t("search.unit_get",:unit_name => params[:name],:item_num=>@bulletins.count) %>
<% end %>
<% if @bulletins.blank? and !params[:search_query].blank? %>
<%=render :partial => 'shared/search_not_found' %>
<% elsif !params[:search_query].blank? %>
<%= t("search.result_get",:search_word => params[:search_query],:item_num=>@bulletins.count) unless (@bulletins.count == 30) %>
<%= t("search.too_many",:search_word => params[:search_query],:exceed_num=>@bulletins.count) if (@bulletins.count ==30) %>
<% end %>
<% if @bulletins.blank? and !params[:search_query].blank? %>
<%=render :partial => 'shared/search_not_found' %>
<% elsif !params[:search_query].blank? %>
<%= t("search.result_get",:search_word => params[:search_query],:item_num=>@bulletins.count) unless (@bulletins.count == 30) %>
<%= t("search.too_many",:search_word => params[:search_query],:exceed_num=>@bulletins.count) if (@bulletins.count ==30) %>
<% end %>
<% @bulletins.each do |post| %>
<tr class=<%= cycle('odd', '') %>>
<%= content_tag(:th) do%>
<td><%= (post.bulletin_category.title rescue nil ) %></td>
<% end if(!params[:search_query].blank? or params[:category_id].blank?) %>
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td class="date"><%= display_date_time(post.postdate) %></td>
</tr>
<% end %>
</table>
<% @bulletins.each do |post| %>
<tr class=<%= cycle('odd', '') %>>
<%= content_tag(:th) do%>
<td><%= (post.bulletin_category.title rescue nil ) %></td>
<% end if(!params[:search_query].blank? or params[:category_id].blank?) %>
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td class="date"><%= display_date_time(post.postdate) %></td>
</tr>
<% end %>
</table>
<% else %>
<table class="table table-bordered">
@@ -269,8 +270,8 @@
<% @bulletins.each do |post| %>
<tr>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] rescue nil %></td>
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
<td><%= post.bulletin_category.title rescue nil %></td>
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td><%= display_date_time(post.postdate) %></td>
@@ -10,13 +10,13 @@
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('bulletin.category') %></th>
<th class="span3"><%= t('bulletin.title') %></th>
<th class="span1"><%= t('bulletin.start_date') %></th>
<th class="span1"><%= t('bulletin.end_date') %></th>
<th class="span1"><%= t('bulletin.tags') %></th>
<th class="span1"><%= t('category') %></th>
<th class="span3"><%= t('title') %></th>
<th class="span1"><%= t('start_date') %></th>
<th class="span1"><%= t('end_date') %></th>
<th class="span1"><%= t('tags') %></th>
<% if not @user%>
<th class="span1"><%= t('bulletin.last_modified') %></th>
<th class="span1"><%= t('last_modified') %></th>
<% end %>
</tr>
</thead>
@@ -35,7 +35,7 @@
<% if not bulletin.deadline.nil?%>
<td><%= display_date_time(bulletin.deadline) %></td>
<%else%>
<td><%= t('bulletin.no_deadline') %></td>
<td><%= t('no_deadline') %></td>
<% end %>
<td>
<div class="label-group">
@@ -22,7 +22,7 @@
<td>
<span class="<%= wf[1] %>">
<% if wf[1] == 'title' %>
<%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
<% elsif wf[1] == 'date' %>
<%= display_date(post.send(wf[0])) %>
<% elsif wf[1] == 'category' %>
+15 -8
View File
@@ -6,11 +6,13 @@ Rails.application.routes.draw do
match 'approval_setting' => "approvals#setting" ,:as => :approval_setting,:via => :get
match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post
match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put
#match 'get_bulletins_json' => "bulletins#get_bulletins_json" ,:as => :bulletins_json_list,:via => :get
resources :bulletins do
match "approve/:bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put
match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post
match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add
match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit
member do
get 'load_quick_edit'
end
@@ -22,17 +24,22 @@ Rails.application.routes.draw do
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit
end
resources :bulletin_categorys
resources :bulletin_links, :controller => 'bulletin_links' do
resources :bulletin_categorys do
collection do
get 'get_categorys_json'
end
match "get_bulletins_json/" => "bulletin_categorys#get_bulletins_json", :as => :get_bulletins_json
end
resources :bulletin_links, :controller => 'bulletin_links' do
match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit
end
resources :bulletin_files, :controller => 'bulletin_files' do
resources :bulletin_files, :controller => 'bulletin_files' do
match "file_quick_edit/:bulletin_file_id" => "bulletin_files#file_quick_edit" ,:as => :file_quick_edit
end
resources :tags
end
namespace :front_end do
@@ -42,7 +49,7 @@ Rails.application.routes.draw do
# end
end
namespace :widget do
match "bulletins" => "bulletins#index"
match "index" => "bulletins#index"
match "bulletins_and_web_links" => "bulletins#bulletins_and_web_links"
match "reload_bulletins" => "bulletins#reload_bulletins"
match "reload_web_links" => "bulletins#reload_web_links"
@@ -1,7 +1,7 @@
class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :force_order_for_visitor,:only=>[:index]
before_filter :force_order_for_user,:except => [:index]
before_filter :for_app_sub_manager,:except => [:index]
def index
@@ -15,7 +15,7 @@
<div class="control-group">
<%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class =>' input-xxlarge', :value => (@archive_file_category.title[locale] rescue nil) %>
<%= f.text_field locale, :class =>' input-xxlarge', :value => (@archive_file_category.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
@@ -1,4 +1,4 @@
$("#<%= dom_id @archive_file_category %>").replaceWith("<%= j render :partial => 'link_category', :collection => [@archive_file_category] %>");
<% @archive_file_category = WebLinkCategory.new(:display => 'List') # reset for new form %>
$("#<%= dom_id @archive_file_category %>").replaceWith("<%= j render :partial => 'archive_file_category', :collection => [@archive_file_category] %>");
<% @archive_file_category = ArchiveFileCategory.new(:display => 'List') # reset for new form %>
$(".edit_archive_file_category").replaceWith("<%= j render "form" %>")
$(".new_archive_file_category")[0].reset();
@@ -10,12 +10,14 @@
<% if post.is_hidden? %>
<span class="label"><%= t(:hidden) %></span>
<% end %>
<% if is_manager?%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('archive_file.edit'), edit_panel_archive_back_end_archive_file_path(post) %></li>
<li><%= link_to t('archive_file.delete'), panel_archive_back_end_archive_file_path(post), :confirm => t('sure?'), :method => :delete, :remote => true %></li>
</ul>
</div>
<%end%>
</td>
<td><%= post.archive_file_category.title %></td>
<td>
@@ -242,7 +242,8 @@ var calendarAPI = function(){
this.loadMonthView = function(month,year){
$("#range_selection").hide();
$("#navigation").show();
$("#sec1").removeClass("span8").addClass("span3");
$("#sec1").removeClass("span7").addClass("span3");
$("#sec3").removeClass("span5").addClass("span4");
$("#sec2").show();
c.view = "month";
if(!month){
@@ -289,6 +290,7 @@ var calendarAPI = function(){
})
var doneEventArray = new Array();
var makerow = function(events){
var $eventrow =null;
var currow = 0;
var curdate = 0;
@@ -319,8 +321,6 @@ var calendarAPI = function(){
var recordcurdate = true;
if(allow){
if(evnt.title=="Navratri")
//console.log(pos);
if(pos == 1){
var colspan = 0;
if(evnt.total_days>7){
@@ -371,6 +371,7 @@ var calendarAPI = function(){
curparent = thisparent;
if(recordcurdate)
doneEventArray.push(evnt.index);
}
}
@@ -388,7 +389,8 @@ var calendarAPI = function(){
this.loadWeekView = function(week,year){
$("#range_selection").hide();
$("#navigation").show();
$("#sec1").removeClass("span8").addClass("span3");
$("#sec1").removeClass("span7").addClass("span3");
$("#sec3").removeClass("span5").addClass("span4");
$("#sec2").show();
c.view = "week";
if(!week){
@@ -512,7 +514,8 @@ var calendarAPI = function(){
this.loadDayView = function(day,month,year){
$("#range_selection").hide();
$("#navigation").show();
$("#sec1").removeClass("span8").addClass("span3");
$("#sec1").removeClass("span7").addClass("span3");
$("#sec3").removeClass("span5").addClass("span4");
$("#sec2").show();
c.view = "day";
if(!day){
@@ -594,7 +597,8 @@ var calendarAPI = function(){
$('#view_holder').load(url, function() {
$("#navigation").hide();
$("#range_selection").html($("#agenda_date_range").html()).show();
$("#sec1").removeClass("span3").addClass("span8");
$("#sec1").removeClass("span3").addClass("span7");
$("#sec3").removeClass("span4").addClass("span5");
$("#sec2").hide();
bindHandlers();
})
@@ -1,7 +1,7 @@
/* orbit calendar */
#orbit_calendar {
padding: 10px 8px;
min-width: 960px;
transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
@@ -338,6 +338,21 @@
margin: 4px 0 0 0;
}
/* category edit */
.edit_cal {
margin: -8px;
background-color: whitesmoke;
}
.edit_cal .table td, .edit_cal .table {
border: 0 !important;
background-color: transparent !important;
margin: 0 !important;
}
.main-list td {
border-top: solid 1px #ddd;
}
/* create / edit event panel */
#tags_panel {
top: auto;
@@ -1,7 +1,11 @@
class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
include AdminHelper
include Panel::Calendar::BackEnd::CalsHelper
before_filter :force_order_for_user
before_filter :force_order_for_visitor,:except=>[:new,:edit,:update,:create,:destroy]
before_filter :force_order_for_user,:only => [:new,:edit,:update,:create,:destroy]
before_filter :for_app_sub_manager,:only => [:new,:edit,:update,:create,:destroy]
def index
@calendars = Cal.all
end
@@ -1,8 +1,6 @@
<tr class="with_action" for="<%= calendar.id.to_s %>">
<td>
<span class="calendars_color_tag" style="background-color: <%= calendar.color %>"></span>
<div id="edit_area_<%= calendar.id %>" style="display:hidden;"></div>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t("calendar.edit"), edit_panel_calendar_back_end_cal_path(calendar), :remote => true, :class=>"btn-edit-a", :for => calendar.id %></li>
@@ -15,4 +13,7 @@
<%= calendar.name_translations[locale] %>
</td>
<% end %>
</tr>
<tr class="with_action">
<td colspan="3" id="edit_area_<%= calendar.id %>" style="display:none;"></td>
</tr>
@@ -42,7 +42,7 @@
<div id="calendar_agenda">
<% @datesets.each_with_index do |dateset,i| %>
<div class="row-fluid">
<div class="span3">
<div class="span4">
<h4><%= Date::MONTHNAMES[@calendartitle[i][0]] + " - " + @calendartitle[i][1].to_s %></h4>
<div class="tiny_calendar">
<table class="table">
@@ -71,7 +71,7 @@
</table>
</div>
</div>
<div class="span9">
<div class="span8">
<table class="table event_list">
<thead>
<tr height="0">
@@ -1,26 +1,23 @@
<%= form_for @calendar, :url => panel_calendar_back_end_cal_path(@calendar), :remote => true do |f| %>
<h4>Edit</h4>
<div class="row-fluid">
<div class="span2">
<%= label_tag("color", t("calendar.color")) %>
<%= f.text_field :color, :class => "color-picker miniColors", :size => "5", :maxlength => "5", :autocomplete=>"off",:value=>@calendar.color %>
</div>
</div>
<div>
<%= f.fields_for :name_translations do |name| %>
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="control-group">
<%= label_tag(locale, t("calendar.name")+"-"+I18nVariable.from_locale(locale)) %>
<div class="controls">
<%= name.text_field locale, :class => "input-xxlarge", :size=>"30", :value=>@calendar.name_translations[locale] %>
</div>
</div>
<table class="table" style="table-layout: fixed;">
<tr>
<td>
<!--<%= label_tag("color", t("calendar.color")) %>-->
<%= f.text_field :color, :class => "color-picker miniColors input-small", :maxlength => "5", :autocomplete=>"off",:value=>@calendar.color %>
</td>
<%= f.fields_for :name_translations do |name| %>
<% @site_valid_locales.each_with_index do |locale, i| %>
<td class="form-inline">
<%= name.text_field locale, :class => "input-large", :value=>@calendar.name_translations[locale] %>
</td>
<% end %>
<% end %>
<% end %>
</div>
<div class="">
<%= f.submit t("calendar.save"), :class=>"btn btn-primary" %>
<button class="btn btn-primary bt-cancel" for="<%= @calendar.id %>">Cancel</button>
</div>
</tr>
<tr>
<td colspan="3">
<%= f.submit t("calendar.save"), :class=>"btn btn-primary" %>
<button class="btn btn-primary bt-cancel" for="<%= @calendar.id %>">Cancel</button>
</td>
</tr>
</table>
<% end %>
@@ -58,6 +58,7 @@
</div>
<div id="view_holder"></div>
</div>
<% if is_manager? %>
<div class="form-actions form-fixed">
<div class="row-fluid">
<div class="span8">
@@ -67,6 +68,7 @@
</div>
</div>
</div>
<%end%>
<div id="event_create" class="modal" style="right: 8px; bottom: 50px; left: auto; top: auto; width: 380px; margin: 0;display:none;"></div>
<div id="event_quick_view" class="modal" style="width: 300px; display:none; margin:0 0 0 0;"></div>
@@ -1,5 +1,6 @@
<%= stylesheet_link_tag "jquery.miniColors" %>
<%= stylesheet_link_tag "calendar" %>
<%= stylesheet_link_tag "bootstrap-responsive" %>
<%= javascript_include_tag "jquery.miniColors.min" %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "calendarAPI" %>
@@ -57,7 +58,7 @@
<% end %>
<% end %>
</div>
<div class="form-actions pagination-right">
<div class="form-actions form-fixed pagination-right">
<%= f.submit t("calendar.save"), :class=>"btn btn-primary" %>
</div>
<% end %>
File diff suppressed because it is too large. Load diff
@@ -45,7 +45,7 @@ var galleryAPI = function(){
}else{
var cids = "all";
}
$.getJSON("panel/gallery/front_end/get_albums",{"cid":cids,"tid":tids,"inner":true},function(categories){
$.getJSON("/panel/gallery/front_end/get_albums",{"cid":cids,"tid":tids,"inner":true},function(categories){
$.each(categories,function(x,category){
$.each(category,function(i,album){
album.description = (album.description?album.description:"<%= I18n.t('gallery.no_description') %>")
@@ -16,7 +16,7 @@
}
.rg a:hover { }
.rg img { display: block; border: none;}
/*.rg img { display: block; border: none;}*/
.rgmask { background: #000; width: 100%; position: fixed; top: 0; left: 0; }
@@ -83,14 +83,14 @@
box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}
.rgphoto img, .rgphoto_edit img {
display: block;
/*display: block;*/
border-radius: 3px;
transition: all, 0.3s ease;
-webkit-transition: all, 0.3s ease;
-moz-transition: all, 0.3s ease;
}
.rgalbum .albumname {
font-size: 15px;
font-size: 18px;
padding: 6px 0;
display: block;
transition: background 0.3s ease;
@@ -105,14 +105,14 @@
.rgp .rgtitle { margin: 0 0 10px 0; }
/* Photo Edit */
.albumname_edit label, .albumname_edit .rginput, .rgphoto_edit img, .rgphoto_edit .rginput { float: left; }
.albumname_edit label, .albumname_edit .rginput, .rgphoto_edit > a, .rgphoto_edit .rginput { float: left; }
.rgphoto_edit, .albumname_edit {
clear: both;
overflow: hidden;
margin-bottom: 10px;
}
.albumname_edit label {
width: 120px;
width: 150px;
margin: 0 10px 0 0;
text-align: right;
padding: 0;
@@ -398,7 +398,7 @@
.rgih26 { width: 208px; }
.rgih26 span { }
.rgih26 input { width: 376px; }
.rgih26 input { width: 356px; }
.rgih26.focus { }
.rgih26.focus span { }
.rgih68 { width: 396px; }
@@ -408,7 +408,7 @@
.rgih68.focus span { }
.rgih98 { width: 396px; }
.rgih98 span { }
.rgih98 textarea { width: 376px; height: 80px; }
.rgih98 textarea { width: 356px; height: 110px; }
.rgih98.focus { }
.rgih98.focus span { }
@@ -476,7 +476,7 @@
.tag_search {
position: absolute;
left: -1px;
bottom: -32px;
bottom: -30px;
width: 200px;
height: 32px;
background-color: #f5f5f5;
@@ -552,3 +552,6 @@
padding-left: 12px;
padding-right: 12px;
}
.o_album_edit form {
margin-left: 8px;
}
@@ -16,7 +16,7 @@
}
.rg a:hover { }
.rg img { display: block; border: none; }
/*.rg img { display: block; border: none; }*/
.rgmask { background: #000; width: 100%; position: fixed; top: 0; left: 0; }
@@ -73,7 +73,7 @@
opacity: 0.85;
}
.rgphoto img, .rgphoto_edit img {
display: block;
/*display: block;*/
transition: all, 0.3s ease;
-webkit-transition: all, 0.3s ease;
@@ -0,0 +1,66 @@
.widget_gallery {
margin-bottom: 20px;
}
.widget_gallery:after {
display: table;
width: 100%;
content: '';
}
.widget_gallery ul {
list-style: none;
margin: 0;
padding: 0;
}
.widget_gallery li a {
display: block;
}
.widget_gallery li a img {
height: auto;
display: block;
}
/* widget 1 */
.w1 ul {
margin: 0 -1%;
}
.w1 li {
float: left;
margin: 1%;
}
.w1.c2 li { width: 48%; }
.w1.c3 li { width: 31.3333%; }
.w1.c4 li { width: 23%; }
.w1.c5 li { width: 18%; }
.w1.c6 li { width: 14.6666%; }
.w1 li a:hover {
box-shadow: 0 0 20px rgba(0,0,0,0.9);
outline: solid 4px #429DFF;
position: relative;
}
.w1 li a img {
width: 100%;
}
/* widget 2 */
.w2 li {
width: 100%;
}
.w2 li a img {
width: 100%;
height: auto;
}
.w2 li a {
position: relative;
overflow: hidden;
color: #fff;
text-transform: capitalize;
}
.w2 li a .desc {
position: absolute;
bottom: -60px;
opacity: 0;
display: block;
width: 100%;
padding: 5%;
background-color: rgba(8, 166, 255, 0.8);
}
@@ -2,8 +2,10 @@ class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController
include AdminHelper
# before_filter :force_order_for_visitor,:only=>[:index]
before_filter :force_order_for_user#,:except => [:index]
# before_filter :force_order_for_user#,:except => [:index]
before_filter :force_order_for_visitor,:only=>[:index,:show]
before_filter :force_order_for_user,:except => [:index,:show]
before_filter :for_app_sub_manager,:except => [:index,:show]
def show
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
@@ -1,190 +1,241 @@
class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
include AdminHelper
# before_filter :force_order_for_visitor,:only=>[:index]
before_filter :force_order_for_user#,:except => [:index]
include AdminHelper
def index
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
@categorylist = GalleryCategory.all
@cid = params['cat']
@tags = GalleryTag.all
end
# before_filter :force_order_for_user, :except => [:index,:get_album_json,:get_imgs_json]
def show
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
@album = GalleryAlbum.find(params[:id])
@tags = GalleryTag.all
end
before_filter :force_order_for_visitor,:only=>[:index,:show,:get_album_json,:get_imgs_json,:get_albums,:imgs]
before_filter :force_order_for_user,:except => [:index,:show,:get_album_json,:get_imgs_json,:get_albums,:imgs]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_album_json,:get_imgs_json,:get_albums,:imgs]
# before_filter lambda
def index
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
@categorylist = GalleryCategory.all
@cid = params['cat']
@tags = GalleryTag.all
end
def new
if is_manager? || is_admin?
@categorylist = GalleryCategory.all
elsif is_sub_manager?
@categorylist = GalleryCategory.authed_for_user(current_user,"new_album")
end
@album = GalleryAlbum.new
render :layout => false
end
def show
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
@album = GalleryAlbum.find(params[:id])
@tags = GalleryTag.all
end
def create
album = GalleryAlbum.new(params[:gallery_album])
album.save!
respond_to do |h|
h.js
end
end
def new
if is_manager? || is_admin?
@categorylist = GalleryCategory.all
elsif is_sub_manager?
@categorylist = GalleryCategory.authed_for_user(current_user,"new_album")
end
@album = GalleryAlbum.new
render :layout => false
end
def get_albums
@categoryids = params["cid"]
@tags = params["tid"]
@albums = Array.new
if @categoryids == "all"
if @tags
if @tags.kind_of?(Array)
@tags.each do |tag|
@albums << GalleryAlbum.where(tag_ids: tag)
end
else
@albums << GalleryAlbum.where(tag_ids: @tags)
end
else
@albums << GalleryAlbum.all
end
else
@categoryids.each do |id|
category = GalleryCategory.find(id)
if @tags
if @tags.kind_of?(Array)
@tags.each do |tag|
@albums << category.gallery_albums.where(tag_ids: tag)
end
else
@albums << category.gallery_albums.where(tag_ids: @tags)
end
else
@albums << category.gallery_albums.all
end
end
end
@output = Array.new
@albums.each do |album|
@albs = Array.new
album.each do |values|
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
category = GalleryCategory.find(values.gallery_category_id).name
@albs << {"_id"=>values.id,"show_path"=>panel_gallery_back_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
end
@output << @albs
end
render :json=>@output.to_json
end
def create
album = GalleryAlbum.new(params[:gallery_album])
album.save!
respond_to do |h|
h.js
end
end
def destroy
album = GalleryAlbum.find(params[:id])
album.delete
render :json =>{"success"=>true}.to_json
end
def get_albums
@categoryids = params["cid"]
@tags = params["tid"]
@albums = Array.new
if @categoryids == "all"
if @tags
if @tags.kind_of?(Array)
@tags.each do |tag|
@albums << GalleryAlbum.where(tag_ids: tag)
end
else
@albums << GalleryAlbum.where(tag_ids: @tags)
end
else
@albums << GalleryAlbum.all
end
else
@categoryids.each do |id|
category = GalleryCategory.find(id)
if @tags
if @tags.kind_of?(Array)
@tags.each do |tag|
@albums << category.gallery_albums.where(tag_ids: tag)
end
else
@albums << category.gallery_albums.where(tag_ids: @tags)
end
else
@albums << category.gallery_albums.all
end
end
end
@output = Array.new
@albums.each do |album|
@albs = Array.new
album.each do |values|
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
category = GalleryCategory.find(values.gallery_category_id).name
@albs << {"_id"=>values.id,"show_path"=>panel_gallery_back_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
end
@output << @albs
end
render :json=>@output.to_json
end
def edit
if is_manager? || is_admin? || is_sub_manager?
@album = GalleryAlbum.find(params[:id])
@images = @album.gallery_images.all
@album_name = @album.name_translations
@cover = @album.cover
@tags = GalleryTag.all
end
end
def destroy
album = GalleryAlbum.find(params[:id])
album.delete
render :json =>{"success"=>true}.to_json
end
def set_cover
album = GalleryAlbum.find(params[:album_id])
image = GalleryImage.find(params[:imageid])
album.update_attributes({:cover_path => image.file.thumb.url, :cover=>params[:imageid]})
render :json =>{"success"=>true}.to_json
end
def edit
if is_manager? || is_admin? || is_sub_manager?
@album = GalleryAlbum.find(params[:id])
@images = @album.gallery_images.all
@album_name = @album.name_translations
@cover = @album.cover
@tags = GalleryTag.all
end
end
def imgs
@album = GalleryAlbum.find(params[:album_id])
@tag_names = Array.new
@images = @album.gallery_images.all
@output = Array.new
@images.each do |values|
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
@output << {"_id"=>values.id,"theater_link"=>panel_gallery_back_end_album_image_path(values),"description"=>values.description,"title"=>values.title,"file"=>values.file,"gallery_album_id"=>values.gallery_album_id,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
end
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
if @authenticated
render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json
else
@album.tag_ids.each do |tag|
@tag_names << GalleryTag.find(tag)[I18n.locale]
end
render :json=>{"images" => @output, "tags" => @album.tag_ids, "tag_names" => @tag_names}.to_json
end
end
def upload_panel
@album = GalleryAlbum.find(params[:album_id])
render :layout => false
end
def upload_image
@album = GalleryAlbum.find(params[:album_id])
@files = params['files']
a = Array.new
@files.each do |file|
@image = @album.gallery_images.new
@image.file = file
@image.save!
a << {"thumbnail_url"=>@image.file.thumb.url}
end
render :json=>a.to_json
end
def images_tags
album = GalleryAlbum.find(params[:album_id])
tags = Array.new
images = album.gallery_images.all
images.each do |image|
tags << {"id"=>image.id, "tags" => image.tag_ids}
end
render :json=>tags.to_json
end
def set_cover
album = GalleryAlbum.find(params[:album_id])
image = GalleryImage.find(params[:imageid])
album.update_attributes({:cover_path => image.file.thumb.url, :cover=>params[:imageid]})
render :json =>{"success"=>true}.to_json
end
def update
@album = GalleryAlbum.find(params[:id])
@album.update_attributes(params[:gallery_album])
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
if params['delete_cover'] == "true"
@album.update_attributes(:cover=>"default")
end
@tags = GalleryTag.all
render :action => :show
end
def get_album_json
albums = GalleryAlbum.all
output = Array.new
albums.each do |album|
tag_names = Array.new
album.tag_ids.each do |tag|
tag_names << GalleryTag.find(tag)[I18n.locale]
end
output << {
album_cover_file: "http://#{request.host_with_port}#{album.cover_path}",
album_name: album.name,
album_tag_names: tag_names,
album_link:"http://#{request.host_with_port}#{panel_gallery_back_end_album_get_imgs_json_path(album)}"
}
end
render :json=>JSON.pretty_generate(output)
end
def get_imgs_json
album = GalleryAlbum.find(params[:album_id])
images = album.gallery_images.all
output = Array.new
images.each do |image|
tags = Array.new
image.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
output << {
image_title: image.title,
image_description: image.description,
image_file: { url: "http://#{request.host_with_port}#{image.file.url}",
thumb: "http://#{request.host_with_port}#{image.file.thumb.to_s}"},
image_tag_names: tags}
end
render :json=>JSON.pretty_generate(output)
end
def imgs
@album = GalleryAlbum.find(params[:album_id])
@tag_names = Array.new
@images = @album.gallery_images.all
@output = Array.new
@images.each do |values|
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
@output << { _id: values.id,
theater_link: panel_gallery_back_end_album_image_path(values),
description: values.description,
title: values.title,
file: values.file,
gallery_album_id: values.gallery_album_id,
tag_ids: values.tag_ids,
tag_names: tags}
end
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
if @authenticated
render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json
else
@album.tag_ids.each do |tag|
@tag_names << GalleryTag.find(tag)[I18n.locale]
end
render :json=>{"images" => @output, "tags" => @album.tag_ids, "tag_names" => @tag_names}.to_json
end
end
def upload_panel
@album = GalleryAlbum.find(params[:album_id])
render :layout => false
end
def upload_image
@album = GalleryAlbum.find(params[:album_id])
@files = params['files']
a = Array.new
@files.each do |file|
@image = @album.gallery_images.new
@image.file = file
@image.save!
a << {"thumbnail_url"=>@image.file.thumb.url}
end
render :json=>a.to_json
end
def images_tags
album = GalleryAlbum.find(params[:album_id])
tags = Array.new
images = album.gallery_images.all
images.each do |image|
tags << {"id"=>image.id, "tags" => image.tag_ids}
end
render :json=>tags.to_json
end
def update
@album = GalleryAlbum.find(params[:id])
@album.update_attributes(params[:gallery_album])
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
if params['delete_cover'] == "true"
@album.update_attributes(:cover=>"default")
end
@tags = GalleryTag.all
render :action => :show
end
end
@@ -10,6 +10,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
@album.tag_ids.each do |tag|
@tags << GalleryTag.find(tag)[I18n.locale]
end
end
def get_albums
@@ -96,6 +97,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
tags.each do |tag|
@tagnames << GalleryTag.find(tag)[I18n.locale]
end
@back_link = panel_gallery_front_end_album_path(@albumid)
end
@@ -0,0 +1,23 @@
class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
def widget1
@settings = {"vertical"=>2,"horizontal"=>6} #[note] horizontal has it's limitation from 2 to 6
@class = "c" + @settings["horizontal"].to_s
@total = @settings["vertical"] * @settings["horizontal"]
@rnd = Random.new
@images = []
for i in 0..@total-1
@sn = @rnd.rand(0...GalleryImage.count)
if @sn < 0
@sn = @sn * -1
end
image = GalleryImage.skip(@sn).limit(1).first
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
@images << values
end
end
def widget2
end
end
@@ -5,7 +5,7 @@ class GalleryAlbum
field :name, localize: true
field :description, localize: true
field :cover, default: "default"
field :cover_path
field :cover_path #can refact
field :tag_names
belongs_to :gallery_category
@@ -30,6 +30,9 @@
</div>
</div>
</div>
<% if is_admin? %>
<!-- #TODO or 類別屬於他 -->
<!-- tag part -->
<div id="tag_panel" class="my_scroll">
<div class="scrollbar">
@@ -48,19 +51,21 @@
<div class="viewport">
<div class="overview">
<ul class="tag_list" id="gallery_tag_list">
<% if @authenticated %>
<%# if @authenticated %>
<% @tags.each do |tag| %>
<li data-content="<%= tag.id %>"><input id="tag_<%= tag.id %>" type="checkbox"><label for="tag_<%= tag.id %>"><%= tag[I18n.locale] %></label><span style="display:none;"><%= tag[@locales[1]] %> <%= tag[@locales[0]] %></span></li>
<% end %>
<% end %>
<%# end %>
</ul>
</div>
</div>
<% if @authenticated %>
<%# if @authenticated %>
<div class="tag_search"><div class="icon-search"></div><input type="text" value="<%= t('gallery.search_tags') %>" onblur="if(this.value=='')this.value='<%= t('gallery.search_tags') %>';" onfocus="if(this.value=='<%= t("gallery.search_tags") %>')this.value='';" id="tag_search_box"> <div class="tag_save"><a class="btn bt-save"><i class="icon-ok"></i><%= I18n.t("gallery.save") %></a></div></div>
<% end %>
<%# end %>
</div>
<%end%>
<script type="text/javascript">
var $tag_panel = $('#tag_panel');
@@ -82,11 +87,14 @@
<!-- tag end -->
<div class="form-actions form-fixed pagination-right rghead">
<div class="rgfn">
<a href="" class="bt-back btn pull-left" title="<%= I18n.t("gallery.back_to_photos") %>"><i class="icon-arrow-left icon-black"></i><%= I18n.t("gallery.back_to_photos") %></a>
<% if @authenticated %>
<a class="bt-edit btn btn-primary pull-right" title="<%= I18n.t("gallery.edit") %>" href="<%= edit_panel_gallery_back_end_album_path(@album) %>" ><i class="icon-pencil icon-white"></i><%= I18n.t("gallery.edit") %></a>
<%= link_to (content_tag(:i,I18n.t("gallery.back_to_photos"),:class=>"icon-arrow-left icon-black")),"",:class=>"bt-back btn pull-left btn-primary",:title=>I18n.t("gallery.back_to_photos")%>
<% if is_admin? %>
<!-- #TODO or類別屬於他 -->
<%= link_to (content_tag(:i,I18n.t("gallery.edit"),:class=>"icon-pencil icon-white")),edit_panel_gallery_back_end_album_path(@album),:class=>"bt-edit btn btn-primary pull-right",:title=>I18n.t("gallery.edit")%>
<%= link_to (content_tag(:i,I18n.t("gallery.photo_tag"),:class=>"icon-pencil icon-white")),'#tags',:class=>"bt-tag btn btn-primary pull-right",:title=>I18n.t("gallery.photo_tag")%>
<% end %>
<a class="bt-tag btn btn-primary pull-right" title="<%= I18n.t("gallery.photo_tag") %>" href="#tags" ><i class="icon-tag icon-white"></i><%= I18n.t("gallery.photo_tag") %></a>
</div>
</div>
</div>
@@ -1,4 +1,3 @@
<%= stylesheet_link_tag "gallery" %>
<div id="filter" class="subnav">
@@ -44,13 +43,16 @@
</div>
</div>
<% if is_sub_manager? %>
<div class="form-actions form-fixed pagination-right rghead">
<div class="rgfn">
<% if @authenticated %>
<a class="btn btn-primary pull-right" title="<%= I18n.t("gallery.add_album") %>" href="<%= new_panel_gallery_back_end_album_path %>" onclick="return false;"><i class="icon-plus icon-white"></i><%= I18n.t("gallery.add_album") %></a>
<% end %>
</div>
</div>
<%end %>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "galleryAPI" %>
@@ -7,6 +7,9 @@
</div>
</div>
<% if is_sub_manager? #TODO 或 這類別是他自己的 %>
<!-- tag part -->
<div id="tag_panel" class="my_scroll">
<div class="scrollbar">
@@ -25,18 +28,15 @@
<div class="viewport">
<div class="overview">
<ul class="tag_list" id="gallery_tag_list">
<% if @authenticated %>
<% @tags.each do |tag| %>
<li data-content="<%= tag.id %>"><input id="tag_<%= tag.id %>" type="checkbox"><label for="tag_<%= tag.id %>"><%= tag[I18n.locale] %></label><span style="display:none;"><%= tag[@locales[1]] %> <%= tag[@locales[0]] %></span></li>
<% end %>
<% end %>
</ul>
</div>
</div>
<% if @authenticated %>
<div class="tag_search"><div class="icon-search"></div><input type="text" value="<%= t('gallery.search_tags') %>" onblur="if(this.value=='')this.value='<%= t('gallery.search_tags') %>';" onfocus="if(this.value=='<%= t("gallery.search_tags") %>')this.value='';" id="tag_search_box"> <div class="tag_save"><a class="btn bt-save"><i class="icon-ok"></i><%= I18n.t("gallery.save") %></a></div></div>
<% end %>
<%end%>
</div>
<script type="text/javascript">
@@ -59,13 +59,23 @@
<!-- tag end -->
<div class="form-actions form-fixed pagination-right rghead">
<div class="rgfn">
<a class="bt-back btn btn-primary pull-left" title="<%= I18n.t("gallery.back_to_albums") %>" href="<%= panel_gallery_back_end_albums_path %>"><i class="icon-arrow-left icon-white"></i><%= I18n.t("gallery.back_to_albums") %></a>
<a class="bt-tag btn btn-primary pull-right" title="<%= I18n.t("gallery.album_tag") %>" href="" ><i class="icon-tag icon-white"></i><%= I18n.t("gallery.album_tag") %></ a>
<% if @authenticated %>
<a class="bt-add btn btn-primary pull-right" title="<%= I18n.t("gallery.add_images") %>" href="images" onclick="return false;"><i class="icon-plus icon-white"></i><%= I18n.t("gallery.add_images") %></a>
<a class="bt-del btn btn-primary pull-right" title="<%= I18n.t("gallery.del_album") %>" href="delete" onclick="return false;"><i class="icon-trash icon-white"></i><%= I18n.t("gallery.del_album") %></a>
<a class="bt-edit btn btn-primary pull-right" title="<%= I18n.t("gallery.edit") %>" href="<%= edit_panel_gallery_back_end_album_path(@album) %>" ><i class="icon-pencil icon-white"></i><%= I18n.t("gallery.edit") %></a>
<% end %>
<%= link_to (content_tag(:i,I18n.t("gallery.back_to_albums"),:class=>"icon-arrow-left icon-white")),panel_gallery_back_end_albums_path,:title=> I18n.t("gallery.back_to_albums") ,:class=>"bt-back btn btn-primary pull-left" %>
<%= link_to( (content_tag(:i,I18n.t("gallery.album_tag"),:class=>"icon-tag icon-white")),'',:title=> I18n.t("gallery.album_tag") ,:class=>"bt-tag btn btn-primary pull-right")if is_admin? %>
<!-- #TODO 或是類別屬於他 -->
<%= link_to (content_tag(:i,I18n.t("gallery.add_images"),:class=>"icon-plus icon-white")),'images',:title=> I18n.t("gallery.add_images") ,:class=>"bt-add btn btn-primary pull-right",:onclick=>"return false;" if is_admin?%>
<!-- #TODO 或是類別屬於他 -->
<%= link_to (content_tag(:i,I18n.t("gallery.del_album"),:class=>"icon-trash icon-white")),'delete',:title=> I18n.t("gallery.del_album") ,:class=>"bt-del btn btn-primary pull-right",:onclick=>"return false;" if is_admin?%>
<!-- #TODO 或是類別屬於他 -->
<%= link_to (content_tag(:i,I18n.t("gallery.edit"),:class=>"icon-plus icon-white")),edit_panel_gallery_back_end_album_path(@album),:title=> I18n.t("gallery.edit") ,:class=>"bt-edit btn btn-primary pull-right" if is_admin?%>
<!-- #TODO 或是類別屬於他 -->
</div>
</div>
</div>
@@ -36,7 +36,7 @@
gallery.loadAlbums(gallery.urlVars['tag']);
}else{
gallery.loadArea = "albums";
g.loadAlbums("all");
gallery.loadAlbums("all");
}
</script>
@@ -20,7 +20,7 @@
<!-- tag end -->
<div class="form-actions form-fixed pagination-right rghead">
<div class="rgfn">
<a class="bt-back rgbt" title="<%= I18n.t("gallery.back_to_albums") %>" href="gallery"><i class="icon-arrow-left"></i> <%= I18n.t("gallery.back_to_albums") %></a>
<a class="bt-back rgbt" title="<%= I18n.t("gallery.back_to_albums") %>" href="<%= panel_gallery_front_end_albums_path %>"><i class="icon-arrow-left"></i> <%= I18n.t("gallery.back_to_albums") %></a>
</div>
</div>
</div>
@@ -42,7 +42,7 @@
<!-- tag end -->
<div class="form-actions form-fixed pagination-right rghead">
<div class="rgfn">
<a class="bt-back rgbt" title="<%= I18n.t("gallery.back_to_albums") %>" href="gallery?id=<%= @albumid %>"><i class="icon-arrow-left"></i> <%= I18n.t("gallery.back_to_albums") %></a>
<a class="bt-back rgbt" title="<%= I18n.t("gallery.back_to_albums") %>" href="<%= @back_link %>"><i class="icon-arrow-left"></i> <%= I18n.t("gallery.back_to_albums") %></a>
</div>
</div>
</div>
@@ -14,7 +14,7 @@
</div>
</div>
<!-- tag part -->
<% if @authenticated %>
<%# if @authenticated %>
<div id="tag_panel" class="my_scroll">
<div class="scrollbar">
<div class="track">
@@ -41,7 +41,7 @@
<div class="tag_search"><div class="icon-search"></div><input type="text" value="<%= t('gallery.search_tags') %>" onblur="if(this.value=='')this.value='<%= t('gallery.search_tags') %>';" onfocus="if(this.value=='<%= t("gallery.search_tags") %>')this.value='';" id="tag_search_box"><div class="tag_save"><a class="btn bt-save"><i class="icon-ok"></i><%= I18n.t("gallery.save") %></a></div></div>
</div>
<% end %>
<%# end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "jquery.tinyscrollbar" %>
<% end %>
@@ -0,0 +1,20 @@
<%= stylesheet_link_tag "widget_gallery" %>
<%# content_for :page_specific_javascript do %>
<%#= javascript_include_tag "cycle" %>
<%# end %>
<div class="four columns">
<h4>Gallery Widget</h4>
<p>WIDGET 1</p>
<div class="widget_gallery w1 <%= @class %>">
<ul>
<% @images.each do |image| %>
<li><a href="<%= image['show_link'] %>" title="photo description 1"><img src="<%= image['thumb'] %>" alt=""/></a></li>
<% end %>
<!-- <li><a href="" title="photo description 2"><img src="images/assets/2.jpg" alt=""/></a></li>
<li><a href="" title="photo description 3"><img src="images/assets/3.jpg" alt=""/></a></li>
<li><a href="" title="photo description 4"><img src="images/assets/4.jpg" alt=""/></a></li>
<li><a href="" title="photo description 5"><img src="images/assets/5.jpg" alt=""/></a></li>
<li><a href="" title="photo description 6"><img src="images/assets/6.jpg" alt=""/></a></li> -->
</ul>
</div>
</div>
+58 -48
View File
@@ -1,54 +1,64 @@
Rails.application.routes.draw do
namespace :panel do
namespace :gallery do
namespace :back_end do
match "get_albums" => "albums#get_albums"
match "upload_image" => "albums#upload_image"
match "save_tags" => "tags#save_tags"
match "albums/save_tags" => "tags#save_tags"
resources :albums do
match "set_cover" => "albums#set_cover"
match "imgs" => "albums#imgs"
match "upload_panel" => "albums#upload_panel"
match "images_tags" => "albums#images_tags"
end
match "album_images/#!/:id" => "album_images#show"
resources :album_images
resources :gallery_categories
resources :tags
namespace :gallery do
namespace :back_end do
match "get_albums" => "albums#get_albums"
match "upload_image" => "albums#upload_image"
match "save_tags" => "tags#save_tags"
match "albums/save_tags" => "tags#save_tags"
resources :albums do
match "set_cover" => "albums#set_cover"
match "imgs" => "albums#imgs"
match "upload_panel" => "albums#upload_panel"
match "images_tags" => "albums#images_tags"
match "get_imgs_json" => "albums#get_imgs_json"
collection do
get "get_album_json"
end
end
namespace :front_end do
match "get_albums" => "albums#get_albums"
# match "orbit_galleries" => "orbit_galleries#index"
# match "gallery_category_save" => "orbit_galleries#new_category"
# match "categorylist" => "orbit_galleries#categorylist"
# match "gallery_category_delete" => "orbit_galleries#gallery_category_delete"
# match "add_album" => "orbit_galleries#add_album"
# match "create_album" => "orbit_galleries#create_album"
# match "get_albums" => "orbit_galleries#get_albums"
# match "upload_image" => "orbit_galleries#upload_image"
# match "upload_panel" => "orbit_galleries#upload_panel"
# match "get_images" => "orbit_galleries#get_images"
# match "theater" => "orbit_galleries#theater"
# match "delete_album" => "orbit_galleries#delete_album"
# match "edit_album" => "orbit_galleries#edit_album"
# match "set_cover" => "orbit_galleries#set_cover"
# match "delete_images" => "orbit_galleries#delete_images"
# match "update_album" => "orbit_galleries#update_album"
# match "save_tags" => "orbit_galleries#save_tags"
resources :albums do
member do
get "imgs"
get "theater"
end
end
resources :album_images
end
end
match "album_images/#!/:id" => "album_images#show"
resources :album_images
resources :gallery_categories
resources :tags
end
namespace :front_end do
match "orbit_galleries" => "orbit_galleries#index"
match "get_albums" => "albums#get_albums"
# match "orbit_galleries" => "orbit_galleries#index"
# match "gallery_category_save" => "orbit_galleries#new_category"
# match "categorylist" => "orbit_galleries#categorylist"
# match "gallery_category_delete" => "orbit_galleries#gallery_category_delete"
# match "add_album" => "orbit_galleries#add_album"
# match "create_album" => "orbit_galleries#create_album"
# match "get_albums" => "orbit_galleries#get_albums"
# match "upload_image" => "orbit_galleries#upload_image"
# match "upload_panel" => "orbit_galleries#upload_panel"
# match "get_images" => "orbit_galleries#get_images"
# match "theater" => "orbit_galleries#theater"
# match "delete_album" => "orbit_galleries#delete_album"
# match "edit_album" => "orbit_galleries#edit_album"
# match "set_cover" => "orbit_galleries#set_cover"
# match "delete_images" => "orbit_galleries#delete_images"
# match "update_album" => "orbit_galleries#update_album"
# match "save_tags" => "orbit_galleries#save_tags"
resources :albums do
member do
get "imgs"
get "theater"
end
end
resources :album_images
end
namespace :widget do
match "widget1" => "albums#widget1"
end
end
end
end
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
@@ -1,29 +1,77 @@
class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
def index
@newlocation = Location.new
end
def create
debugger
@newlocation = Location.new(params[:location])
@newlocation.save!
render :action => "index"
end
#before_filter :clean_values, :only => [:create, :update]
def get_locations
locations = Location.all
@data = Array.new
before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :delete]
before_filter :force_order_for_user,:except => [:get_locations,:index]
#before_filter :for_app_sub_manager,:except => [:index, :new, :edit, :delete, :get_locations]
locations.each do |location|
picurl = "http://"+request.host + location.file.url
thumburl = "http://"+request.host + location.file.thumb.url
@data << {"name"=>location.name,"pic_url"=>picurl,"thumb_url"=>thumburl,"description"=>location.description}
end
render :json => @data.to_json
end
def index
@locations = Location.all
respond_to do |format|
format.html # new.html.erb
format.json { render json: @locations }
end
end
def new
@location = Location.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @location }
end
end
def edit
@location = Location.find(params[:id])
end
def show
@location = Location.find(params[:id])
respond_to do |format|
format.html
format.json { render json: @location }
end
end
def create
@location = Location.new(params[:location])
@location.save!
redirect_to panel_gprs_back_end_locations_url
end
def update
@location = Location.find(params[:id])
@location.update_attributes(params[:location])
redirect_to panel_gprs_back_end_locations_url
end
def destroy
@location = Location.find(params[:id])
@location.destroy
redirect_to panel_gprs_back_end_locations_url
end
def get_locations
locations = Location.all
@data = Array.new
locations.each do |location|
picurl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.url}"
thumburl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.thumb.url}"
@data << { name: location.name,
pic_url: picurl,
thumb_url: thumburl,
longitude: location.longitude,
latitude: location.latitude,
description: location.description }
end
#print readable json
render :json => JSON.pretty_generate({location: @data})
#render :json => {location: @data}.to_json
end
end
@@ -0,0 +1,2 @@
module Panel::Gprs::BackEnd::LocationsHelper
end
+8 -9
View File
@@ -1,12 +1,11 @@
class Location
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :file, GprsUploader
mount_uploader :file, GprsUploader
field :name
field :description
field :longitude, type: Float
field :latitude, type: Float
end
field :name
field :description
field :longitude, type: Float
field :latitude, type: Float
end
@@ -0,0 +1,30 @@
<div class="control-group">
<label class="control-label" for="">Name</label>
<div class="controls">
<%= f.text_field :name, :class=>"span4", :placeholder => "Area" %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Picture</label>
<div class="controls">
<%= f.file_field :file %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Coordinates</label>
<div class="controls">
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %>
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Description</label>
<div class="controls">
<%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %>
</div>
</div>
<div class="control-group">
<div class="controls">
<%= f.submit "Save", :class=>"btn" %>
</div>
</div>
@@ -0,0 +1,4 @@
<%= form_for @location, :url=> panel_gprs_back_end_location_path(@location), :html => { :class=>"form-horizontal"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
@@ -1,42 +1,34 @@
<!-- <form class="form-horizontal"> -->
<%= form_for @newlocation, :url=>{:action => "create"}, :remote => true, :class=>"form-horizontal" do |f| %>
<div class="control-group">
<label class="control-label" for="">Name</label>
<div class="controls">
<!-- <input type="text" id="" class="span4" placeholder="Taipei 101"> -->
<%= f.text_field :name, :class=>"span4", :placeholder => "Area" %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Picture</label>
<div class="controls">
<!-- <input type="file" id=""> -->
<%= f.file_field :file %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Coordinates</label>
<div class="controls">
<!-- <input type="text" id="" class="span2" placeholder="long"> -->
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %>
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %>
<!-- <input type="text" id="" class="span2" placeholder="lat"> -->
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Description</label>
<div class="controls">
<!-- <textarea name="" id="" class="span4" cols="30" rows="5"></textarea> -->
<%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %>
</div>
</div>
<div class="control-group">
<div class="controls">
<!-- <textarea name="" id="" class="span4" cols="30" rows="5"></textarea> -->
<%= f.submit "Save", :class=>"btn" %>
</div>
</div>
<% end %>
<!-- </form> -->
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('location.picture') %></th>
<th class="span1"><%= t('location.name') %></th>
<th class="span1"><%= t('location.longitude') %></th>
<th class="span1"><%= t('location.latitude') %></th>
<th class="span3"><%= t('location.description') %></th>
<%if is_manager? %>
<th class="span1"><%= t('location.edit') %></th>
<th class="span1"><%= t('location.delete') %></th>
<% end %>
</tr>
</thead>
<tbody id="tbody_locations" class="sort-holder">
<% @locations.each do |location| %>
<tr class="with_action">
<td><%= image_tag(location.file, alt: location.file, size: "50x50" ) if !location.file.blank? %></td>
<td><%= location.name%></td>
<td><%= location.longitude%></td>
<td><%= location.latitude%></td>
<td><%= location.description%></td>
<%if is_manager? %>
<td><%= link_to 'Edit', edit_panel_gprs_back_end_location_path(location) %></td>
<td><%= link_to 'Destroy', panel_gprs_back_end_location_path(location), method: :delete , :confirm => t(:sure?) %></td>
<%end%>
</tr>
<% end %>
</tbody>
</table>
<%if is_manager? %>
<td><%= link_to 'New', new_panel_gprs_back_end_location_path %></td>
<% end %>
@@ -0,0 +1,3 @@
<%= form_for @location, :url=> panel_gprs_back_end_locations_path, :html => { :class=>"form-horizontal"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
+8 -10
View File
@@ -1,14 +1,12 @@
Rails.application.routes.draw do
namespace :panel do
namespace :gprs do
namespace :back_end do
namespace :panel do
namespace :gprs do
namespace :back_end do
match "locations/get_locations" => "locations#get_locations"
resources :locations
end
end
end
match "locations/get_locations" => "locations#get_locations"
resources :locations
end
end
end
end
@@ -0,0 +1,14 @@
require 'test_helper'
class Panel::Gprs::BackEnd::LocationsControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
test "should get edit" do
get :edit
assert_response :success
end
end
@@ -0,0 +1,4 @@
require 'test_helper'
class Panel::Gprs::BackEnd::LocationsHelperTest < ActionView::TestCase
end
-6
View File
@@ -1,6 +0,0 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/
-17
View File
@@ -1,17 +0,0 @@
source "http://rubygems.org"
# Declare your gem's dependencies in news.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# jquery-rails is used by the dummy application
gem "jquery-rails"
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
-20
View File
@@ -1,20 +0,0 @@
Copyright 2011 YOURNAME
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-3
View File
@@ -1,3 +0,0 @@
= News
This project rocks and uses MIT-LICENSE.
-39
View File
@@ -1,39 +0,0 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'News'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task :default => :test
@@ -1,45 +0,0 @@
$(document).ready(function(){
var topic1="0px";
var topic2="-948px";
var topic3="-1896px";
var topic_page=1;
$(".topic_prev").addClass("topic_prev_first");
$(document).on("click", ".topic_prev", function() {
if (topic_page !=1){
topic_page-=1;
}else{
}
if (topic_page == 1){
$("#topic_list").stop().animate({"left": topic1}, "slow");
$(".topic_prev").addClass("topic_prev_first");
}
if (topic_page == 2){
$("#topic_list").stop().animate({"left": topic2}, "slow");
$(".topic_prev").removeClass("topic_prev_first");
$(".topic_next").removeClass("topic_next_last");
}
if (topic_page == 3){
$("#topic_list").stop().animate({"left": topic3}, "slow");
$(".topic_prev").removeClass("topic_next_last");
}
});
$(document).on("click", ".topic_next", function() {
if (topic_page >=1 && topic_page <=2){
topic_page+=1;
}else{
}
if (topic_page == 1){
$("#topic_list").stop().animate({"left": topic1}, "slow");
$(".topic_prev").addClass("topic_prev_first");
}
if (topic_page == 2){
$("#topic_list").stop().animate({"left": topic2}, "slow");
$(".topic_prev").removeClass("topic_prev_first");
}
if (topic_page == 3){
$("#topic_list").stop().animate({"left": topic3}, "slow");
$(".topic_next").addClass("topic_next_last");
}
});
});
Whitespace-only changes.
Whitespace-only changes.
@@ -1,23 +0,0 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
# Set I18n.locale
def set_locale
# update session if passed
session[:locale] = params[:locale] if params[:locale]
# set locale based on session or default
begin
# check if locale is valid for non site pages
if !VALID_LOCALES.include?(session[:locale])
I18n.locale = I18n.default_locale
else
I18n.locale = session[:locale]
end
rescue
I18n.locale = I18n.default_locale
end
end
end
@@ -1,71 +0,0 @@
class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
before_filter :authenticate_user!
before_filter :is_admin?
include AdminHelper
def preview_and_approve
@news_bulletin = NewsBulletin.find params[:news_bulletin_id]
end
def approve
notice = ""
@news_bulletin = NewsBulletin.find params[:news_bulletin_id]
@news_bulletin.proc_check(params[:news_bulletin][:is_checked],params[:news_bulletin][:not_checked_reason])
@news_bulletin.de_pending
if @news_bulletin.save
notice = t('approval.pass')
else
notice = t('approval.not_pass')
end
redirect_to(panel_news_back_end_news_bulletins_url,:notice => notice)
end
def setting
@sys_users = User.all(conditions: {admin: false}).includes(:avatar)
@news_bulletin_categorys = NewsBulletinCategory.all
@options_from_collection_for_select_news_bulletin_categorys = @news_bulletin_categorys.collect{|bc| [bc.title,bc.id] }
if params.has_key? :news_category
@news_bulletin_categorys = NewsBulletinCategory.find params[:news_category][:id]
else
@news_bulletin_categorys = @news_bulletin_categorys.first
end
preload_object_auth = @news_bulletin_categorys.get_object_auth_by_title('fact_check')
@users_array = preload_object_auth.privilege_users rescue []
respond_to do |format|
format.html
format.js
end
end
def update_setting
object_auth = update_setting_by_params
if object_auth.save!
flash[:notice] = t('update.success_')
else
flash[:notice] = t('update.fail')
end
end
def user_list
@news_bulletin_category = NewsBulletinCategory.find params[:news_category][:id]
end
protected
def update_setting_by_params
category = NewsBulletinCategory.find params[:news_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 = []
if(is_manager? || is_admin?)
@news_bulletin_categorys = (id ? NewsBulletinCategory.find(id).to_a : NewsBulletinCategory.all)
elsif is_sub_manager?
@news_bulletin_categorys = NewsBulletinCategory.authed_for_user(current_user,'submit_new')
end
end
end
@@ -1,133 +0,0 @@
class Panel::News::BackEnd::NewsBulletinCategorysController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
before_filter :force_order_for_visitor,:only=>[:index]
before_filter :force_order_for_user,:except => [:index]
before_filter :for_app_sub_manager,:except => [:index]
def index
@news_bulletin_categorys = get_categories_for_index("NewsBulletinCategory")
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
@news_bulletin_category = NewsBulletinCategory.new(:display => 'List')
@url = panel_news_back_end_news_bulletin_categorys_path
respond_to do |format|
format.html # index.html.erb
# format.xml { render :xml => @news_bulletins }
format.js
end
end
# GET /news_bulletins/1
# GET /news_bulletins/1.xml
def show
@news_bulletin_category = NewsBulletinCategory.find(params[:id])
respond_to do |format|
format.html # show.html.erb
# format.xml { render :xml => @news_bulletin_category }
format.js
end
end
# GET /news_bulletins/new
# GET /news_bulletins/new.xml
def new
@news_bulletin_category = NewsBulletinCategory.new(:display => 'List')
respond_to do |format|
format.html # new.html.erb
# format.xml { render :xml => @news_bulletin_category }
format.js
end
end
def quick_edit
# debugger
@news_bulletin_category = NewsBulletinCategory.find(params[:news_bulletin_category_id])
@url = panel_news_back_end_news_bulletin_category_path(@news_bulletin_category)
respond_to do |format|
format.js
end
end
# GET /news_bulletins/1/edit
def edit
@news_bulletin_category = NewsBulletinCategory.find(params[:id])
@url = panel_news_back_end_news_bulletin_category_path(@news_bulletin_category)
respond_to do |format|
format.html
format.js
end
end
# POST /news_bulletins
# POST /news_bulletins.xml
def create
@news_bulletin_category = NewsBulletinCategory.new(params[:news_bulletin_category])
respond_to do |format|
if @news_bulletin_category.save
# format.html { redirect_to @news_bulletin_category, notice: 'Entry was successfully created.' }
format.html { redirect_to(panel_news_back_end_news_bulletin_categorys_url, :notice => t('news_bulletin.create_news_bulletin_category_success')) }
# format.xml { render :xml => @news_bulletin_category, :status => :created, :location => @news_bulletin_category }
format.js
else
format.html { render :action => "new" }
# format.xml { render :xml => @news_bulletin_category.errors, :status => :unprocessable_entity }
format.js { render action: "new" }
end
end
end
# PUT /news_bulletins/1
# PUT /news_bulletins/1.xml
def update
@news_bulletin_category = NewsBulletinCategory.find(params[:id])
@url = panel_news_back_end_news_bulletin_category_path(@news_bulletin_category)
respond_to do |format|
if @news_bulletin_category.update_attributes(params[:news_bulletin_category])
# format.html { redirect_to(panel_news_back_end_news_bulletin_category_url(@news_bulletin_category), :notice => t('news_bulletin_category.update_news_bulletin_category_success')) }
# format.html { redirect_to(panel_news_back_end_news_bulletin_categorys_url, :notice => t('news_bulletin_category.update_news_bulletin_category_success')) }
# format.xml { head :ok }
format.js
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
# format.xml { render :xml => @news_bulletin_category.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /news_bulletins/1
# DELETE /news_bulletins/1.xml
def destroy
@news_bulletin_category = NewsBulletinCategory.find(params[:id])
@news_bulletin_category.disable = @news_bulletin_category.disable ? false : true
if @news_bulletin_category.save!
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
respond_to do |format|
flash[:notice] = t("update.success_")
# flash[:error] += @bulletin_category.disable ? t(enable) : t(disable)
format.html { redirect_to(panel_announcement_back_end_news_bulletin_categorys_url) }
# format.xml { head :ok }
format.js
end
else
flash[:error] = t("update.fail")
format.html { render :action => "index" }
end
end
end
@@ -1,48 +0,0 @@
class Panel::News::BackEnd::NewsBulletinFilesController < ApplicationController
layout 'new_admin'
def index
@news_bulletin_files = NewsBulletinFile.all
respond_to do |format|
format.html # index.html.erb
# format.xml { render :xml => @news_bulletins }
format.js
end
end
# POST /news_bulletins
# POST /news_bulletins.xml
def create
@news_bulletin_file = NewsBulletinFile.new(params[:news_bulletin_file])
respond_to do |format|
if @news_bulletin_file.save
format.html { redirect_to(panel_news_back_end_news_bulletins_url) }
format.js
else
format.html { render :action => "new" }
format.js { render action: "new" }
end
end
end
# PUT /news_bulletins/1
# PUT /news_bulletins/1.xml
def update
@news_bulletin_file = NewsBulletinFile.find(params[:id])
respond_to do |format|
if @news_bulletin_file.update_attributes(params[:news_bulletin_file])
format.html { redirect_to(panel_news_back_end_news_bulletins_url) }
format.js
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
end
@@ -1,49 +0,0 @@
class Panel::News::BackEnd::NewsBulletinLinksController < ApplicationController
layout 'new_admin'
def index
@news_bulletin_links = NewsBulletinLink.all
respond_to do |format|
format.html # index.html.erb
# format.xml { render :xml => @news_bulletins }
format.js
end
end
# POST /news_bulletins
# POST /news_bulletins.xml
def create
@news_bulletin_link = NewsBulletinLink.new(params[:news_bulletin_link])
# @news_bulletin_link.news_bulletin_id = params[:news_bulletin_link][:news_bulletin_id]
respond_to do |format|
if @news_bulletin_link.save
format.html { redirect_to(panel_news_back_end_news_bulletins_url) }
format.js
else
format.html { render :action => "new" }
format.js { render action: "new" }
end
end
end
# PUT /news_bulletins/1
# PUT /news_bulletins/1.xml
def update
@news_bulletin_link = NewsBulletinLink.find(params[:id])
respond_to do |format|
if @news_bulletin_link.update_attributes(params[:news_bulletin_link])
format.html { redirect_to(panel_news_back_end_news_bulletins_url) }
format.js
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
end
@@ -1,407 +0,0 @@
class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
# before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,]
before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_news_bulletins]
before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_news_bulletins]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_news_bulletins]
before_filter :only => [ :new,:edit,:update,:create] do |controller|
controller.get_categorys('NewsBulletinCategory')
controller.get_unit_list
end
before_filter :clean_values, :only => [:create, :update]
def preview
#@preview_obj = Preview.create(:object=>params[:news_bulletin],:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
news_bulletin = NewsBulletin.new params
@preview_obj = news_bulletin.to_preview
@preview_obj.save
render '/shared/preview/preview.html.erb', :layout=>false
end
def index
# @news_bulletins = NewsBulletin.all
# @news_bulletins = NewsBulletin.desc("postdate desc")
get_categorys("NewsBulletinCategory",params[:news_bulletin_category_id])
get_tags
@filter = params[:filter]
new_filter = params[:new_filter]
if @filter && params[:clear]
@filter.delete(params[:type])
elsif @filter && new_filter
if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
@filter[new_filter[:type]].delete(new_filter[:id].to_s)
elsif @filter.has_key?(new_filter[:type])
@filter[new_filter[:type]] << new_filter[:id].to_s
else
@filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
end
elsif new_filter
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
end
# @news_bulletins = NewsBulletin.where("news_bulletin_category_id" => params[:news_bulletin_category_id]).desc("postdate") if params[:news_bulletin_category_id]
# @news_bulletins = NewsBulletin.search(params[:search], params[:category_id])
# @news_bulletins = NewsBulletin.all.order_by([params[:sort], params[:direction]])
# @news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_news_bulletins : NewsBulletin.all.page(params[:page]).per(10)
@news_bulletin_categories = get_categories_for_index("NewsBulletinCategory")
@news_bulletin_category_ids = @news_bulletin_categories.collect{|t| t.id.to_s} + [nil]
@news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("news_bulletin",:news_bulletin_category_id.in => @news_bulletin_category_ids) : get_viewable("news_bulletin",:news_bulletin_category_id.in => @news_bulletin_category_ids)
@news_bulletin_link = NewsBulletinLink.new
@link_url = panel_news_back_end_news_bulletins_path
@news_bulletin_file = NewsBulletinFile.new
@file_url = panel_news_back_end_news_bulletins_path
respond_to do |format|
format.html # index.html.erb
format.js { }
format.xml { render :xml => @news_bulletins }
end
end
# GET /news_bulletins/1
# GET /news_bulletins/1.xml
def show
@news_bulletin = NewsBulletin.find(params[:id])
get_tags
# get_categorys
# @news_bulletin_categorys = NewsBulletinCategory.where("_id" => params[:id])
# if params[:id]
# @news_bulletins = NewsBulletin.where("news_bulletin_category_id" => params[:id])
# else
# @news_bulletins = NewsBulletin.desc("postdate desc")
# end
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @news_bulletin }
end
end
# GET /news_bulletins/new
# GET /news_bulletins/new.xml
def new
if(session[:in_validate_object].blank?)
@news_bulletin = NewsBulletin.new
else
@news_bulletin = session[:in_validate_object]
session[:in_validate_object] = {}
end
@link_url = panel_news_back_end_news_bulletins_path
# @news_bulletin.news_bulletin_files.build
# @news_bulletin.news_bulletin_files.new
get_tags
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @news_bulletin }
end
end
# GET /news_bulletins/1/edit
def edit
@news_bulletin = NewsBulletin.find(params[:id])
if !current_user.admin? && (@news_bulletin.is_rejected? || @news_bulletin.is_checked?)
redirect_to :action => :index
else
# @summary_variable = @news_bulletin.summary_variable
@link_url = panel_news_back_end_news_bulletin_path(@news_bulletin)
get_tags
end
end
# POST /news_bulletins
# POST /news_bulletins.xml
def create
get_tags
if params[:news_bulletin_link]
@news_bulletin_link = NewsBulletinLink.new(params[:news_bulletin_link])
respond_to do |format|
if @news_bulletin_link.save
format.js { render 'create_news_bulletin_link' }
end
end
elsif params[:news_bulletin_file]
@news_bulletin_file = NewsBulletinFile.new(params[:news_bulletin_file])
respond_to do |format|
if @news_bulletin_file.save
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
format.js { render 'create_news_bulletin_file' }
end
end
else
@news_bulletin = NewsBulletin.new(params[:news_bulletin])
@news_bulletin.deadline = nil if (@news_bulletin.deadline < @news_bulletin.postdate rescue nil)
@news_bulletin.create_user_id = current_user.id
@news_bulletin.update_user_id = current_user.id
if(is_manager? || is_admin?)
@news_bulletin.is_checked = true
@news_bulletin.is_rejected = false
@news_bulletin.de_pending
end
respond_to do |format|
if @news_bulletin.save
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
format.html { redirect_to(panel_news_back_end_news_bulletins_url, :notice => t('news_bulletin.create_news_bulletin_success')) }
format.xml { render :xml => @news_bulletin, :status => :created, :location => @news_bulletin }
format.js
#format.json {render :json => {"success"=>"true","redirect_url"=>panel_news_back_end_news_bulletins_url,"notice" => t('news_bulletin.create_news_bulletin_success')}}
else
format.html { render :action => "new" }
format.xml { render :xml => @news_bulletin.errors, :status => :unprocessable_entity }
end
end
end
end
def link_quick_add
# debugger
@news_bulletin_link = NewsBulletinLink.new
@link_url = panel_news_back_end_news_bulletins_path
@news_bulletin_link.news_bulletin_id = params[:news_bulletin_id]
respond_to do |format|
format.js
end
end
def link_quick_edit
# debugger
@news_bulletin_link = NewsBulletinLink.find(params[:news_bulletin_id])
@link_url = panel_news_back_end_news_bulletin_path(@news_bulletin_link)
# @news_bulletin = NewsBulletin.find(params[:news_bulletin_id])
# @link_url = panel_news_back_end_news_bulletin_path(@news_bulletin)
respond_to do |format|
format.js
end
end
def file_quick_add
# debugger
@news_bulletin_file = NewsBulletinFile.new
@file_url = panel_news_back_end_news_bulletins_path
@news_bulletin_file.news_bulletin_id = params[:news_bulletin_id]
respond_to do |format|
format.js
end
end
def file_quick_edit
# debugger
@news_bulletin_file = NewsBulletinFile.find(params[:news_bulletin_id])
@file_url = panel_news_back_end_news_bulletin_path(@news_bulletin_file)
respond_to do |format|
format.js
end
end
# PUT /news_bulletins/1
# PUT /news_bulletins/1.xml
def update
if params[:news_bulletin_link]
@news_bulletin_link = NewsBulletinLink.find(params[:id])
@link_url = panel_news_back_end_news_bulletin_path(@news_bulletin_link)
respond_to do |format|
if @news_bulletin_link.update_attributes(params[:news_bulletin_link])
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
# format.html { redirect_to(panel_news_back_end_news_bulletins_url) }
format.js { render 'update_news_bulletin_link' }
end
end
elsif params[:news_bulletin_file]
@news_bulletin_file = NewsBulletinFile.find(params[:id])
@file_url = panel_news_back_end_news_bulletin_path(@news_bulletin_file)
respond_to do |format|
if @news_bulletin_file.update_attributes(params[:news_bulletin_file])
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
# format.html { redirect_to(panel_news_back_end_news_bulletins_url) }
format.js { render 'update_news_bulletin_file' }
end
end
else
@news_bulletin = NewsBulletin.find(params[:id])
@news_bulletin.deadline = nil if (@news_bulletin.deadline < @news_bulletin.postdate rescue nil)
@news_bulletin.update_user_id = current_user.id
# @news_bulletin.image.clear if params[:news_bulletin][:image_del] == '1'
# if params[:news_bulletin][:image_del] == '1'
# @news_bulletin.remove_image!
# @news_bulletin.image_del = nil
# params[:news_bulletin][:image_del] = nil
# end
delete_out_invalid_date_from_params
respond_to do |format|
if @news_bulletin.update_attributes(params[:news_bulletin])
if(is_manager? || is_admin?)
@news_bulletin.is_checked = true
@news_bulletin.is_rejected = false
@news_bulletin.de_pending!
end
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
# format.html { redirect_to(panel_news_back_end_news_bulletin_url(@news_bulletin), :notice => t('news_bulletin.update_news_bulletin_success')) }
format.html { redirect_to(panel_news_back_end_news_bulletins_url, :notice => t('update.success_')) }
format.js { render 'toggle_enable' }
format.xml { head :ok }
else
get_tags
format.html { render :action => "edit" }
format.xml { render :xml => @news_bulletin.errors, :status => :unprocessable_entity }
end
end
end
end
# DELETE /news_bulletins/1
# DELETE /news_bulletins/1.xml
def destroy
@news_bulletin = NewsBulletin.find(params[:id])
# @news_bulletin.news_bulletin_files.destroy
@news_bulletin.destroy
respond_to do |format|
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
format.html { redirect_to(panel_news_back_end_news_bulletins_url) }
# format.xml { head :ok }
format.js
end
end
# def top_edit
# NewsBulletin.where(id: params[:id]).update_all( is_top: true )
# respond_to do |format|
# format.html { redirect_to(panel_news_back_end_news_bulletins_url) }
# format.xml { head :ok }
# end
# end
def load_quick_edit
@news_bulletin = NewsBulletin.find(params[:id])
@type = params[:type]
@news_bulletin_categories = NewsBulletinCategory.all
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
get_tags
end
def delete
if params[:ids]
news_bulletins = NewsBulletin.any_in(:_id => params[:ids]).delete_all
end
redirect_to panel_news_back_end_news_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end
protected
def delete_out_invalid_date_from_params
if((params[:news_bulletin]["deadline(1i)"] && params[:news_bulletin]["deadline(1i)"].blank?) or (params[:news_bulletin]["deadline(2i)"] && params[:news_bulletin]["deadline(2i)"].blank?) or (params[:news_bulletin]["deadline(3i)"] && params[:news_bulletin]["deadline(3i)"].blank?))
params[:news_bulletin].delete("deadline(1i)")
params[:news_bulletin].delete("deadline(2i)")
params[:news_bulletin].delete("deadline(3i)")
@news_bulletin.deadline = nil
end rescue nil
end
# def get_categories_for_index(id = nil)
# @news_bulletin_categories = []
# if(is_manager? || is_admin?)
# @news_bulletin_categories = (id ? NewsBulletinCategory.admin_manager_all.find(id).to_a : NewsBulletinCategory.admin_manager_all)
# elsif is_sub_manager?
# @news_bulletin_categories = NewsBulletinCategory.all
# end
# @news_bulletin_categories
# end
# def get_categorys(id = nil)
# @news_bulletin_categorys = []
# @unit_list_for_anc = UnitListForAnc.all
# if(is_manager? || is_admin?)
# @news_bulletin_categorys = (id ? NewsBulletinCategory.admin_manager_all.find(id).to_a : NewsBulletinCategory.admin_manager_all)
# elsif is_sub_manager?
# @news_bulletin_categorys = NewsBulletinCategory.all.authed_for_user(current_user,'submit')
# end
# if @news_bulletin_categorys.empty? && params[:action] != "index"
# flash[:alert] = t("news_bulletin.error.no_avilb_cate_for_posting")
# redirect_to :action => :index
# end
# end
def get_unit_list
@unit_list_for_anc = UnitListForAnc.all
end
def get_tags
module_app = ModuleApp.first(:conditions => {:key => 'news'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
end
def clean_values
if params[:news_bulletin]
params[:news_bulletin][:news_bulletin_links_attributes].each_with_index do |link, index|
params[:news_bulletin][:news_bulletin_links_attributes].delete(index.to_s) if link[1]['url'].blank? and link[1]['title'].blank?
end rescue nil
params[:news_bulletin][:news_bulletin_files_attributes].each_with_index do |link, index|
params[:news_bulletin][:news_bulletin_files_attributes].delete(index.to_s) if link[1]['file'].blank? and link[1]['title'].blank?
end rescue nil
end
end
end
@@ -1,8 +0,0 @@
class Panel::News::BackEnd::TagsController < Admin::TagsController
def initialize
super
@app_title = 'news'
end
end
@@ -1,83 +0,0 @@
class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
def initialize
super
@app_title = 'news'
end
# GET /news_bulletins
# GET /news_bulletins.xml
def index_news_bulletins_by_unit
@page = Page.find(params[:page_id]) rescue nil
@news_bulletins=NewsBulletin.all.available_for_lang(I18n.locale).can_display.where("unit_list_for_anc_id"=>params[:name]).page( params[:page_main]).per(15).page( params[:page_main]).per(10)
render :index
end
def index
@page = Page.find(params[:page_id]) rescue nil
if !params[:search_query].blank?
# search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending=>false,:is_pending=>false}
# search_cond.merge!({:news_bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank?
@search = NewsBulletin.solr_search do
fulltext params[:search_query]
with(:frontend_search,true)
with(:available_lang).any_of([I18n.locale.to_s])
end
search_result = @search.results.collect{|result| result.id}
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).desc(:postdate).page( params[:page_main]).per(10)
else
date_now = Time.now
if !params[:category_id].blank? && !params[:tag_id].blank?
@tag = NewsTag.find(params[:tag_id]) rescue nil
@tag = NewsTag.where(key: params[:tag_id])[0] unless @tag
@news_bulletins = @tag.news_bulletins.available_for_lang(I18n.locale).can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(15)
@current_category = NewsBulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:category_id].blank?
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(15)
@current_category = NewsBulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@tag = NewsTag.find(params[:tag_id]) rescue nil
@tag = NewsTag.where(key: params[:tag_id])[0] unless @tag
@news_bulletins = @tag.news_bulletins.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(15)
else
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(15)
end
impressionist(@tag) if @tag
end
end
def show
if params[:preview] == "true"
preview_content
else
''
@news_bulletin = NewsBulletin.all.can_display.where(_id: params[:id]).first
if !@news_bulletin.disable? and !@news_bulletin.is_rejected
if @news_bulletin.enabled_for_lang(I18n.locale.to_s)
impressionist(@news_bulletin)
get_categorys
else
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
end
else
render :nothing => true, :status => 403
end
end
end
def preview_content
@news_bulletin = NewsBulletin.find params[:id] rescue nil
@news_bulletin = Preview.find(params[:id]).get_virtual_object if @news_bulletin.nil?
get_categorys
end
protected
def get_categorys
@news_bulletin_categorys = NewsBulletinCategory.all
end
end
@@ -1,73 +0,0 @@
class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController
# caches_page :home_banner
def initialize
super
@app_title = 'news'
end
# GET /news_bulletins
# GET /news_bulletins.xml
def index
@title = params[:part_title]
date_now = Time.now
if !params[:category_id].blank?
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5)
@current_category = NewsBulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@tag = NewsTag.find(params[:tag_id]) rescue nil
@tag = NewsTag.where(key: params[:tag_id])[0] unless @tag
@news_bulletins = @tag.news_bulletins.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5) rescue nil
else
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5)
end
end
def news_bulletins_and_web_links
@tags = NewsTag.all
@selected_tag = NewsTag.find(params[:id]) rescue @tags[0]
@news_bulletins = @selected_tag.get_visible_news_bulletins(:postdate).available_for_lang(I18n.locale).can_display.page(params[:page]).per(5) rescue nil
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links(:created_at).page(params[:page]).per(5) rescue nil
end
def reload_news_bulletins
@selected_tag = NewsTag.find(params[:tag_id])
@news_bulletins = @selected_tag.get_visible_news_bulletins(:postdate).available_for_lang(I18n.locale).can_display.page(params[:page]).per(5) rescue nil
end
def reload_web_links
@selected_tag = NewsTag.find(params[:tag_id])
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links(:created_at).page(params[:page]).per(5) rescue nil
end
def news_bulletins_side_bar
@tags_and_class = NewsTag.sorted_for_cloud
get_categorys
end
def news_bulletins_search_block
end
def home_banner
if !params[:category_id].blank?
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.where(:news_bulletin_category_id => params[:category_id]).widget_datas.limit(9)
elsif !params[:tag_id].blank?
@news_bulletins = NewsTag.find(params[:tag_id]).news_bulletins.available_for_lang(I18n.locale).can_display.widget_datas.limit(9) rescue nil
else
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.widget_datas.limit(9)
end
get_categorys
end
protected
def get_categorys
@news_bulletin_categorys = NewsBulletinCategory.all
end
end
View File
Whitespace-only changes.
@@ -1,17 +0,0 @@
module Panel::News::BackEnd::NewsBulletinCategorysHelper
include ActionView::Helpers::UrlHelper
def show_news_cate_permission_link(news_bulletin_category)
type = 'submit'
oa = news_bulletin_category.get_object_auth_by_title(type)
if oa.nil?
news_bulletin_category.object_auths.new(title: type ).save
oa = news_bulletin_category.get_object_auth_by_title(type)
end
# link_to t(:category_auth), edit_admin_object_auth_path(oa)
link_to t(:category_auth),admin_object_auth_ob_auth_path(oa)
end
end
@@ -1,33 +0,0 @@
module Panel::News::BackEnd::NewsBulletinsHelper
def news_show_reject_reason(news_bulletin)
by_news_bulletin = news_bulletin.is_rejected
by_user = (((news_bulletin.create_user_id == current_user.id) rescue nil) or is_manager? or is_admin?)
by_news_bulletin && by_user
end
def news_show_form_status_field(news_bulletin)
#by_news_bulletin = (!news_bulletin.is_expired? and news_bulletin.is_pending?)
by_user = ((news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) rescue nil) or is_manager? or is_admin?)
by_user
end
def news_show_approval_link(news_bulletin)
by_news_bulletin = (!news_bulletin.is_expired? and news_bulletin.is_pending?)
by_user = ((news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) rescue nil) or is_manager? or is_admin?)
by_news_bulletin and by_user
end
def news_show_delete_link(news_bulletin)
by_news_bulletin = (news_bulletin.create_user_id == current_user.id)
by_user = (is_manager? or is_admin?)
by_news_bulletin or by_user
end
def show_news_bulletin_title_at_index (news_bulletin)
if news_bulletin.is_checked?
link_to news_bulletin.title, panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => news_bulletin.news_bulletin_category.id) rescue ''
else
news_bulletin.title
end
end
end
View File
Whitespace-only changes.
View File
Whitespace-only changes.
-291
View File
@@ -1,291 +0,0 @@
# encoding: utf-8
class NewsBulletin
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
include Sunspot::Mongo
include Impressionist::Impressionable
BelongsToCategory = :news_bulletin_category
include OrbitCoreLib::BelongsToCategoryMayDisable
include OrbitCoreLib::Preview
# include Tire::Model::Search
# include Tire::Model::Callbacks
# include Redis::Objects
#scope :searchable,where(:is_checked=>true,:is_hidden=>false,:is_pending=>false)
is_impressionable :counter_cache => { :column_name => :view_count }
field :title, localize: true
field :subtitle, localize: true
field :text, localize: true
has_and_belongs_to_many :tags, :class_name => "NewsTag"
field :postdate , :type => DateTime
field :deadline , :type => DateTime
# field :url
field :create_user_id
field :update_user_id, :class_name => "User"
field :is_top, :type => Boolean, :default => false
field :is_hot, :type => Boolean, :default => false
field :is_hidden, :type => Boolean, :default => false
field :is_checked, :type => Boolean, :default => false
field :is_pending, :type => Boolean, :default => true
field :is_rejected, :type => Boolean, :default => false
field :view_count, :type => Integer, :default => 0
field :not_checked_reason
field :public, :type => Boolean, :default => true
scope :can_display, where(is_checked: true, is_rejected: false, is_pending: false)
scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
mount_uploader :image, ImageUploader
belongs_to :unit_list_for_anc
# embeds_many :news_bulletin_links, :cascade_callbacks => true
# embeds_many :news_bulletin_files, :cascade_callbacks => true
has_many :news_bulletin_links, :autosave => true, :dependent => :destroy
has_many :news_bulletin_files, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :news_bulletin_files, :allow_destroy => true
accepts_nested_attributes_for :news_bulletin_links, :allow_destroy => true
validates :title, :at_least_one => true
before_save :check_deadline
before_save :update_avliable_language, :clean_tags
after_save :save_news_bulletin_links
after_save :save_news_bulletin_files
# Tire.index 'news_bulletin' do
# delete
# create :mappings =>{
# :news_bulletin_by_title => {
# :properties=> {
# :title => { :type => 'string', :index => 'not_analyzed', :include_in_all => false },
# :body => {}
# }
# }
# :news_bulletin_by_body => {
# :properties=> {
# :body => { :type => 'string', :index => 'not_analyzed', :include_in_all => false },
# }
# }
# }
# end
# mapping do
# indexes :title, :analyzer => 'cjk', :boost => 10
# indexes :sub_titles, :analyzer => 'cjk', :boost => 5
# indexes :text, :analyzer => 'cjk'
# end
def type
"news_bulletin"
end
searchable do
text :titles do
title_translations.to_a.collect{|t| t[1]}
end
text :texts do
text_translations.to_a.collect{|t| Nokogiri::HTML(t[1]).text}
end
integer :view_count
string :available_lang , :multiple => true do
VALID_LOCALES.collect{|t| enabled_for_lang(t.to_sym) ? t : nil}.delete_if{|t| t.nil?}
end
boolean :frontend_search do
( !is_hidden && !is_pending && is_checked && !is_rejected )
end
string :news_bulletin_category_id
end
# redis_search_index(:title_field => :s_title,
# :alias_field => :s_title_en,
# :score_field => :view_count,
# :condition_fields => [:is_checked,:is_hidden,:news_bulletin_category_id,:is_pending],
# :ext_fields =>[])
# def gen_title_for_search
# # [s_title,s_title_en,s_text_en,s_text_zh_tw].join(' ')
# end
# def s_title
# self.
# end
# def s_title_was
# self.title_was["zh_tw"]
# end
# def s_title_en
# self.title_translations["en"]
# end
# def s_title_en_was
# self.title_was["en"]
# end
# def s_text_en
# Nokogiri::HTML(self.text.en).text
# end
# def s_text_zh_tw
# Nokogiri::HTML(self.text.zh_tw).text
# end
def share_item
Item.first(conditions:{name: 'news'})
end
def self.widget_datas( category_id = nil )
date_now = Time.now
# find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :postdate)
# where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate)
# any_of({ :title => "test" },{:deadline => nil, :title => "123"})
if category_id.to_s.size > 0
find(:all, :conditions => {news_bulletin_category_id: category_id}).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).any_of(is_hot: true, is_top: true).desc(:postdate)
else
any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).any_of(is_hot: true, is_top: true).desc(:postdate)
end
end
def proc_check(check,not_pass_info = "")
self.is_checked = true
if check =="true"
self.is_rejected = false
elsif check == "false"
self.is_rejected = true
self.not_checked_reason = not_pass_info
end
end
def enabled_for_lang(lang)
eval("self.available_for_#{lang}")
end
def de_pending
self.is_pending = false
end
def de_pending!
de_pending
self.save!
end
def is_expired?
Date.today > self.deadline ? true : false rescue false
#some dates might sat as nil so rescue false
end
def is_top?
self.is_top
end
def is_hot?
self.is_hot
end
def is_hidden?
self.is_hidden
end
def is_checked?
!self.is_pending && self.is_checked && (self.is_rejected == false)
end
def is_pending?
self.is_pending
end
def is_rejected?
!self.is_pending && self.is_rejected && (self.is_rejected == true)
end
def save_news_bulletin_links
self.news_bulletin_links.each do |t|
if t.should_destroy
t.destroy
end
end
end
def save_news_bulletin_files
self.news_bulletin_files.each do |t|
if t.should_destroy
t.destroy
end
end
end
def self.filter(news_bulletins)
news_bulletins.each do |news_bulletin|
p "#{news_bulletin.id}/#{news_bulletin.is_top}/#{news_bulletin.is_hot}/#{news_bulletin.is_hidden}"
end
return nil
end
def sorted_tags
tags.order_by(I18n.locale, :asc)
end
def to_preview
preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
preview_object.preview_files.build(:file=>self.news_bulletin["image"],:field_name_for_rebuild=>'image')
self.news_bulletin["news_bulletin_files_attributes"].each_with_index do |atr,idx|
preview_object.preview_files.build(:file=>self.news_bulletin["news_bulletin_files_attributes"][idx.to_s],:field_name_for_rebuild=>'news_bulletin_files',:file_in_array=>true)
end unless self.news_bulletin["news_bulletin_files_attributes"].nil?
self.news_bulletin["news_bulletin_links_attributes"].each_with_index do |atr,idx|
preview_object.preview_associations.build(:object=>self.news_bulletin["news_bulletin_links_attributes"][idx.to_s],:field_name_for_rebuild=>'news_bulletin_links',:object_in_array=>true)
end unless self.news_bulletin["news_bulletin_links_attributes"].nil?
preview_object.object = self.news_bulletin.except("news_bulletin_files_attributes","image","news_bulletin_links_attributes")
preview_object
end
protected
def update_avliable_language
VALID_LOCALES.each do |locale|
if (title_translations[locale].blank? rescue true)
self["available_for_#{locale}".to_sym] = false
else
self["available_for_#{locale}".to_sym] = true
end
end
end
def check_deadline
if(!self.deadline.nil? and (self.deadline < self.postdate ))
self.deadline = nil
end
end
def clean_tags
self.tag_ids.delete('')
end
end
@@ -1,30 +0,0 @@
# encoding: utf-8
class NewsBulletinCategory
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable
include OrbitCoreLib::ObjectDisable
ObjectAuthTitlesOptions = %W{submit_new fact_check}
AfterObjectAuthUrl = '/panel/news/back_end/news_bulletin_categorys'
# include Mongoid::MultiParameterAttributes
PAYMENT_TYPES = [ "List", "Picture" ]
APP_NAME = 'news'
field :key
field :display
field :title, localize: true
has_many :news_bulletins
def pp_object
title
end
def self.from_id(id)
NewsBulletinCategory.find(id) rescue nil
end
end
@@ -1,17 +0,0 @@
class NewsBulletinFile
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :file, AssetUploader
field :title, localize: true
field :description, localize: true
# field :to_save, :type => Boolean
field :should_destroy, :type => Boolean
belongs_to :news_bulletin
# embedded_in :news_bulletin
end
@@ -1,23 +0,0 @@
class NewsBulletinLink
include Mongoid::Document
include Mongoid::Timestamps
field :url
field :title, localize: true
field :should_destroy, :type => Boolean
belongs_to :news_bulletin
before_validation :add_http
validates :url, :presence => true, :format => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
protected
def add_http
unless self.url[/^http:\/\//] || self.url[/^https:\/\//]
self.url = 'http://' + self.url
end
end
end
-13
View File
@@ -1,13 +0,0 @@
class NewsTag < Tag
has_and_belongs_to_many :news_bulletins
def get_visible_news_bulletins(sort = :title)
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)
end
def news_bulletins
NewsBulletin.all.any_in(:_id => news_bulletin_ids)
end
end
View File
Whitespace-only changes.
@@ -1,40 +0,0 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "inc/permission-checkbox" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "bootstrap" %>
<%= javascript_include_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/search" %>
<% end %>
<%= form_tag('', :remote => true) %>
<div class="subnav">
<ul class="nav nav-pills filter">
<li class="accordion-group">
<div class="form-search" style="margin: 5px 10px;">
<%= label_tag :category, t(:category) %>
<%= select_tag "category_id", options_from_collection_for_select(@news_bulletin_categorys, "id", "key") %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
</div>
<%#= label_tag :role, t(:roles) %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag :action => "update_setting" do %>
<%= render :partial => "privilege_user", :locals => {:users => @users_array} %>
<div class="form-actions pagination-centered">
<%= submit_tag "Update", :class => 'btn' %>
</div>
<% end -%>
<% end -%>
</div>
<script type="text/javascript" charset="utf-8">
var availableTags = [];
$(function() {
$('#category_id').change(function() {
$(this).parents('form').submit();
});
</script>
@@ -1,69 +0,0 @@
<% 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_approve_path(news_bulletin),:method => :post, :html => {:class => 'clear'} do |f| %>
<%= f.label :approval_stat, t('approval.stat') %>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
<%= t('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('approval.not_pass') %>
<% end -%>
<%= label :is_checked_false, t('approval.not_pass_reason') %>
<%= f.text_field :not_checked_reason %>
<%= f.submit t(: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 -%>
@@ -1,44 +0,0 @@
<% 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("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 -%>
@@ -1,5 +0,0 @@
$('#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");
@@ -1,53 +0,0 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "inc/permission-checkbox" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/search" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %>
<%= 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(:category) %>
<%= select "news_category",'id', @options_from_collection_for_select_news_bulletin_categorys %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
<%= link_to t("approval.user_list"), panel_news_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t(:roles) %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag panel_news_back_end_approval_setting_path do %>
<%= render :partial => "layouts/users_checkbox_ary" %>
<div class="form-actions form-fixed pagination-right">
<%= submit_tag t(:update_), :class => 'btn btn-primary' %>
</div>
<% end -%>
<% end -%>
</div>
<script type="text/javascript" charset="utf-8">
var availableTags = [];
$(document).ready(function() {
$(".prevent_enter_submit_form").bind("keypress", function(e) {
if (e.keyCode == 13) {
return false;
}
});
$('#news_category_id').change(function() {
$.ajax({
type: 'GET',
dataType: "script",
url:$(this).parents("from").attr("href"),
data:$(this).parents("form").serialize()
});
});
});
</script>
@@ -1,2 +0,0 @@
$("#users_checkbox_ary").replaceWith('<%= escape_javascript(render :partial=> "layouts/users_checkbox_ary" )%>');
permissionCheckbox();
@@ -1 +0,0 @@
alert( "<% flash.each do |key, msg| %><%= msg %><% end%>");
@@ -1,2 +0,0 @@
$('#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%>"
@@ -1,55 +0,0 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "inc/permission-checkbox" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/search" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %>
<%= 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(:category) %>
<%= select "category",'id',@options_from_collection_for_select_bulletin_categorys %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
<%= link_to t(:submit_user_list), panel_news_back_end_news_bulletin_category_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t(:roles) %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag panel_news_back_end_news_bulletin_category_setting_path do %>
<%= render :partial => "privilege_user", :locals => {:users => @users_array} %>
<div class="form-actions form-fixed pagination-right">
<%= submit_tag "Update", :class => 'btn btn-primary' %>
</div>
<% end -%>
<% end -%>
</div>
<script type="text/javascript" charset="utf-8">
var availableTags = [];
$(document).ready(function() {
$(".prevent_enter_submit_form").bind("keypress", function(e) {
if (e.keyCode == 13) {
return false;
}
});
$('#category_id').change(function() {
$.ajax({
type: 'GET',
dataType: "script",
url:$(this).parents("from").attr("href"),
data:$(this).parents("form").serialize()
});
});
});
</script>
@@ -1,37 +0,0 @@
<% # encoding: utf-8 %>
<%= form_for(@news_bulletin_category, :remote => true, :url => @url) do |f| %>
<h2><%= (@news_bulletin_category.new_record? ? t(:edit) : t(:add)) %></h2>
<div id="widget-title">
<%= f.label :key, t(:key) %>
<%= f.text_field :key %>
</div>
<div id="widget-title">
<%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "name-#{locale}", "#{t(:name)}-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge', :value => (@news_bulletin_category.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div id="widget-title">
<%#= f.label :display %>
<%#= f.radio_button :display, "List" List%>
<%#= f.radio_button :display, "Picture" Picture%>
<%# <br />顯示方式是設定在前台頁面時,資訊所呈現的樣式 %>
</div>
<div class="form-actions">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
</div>
<% end %>
@@ -1,20 +0,0 @@
<tr id="<%= dom_id news_bulletin_category %>" class="with_action">
<td>
<%= news_bulletin_category.key %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if is_admin?%>
<li><%= link_to t(:edit), edit_panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :remote => true %></li>
<li><%= link_to show_toggle_archive_btn(news_bulletin_category), panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :confirm => t(:sure?), :method => :delete, :remote => true,:class=>"archive_toggle" %></li>
<% end %>
<%if is_manager? || is_admin? %>
<li><%= show_news_cate_permission_link(news_bulletin_category) %></li>
<% end %>
</ul>
</div>
</td>
<% @site_valid_locales.each do |locale| %>
<td><%= news_bulletin_category.title_translations[locale] rescue nil %></td>
<% end %>
</tr>
@@ -1,28 +0,0 @@
<% # encoding: utf-8 %>
<div id="qe-basic" class="qe-edit-div">
<div id="widget-title">
<%= f.label :key %>
<%= f.text_field :key %>
</div>
<div id="widget-title">
<%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge', :value => (news_bulletin_category.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div id="widget-title">
<%= f.label :display %>
<%= f.radio_button :display, "List" %>List
<%= f.radio_button :display, "Picture" %>Picture
<br />顯示方式是設定在前台頁面時,資訊所呈現的樣式
</div>
</div>
@@ -1,2 +0,0 @@
$('<%= j render :partial => 'news_bulletin_category', :collection => [@news_bulletin_category] %>').appendTo('#news_bulletin_categorys').hide().fadeIn();
$("#new_news_bulletin_category")[0].reset();
@@ -1 +0,0 @@
$("#<%= dom_id @news_bulletin_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@news_bulletin_category) %> ");
@@ -1,7 +0,0 @@
<h1><%= t('news_bulletin.editing_news_category') %></h1>
<%= form_for @news_bulletin_category, :url => panel_news_back_end_news_bulletin_category_path(@news_bulletin_category) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_back %>
@@ -1 +0,0 @@
$("#form > form").replaceWith("<%= j render "form" %>");
@@ -1,23 +0,0 @@
<%= flash_messages %>
<table id="news_bulletin_categorys" class="table main-list">
<thead>
<tr>
<th class="span1-2"><%= t(:key) %></th>
<% @site_valid_locales.each do |locale| %>
<th class="span1-2"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
<% end %>
</tr>
</thead>
<tbody>
<%= render :partial => 'news_bulletin_category', :collection => @news_bulletin_categorys %>
</tbody>
</table>
<div id="form"><%= render :partial => "form" if is_manager? %></div>
Loaded 100 of 1006 files, more files were not shown because too many files have changed in this diff. Show more