parent
a4aef30a9c
commit
36da89f93e
|
@ -11,7 +11,7 @@ class Admin::AssetsController < OrbitBackendController
|
||||||
def new
|
def new
|
||||||
@asset = Asset.new
|
@asset = Asset.new
|
||||||
@asset_categories = AssetCategory.all
|
@asset_categories = AssetCategory.all
|
||||||
@tags = AssetTag.all
|
@tags = get_tags
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {}
|
format.html {}
|
||||||
format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/new'} }
|
format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/new'} }
|
||||||
|
@ -21,7 +21,7 @@ class Admin::AssetsController < OrbitBackendController
|
||||||
def edit
|
def edit
|
||||||
@asset = Asset.find(params[:id])
|
@asset = Asset.find(params[:id])
|
||||||
@asset_categories = AssetCategory.all
|
@asset_categories = AssetCategory.all
|
||||||
@tags = AssetTag.all
|
@tags = get_tags
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {}
|
format.html {}
|
||||||
format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/edit'} }
|
format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/edit'} }
|
||||||
|
@ -46,7 +46,7 @@ class Admin::AssetsController < OrbitBackendController
|
||||||
else
|
else
|
||||||
flash[:error] = t('create.fail')
|
flash[:error] = t('create.fail')
|
||||||
@asset_categories = AssetCategory.all
|
@asset_categories = AssetCategory.all
|
||||||
@tags = AssetTag.all
|
@tags = get_tags
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js {
|
format.js {
|
||||||
if params[:uploader]
|
if params[:uploader]
|
||||||
|
@ -69,7 +69,7 @@ class Admin::AssetsController < OrbitBackendController
|
||||||
else
|
else
|
||||||
flash[:error] = t('update.fail')
|
flash[:error] = t('update.fail')
|
||||||
@asset_categories = AssetCategory.all
|
@asset_categories = AssetCategory.all
|
||||||
@tags = AssetTag.all
|
@tags = get_tags
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => :edit }
|
format.html { render :action => :edit }
|
||||||
format.js { render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/edit', :locals => {:is_html => false}} }
|
format.js { render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/edit', :locals => {:is_html => false}} }
|
||||||
|
@ -96,7 +96,7 @@ class Admin::AssetsController < OrbitBackendController
|
||||||
def file_upload
|
def file_upload
|
||||||
@asset = Asset.new
|
@asset = Asset.new
|
||||||
@asset_categories = AssetCategory.all
|
@asset_categories = AssetCategory.all
|
||||||
@tags = AssetTag.all
|
@tags = get_tags
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,25 +17,16 @@ class DefaultWidgetController< OrbitWidgetController
|
||||||
result_objects = nil
|
result_objects = nil
|
||||||
|
|
||||||
if !params["tag_id"].blank?
|
if !params["tag_id"].blank?
|
||||||
@tags = Tag.find(params["tag_id"]) rescue nil
|
|
||||||
result_ids = nil
|
|
||||||
|
|
||||||
result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).entries.collect{|t| t.id}}
|
|
||||||
if params["category_id"].blank? #has tag no cate
|
if params["category_id"].blank? #has tag no cate
|
||||||
#nothing
|
result = ori_class_name.constantize.where(:tagged_ids.in => params["tag_id"])
|
||||||
else #has tag and cate
|
else #has tag and cate
|
||||||
# result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).where(:#{get_category_field_name(ori_class_name)}.in=>params["category_id"]).available_for_lang(I18n.locale).can_display.collect{|t| t.id}}.flatten
|
result = eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id'], :tagged_ids.in => params['tag_id'])")
|
||||||
result_ids << eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id']).entries.collect{|t| t.id}")
|
|
||||||
result_ids.flatten!
|
|
||||||
|
|
||||||
end
|
end
|
||||||
result = eval("#{ori_class_name}.where(:id=>result_ids)")
|
|
||||||
elsif params["category_id"].blank? #no tag no cate
|
elsif params["category_id"].blank? #no tag no cate
|
||||||
result = eval(@default_widget["query"])
|
result = eval(@default_widget["query"])
|
||||||
else #no tag has cate
|
else #no tag has cate
|
||||||
result = eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id'])")
|
result = eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id'])")
|
||||||
end
|
end
|
||||||
date_now = Time.now
|
|
||||||
result.available_for_lang(I18n.locale).can_display.desc(:is_top, :postdate)
|
result.available_for_lang(I18n.locale).can_display.desc(:is_top, :postdate)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ class Asset
|
||||||
|
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
mount_uploader :data, FileAssetUploader
|
mount_uploader :data, FileAssetUploader
|
||||||
|
|
||||||
|
@ -16,18 +18,13 @@ class Asset
|
||||||
|
|
||||||
belongs_to :asset_category
|
belongs_to :asset_category
|
||||||
belongs_to :assetable, polymorphic: true
|
belongs_to :assetable, polymorphic: true
|
||||||
has_and_belongs_to_many :tags, :class_name => "AssetTag"
|
|
||||||
|
|
||||||
before_save :clean_tags
|
before_save :clean_tags
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def clean_tags
|
def clean_tags
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,4 +6,12 @@ class Tagging
|
||||||
|
|
||||||
belongs_to :tag
|
belongs_to :tag
|
||||||
belongs_to :taggable, polymorphic: true
|
belongs_to :taggable, polymorphic: true
|
||||||
|
|
||||||
|
before_destroy :update_taggable_tag_ids
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def update_taggable_tag_ids
|
||||||
|
self.taggable.remove_id(self.tag.id)
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -13,17 +13,35 @@ module OrbitTag
|
||||||
def init_tag
|
def init_tag
|
||||||
class_eval do
|
class_eval do
|
||||||
field :tags_to_destroy, type: Array, default: []
|
field :tags_to_destroy, type: Array, default: []
|
||||||
|
field :tagged_ids, type: Array, default: []
|
||||||
|
|
||||||
has_many :taggings, as: :taggable, autosave: true, dependent: :destroy
|
has_many :taggings, as: :taggable, autosave: true, dependent: :destroy
|
||||||
accepts_nested_attributes_for :taggings, allow_destroy: true
|
accepts_nested_attributes_for :taggings, allow_destroy: true
|
||||||
after_save :remove_taggings, unless: Proc.new{self.tags_to_destroy.blank?}
|
after_save :remove_taggings, unless: Proc.new{self.tags_to_destroy.blank?}
|
||||||
|
|
||||||
|
def remove_id(id)
|
||||||
|
self.class.without_callback(:save, :after, :remove_taggings) do
|
||||||
|
self.update_attribute(:tagged_ids, self.tagged_ids - [id.to_s])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def sorted_tags
|
||||||
|
if tags.blank?
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
tag_array = tags.inject([]){ |result, value|
|
||||||
|
result << [value.name, value]
|
||||||
|
}
|
||||||
|
tag_array.sort.map{|x| x[1] }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
self.taggings.blank? ? [] : self.taggings.map{|t| t.tag}
|
self.taggings.blank? ? [] : self.taggings.map{|t| t.tag}.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def tags=(tag_ids)
|
def tags=(tag_ids)
|
||||||
tag_ids = [tag_ids].flatten
|
ids = [tag_ids].flatten
|
||||||
tag_ids.delete('')
|
tag_ids.delete('')
|
||||||
ids = self.taggings.blank? ? [] : self.taggings.map{|t| t.tag.id}
|
ids = self.taggings.blank? ? [] : self.taggings.map{|t| t.tag.id}
|
||||||
tag_ids.each do |tag_id|
|
tag_ids.each do |tag_id|
|
||||||
|
@ -40,17 +58,9 @@ module OrbitTag
|
||||||
|
|
||||||
def tag_ids=(ids)
|
def tag_ids=(ids)
|
||||||
self.tags = ids
|
self.tags = ids
|
||||||
end
|
ids = [ids].flatten
|
||||||
|
ids.delete('')
|
||||||
def sorted_tags
|
self.tagged_ids = ids
|
||||||
if tags.blank?
|
|
||||||
[]
|
|
||||||
else
|
|
||||||
tag_array = tags.inject([]){ |result, value|
|
|
||||||
result << [value.name, value]
|
|
||||||
}
|
|
||||||
tag_array.sort.map{|x| x[1] }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
class Panel::Announcement::BackEnd::TagsController < Admin::TagsController
|
|
||||||
|
|
||||||
def initialize
|
|
||||||
super
|
|
||||||
@app_title = 'announcement'
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -39,17 +39,13 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
else
|
else
|
||||||
date_now = Time.now
|
date_now = Time.now
|
||||||
if !params[:category_id].blank? && !params[:tag_id].blank?
|
if !params[:category_id].blank? && !params[:tag_id].blank?
|
||||||
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil
|
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:bulletin_category_id => params[:category_id], :tagged_ids => params[:tag_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(@page_num)
|
||||||
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
@bulletins = @tag.bulletins.available_for_lang(I18n.locale).can_display.where(: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(@page_num)
|
|
||||||
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
|
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
|
||||||
elsif !params[:category_id].blank?
|
elsif !params[:category_id].blank?
|
||||||
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(: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(@page_num)
|
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(: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(@page_num)
|
||||||
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
|
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
|
||||||
elsif !params[:tag_id].blank?
|
elsif !params[:tag_id].blank?
|
||||||
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil
|
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_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(@page_num)
|
||||||
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
@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_main]).per(@page_num)
|
|
||||||
else
|
else
|
||||||
@bulletins = Bulletin.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(@page_num)
|
@bulletins = Bulletin.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(@page_num)
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,9 +34,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
|
||||||
@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)
|
@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
|
@current_category = BulletinCategory.from_id(@category_id) rescue nil
|
||||||
elsif !params[:tag_id].blank?
|
elsif !params[:tag_id].blank?
|
||||||
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil
|
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_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)
|
||||||
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
@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
|
else
|
||||||
@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)
|
@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
|
end
|
||||||
|
@ -59,11 +57,9 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
|
||||||
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(: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(@page_num )
|
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(: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(@page_num )
|
||||||
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
|
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
|
||||||
elsif !params[:tag_id].blank?
|
elsif !params[:tag_id].blank?
|
||||||
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil
|
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_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)
|
||||||
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
@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
|
else
|
||||||
@bulletins = Bulletin.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(@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
|
end
|
||||||
|
|
||||||
get_categorys
|
get_categorys
|
||||||
|
@ -71,13 +67,13 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload_bulletins
|
def reload_bulletins
|
||||||
@selected_tag = AnnouncementTag.find(params[:tag_id])
|
@selected_tag = Tag.find(params[:tag_id])
|
||||||
@bulletins = @selected_tag.get_visible_bulletins(:postdate).available_for_lang(I18n.locale).can_display.page(params[:page]).per(5) rescue nil
|
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort).page(params[:page]).per(5) rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload_web_links
|
def reload_web_links
|
||||||
@selected_tag = AnnouncementTag.find(params[:tag_id])
|
@selected_tag = Tag.find(params[:tag_id])
|
||||||
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links(:created_at).available_for_lang(I18n.locale).page(params[:page]).per(5) rescue nil
|
@web_links = WebLink.where(:name => @selected_tag.name).where(:is_hidden => false).desc(:is_top, sort).available_for_lang(I18n.locale).page(params[:page]).per(5) rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def bulletins_side_bar
|
def bulletins_side_bar
|
||||||
|
|
|
@ -199,11 +199,6 @@ class Bulletin
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# def sorted_tags
|
|
||||||
# tags.order_by(I18n.locale, :asc)
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
def to_preview
|
def to_preview
|
||||||
preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_announcement_front_end_bulletin_path",:object_class_type=>"Bulletin")
|
preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_announcement_front_end_bulletin_path",:object_class_type=>"Bulletin")
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="news_prev">prev</div>
|
<div class="news_prev">prev</div>
|
||||||
<div class="news_next">next</div>
|
<div class="news_next">next</div>
|
||||||
<ul class="news_list">
|
<ul class="news_list">
|
||||||
<% tag.bulletins.each do |post| %>
|
<% Bulletin.where(:tagged_ids => tag).each do |post| %>
|
||||||
<li><%= link_to post.title, panel_announcement_front_end_bulletin_path(post) %></li>
|
<li><%= link_to post.title, panel_announcement_front_end_bulletin_path(post) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -20,10 +20,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
|
||||||
# @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num)
|
# @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num)
|
||||||
|
|
||||||
if !params[:category_id].blank? && !params[:tag_id].blank?
|
if !params[:category_id].blank? && !params[:tag_id].blank?
|
||||||
@tag = ArchiveTag.find(params[:tag_id]) rescue nil
|
@archive_files = @archive_files.can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||||
@tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
@archive_files = @tag.archive_files.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
|
||||||
@archive_files = @archive_files.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
|
||||||
|
|
||||||
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
|
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
|
||||||
|
|
||||||
|
@ -31,9 +28,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
|
||||||
@archive_files = ArchiveFile.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
@archive_files = ArchiveFile.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||||
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
|
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
|
||||||
elsif !params[:tag_id].blank?
|
elsif !params[:tag_id].blank?
|
||||||
@tag = ArchiveTag.find(params[:tag_id]) rescue nil
|
@archive_files = ArchiveFile.can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||||
@tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
@archive_files = @tag.archive_files.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
|
||||||
else
|
else
|
||||||
@archive_files = ArchiveFile.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
@archive_files = ArchiveFile.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||||
end
|
end
|
||||||
|
@ -66,9 +61,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
|
||||||
@archive_files = ArchiveFile.can_display.where(:archive_file_category_id => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
@archive_files = ArchiveFile.can_display.where(:archive_file_category_id => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||||
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
|
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
|
||||||
elsif !params[:tag_id].blank?
|
elsif !params[:tag_id].blank?
|
||||||
@tag = ArchiveTag.find(params[:tag_id]) rescue nil
|
@archive_files = ArchiveFile.can_display.where(:tagged_ids => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||||
@tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
@archive_files = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
|
||||||
else
|
else
|
||||||
@archive_files = ArchiveFile.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
@archive_files = ArchiveFile.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,8 +31,7 @@ class Panel::Archive::Widget::ArchiveFilesController < OrbitWidgetController
|
||||||
@archive_files = ArchiveFile.all.can_display.any_in(:archive_file_category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
@archive_files = ArchiveFile.all.can_display.any_in(:archive_file_category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||||
@archive_file_categorys = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true)
|
@archive_file_categorys = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true)
|
||||||
elsif !params[:tag_id].blank?
|
elsif !params[:tag_id].blank?
|
||||||
@tag = ArchiveTag.find(params[:tag_id]) rescue nil
|
@archive_files = ArchiveFile.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||||
@tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
get_categorys
|
get_categorys
|
||||||
else
|
else
|
||||||
@archive_files = ArchiveFile.all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
@archive_files = ArchiveFile.all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||||
|
|
|
@ -61,10 +61,6 @@ class ArchiveFile
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def get_file_icon( file_data )
|
def get_file_icon( file_data )
|
||||||
file_icon = "<span class=\"o-archives-file-type\">#{file_data.split('.')[-1]}</span>".html_safe
|
file_icon = "<span class=\"o-archives-file-type\">#{file_data.split('.')[-1]}</span>".html_safe
|
||||||
|
|
|
@ -26,8 +26,7 @@ class Panel::Faq::FrontEnd::QasController < OrbitWidgetController
|
||||||
@qas = Qa.all.can_display.any_in(:qa_category_id => params[:category_id]).merge(QaCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
@qas = Qa.all.can_display.any_in(:qa_category_id => params[:category_id]).merge(QaCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||||
@qa_categorys = QaCategory.any_in(:_id => @item.category).excludes('disable' => true) rescue nil
|
@qa_categorys = QaCategory.any_in(:_id => @item.category).excludes('disable' => true) rescue nil
|
||||||
elsif params[:tag_id] !="[]" && !params[:tag_id].blank?
|
elsif params[:tag_id] !="[]" && !params[:tag_id].blank?
|
||||||
@tag = FaqTag.find(params[:tag_id]) rescue nil
|
Qa.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(QaCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||||
@tag = FaqTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
@qas = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
@qas = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||||
get_categorys
|
get_categorys
|
||||||
else
|
else
|
||||||
|
|
|
@ -63,10 +63,6 @@ class Qa
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (question_translations[locale].blank? rescue true)
|
if (question_translations[locale].blank? rescue true)
|
||||||
|
@ -87,7 +83,7 @@ class Qa
|
||||||
self.qa_links.each do |link|
|
self.qa_links.each do |link|
|
||||||
link.delete if link.url.blank? && link.title.blank?
|
link.delete if link.url.blank? && link.title.blank?
|
||||||
end
|
end
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -12,7 +12,7 @@ class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController
|
||||||
else
|
else
|
||||||
@authenticated = false
|
@authenticated = false
|
||||||
end
|
end
|
||||||
@tags = GalleryTag.all
|
@tags = get_tags
|
||||||
@image = GalleryImage.find(params[:id])
|
@image = GalleryImage.find(params[:id])
|
||||||
@albumid = @image.gallery_album_id
|
@albumid = @image.gallery_album_id
|
||||||
@album = GalleryAlbum.find(@albumid)
|
@album = GalleryAlbum.find(@albumid)
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
end
|
end
|
||||||
@categorylist = GalleryCategory.all
|
@categorylist = GalleryCategory.all
|
||||||
@cid = params['cat']
|
@cid = params['cat']
|
||||||
@tags = GalleryTag.all
|
@tags = get_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@ -26,7 +26,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
@authenticated = false
|
@authenticated = false
|
||||||
end
|
end
|
||||||
@album = GalleryAlbum.find(params[:id])
|
@album = GalleryAlbum.find(params[:id])
|
||||||
@tags = GalleryTag.all
|
@tags = get_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@ -55,10 +55,10 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
if @tags
|
if @tags
|
||||||
if @tags.kind_of?(Array)
|
if @tags.kind_of?(Array)
|
||||||
@tags.each do |tag|
|
@tags.each do |tag|
|
||||||
@albums << GalleryAlbum.where(tag_ids: tag)
|
@albums << GalleryAlbum.where(tagged_ids: tag)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << GalleryAlbum.where(tag_ids: @tags)
|
@albums << GalleryAlbum.where(tagged_ids: @tags)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << GalleryAlbum.all
|
@albums << GalleryAlbum.all
|
||||||
|
@ -69,10 +69,10 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
if @tags
|
if @tags
|
||||||
if @tags.kind_of?(Array)
|
if @tags.kind_of?(Array)
|
||||||
@tags.each do |tag|
|
@tags.each do |tag|
|
||||||
@albums << category.gallery_albums.where(tag_ids: tag)
|
@albums << category.gallery_albums.where(tagged_ids: tag)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << category.gallery_albums.where(tag_ids: @tags)
|
@albums << category.gallery_albums.where(tagged_ids: @tags)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << category.gallery_albums.all
|
@albums << category.gallery_albums.all
|
||||||
|
@ -83,10 +83,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
@albums.each do |album|
|
@albums.each do |album|
|
||||||
@albs = Array.new
|
@albs = Array.new
|
||||||
album.each do |values|
|
album.each do |values|
|
||||||
tags = Array.new
|
tags = Tag.find(values.tagged_ids).map{|t| t.name}
|
||||||
values.tag_ids.each do |tag|
|
|
||||||
tags << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
category = GalleryCategory.find(values.gallery_category_id).name
|
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}
|
@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
|
end
|
||||||
|
@ -107,7 +104,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
@images = @album.gallery_images.all
|
@images = @album.gallery_images.all
|
||||||
@album_name = @album.name_translations
|
@album_name = @album.name_translations
|
||||||
@cover = @album.cover
|
@cover = @album.cover
|
||||||
@tags = GalleryTag.all
|
@tags = get_tags
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,11 +120,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
output = Array.new
|
output = Array.new
|
||||||
|
|
||||||
albums.each do |album|
|
albums.each do |album|
|
||||||
tag_names = Array.new
|
tag_names = Tag.find(album.tagged_ids).map{|t| t.name}
|
||||||
|
|
||||||
album.tag_ids.each do |tag|
|
|
||||||
tag_names << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
|
|
||||||
output << {
|
output << {
|
||||||
album_cover_file: "http://#{request.host_with_port}#{album.cover_path}",
|
album_cover_file: "http://#{request.host_with_port}#{album.cover_path}",
|
||||||
|
@ -146,11 +139,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
output = Array.new
|
output = Array.new
|
||||||
|
|
||||||
images.each do |image|
|
images.each do |image|
|
||||||
tags = Array.new
|
tags = Tag.find(image.tagged_ids).map{|t| t.name}
|
||||||
|
|
||||||
image.tag_ids.each do |tag|
|
|
||||||
tags << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
|
|
||||||
output << {
|
output << {
|
||||||
image_title: image.title,
|
image_title: image.title,
|
||||||
|
@ -169,10 +158,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
@images = @album.gallery_images.all
|
@images = @album.gallery_images.all
|
||||||
@output = Array.new
|
@output = Array.new
|
||||||
@images.each do |values|
|
@images.each do |values|
|
||||||
tags = Array.new
|
tags = Tag.find(values.tagged_ids).map{|t| t.name}
|
||||||
values.tag_ids.each do |tag|
|
|
||||||
tags << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
@output << { _id: values.id,
|
@output << { _id: values.id,
|
||||||
theater_link: panel_gallery_back_end_album_image_path(values),
|
theater_link: panel_gallery_back_end_album_image_path(values),
|
||||||
description: values.description,
|
description: values.description,
|
||||||
|
@ -190,8 +176,8 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
if @authenticated
|
if @authenticated
|
||||||
render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json
|
render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json
|
||||||
else
|
else
|
||||||
@album.tag_ids.each do |tag|
|
@album.tagged_ids.each do |tag|
|
||||||
@tag_names << GalleryTag.find(tag)[I18n.locale]
|
@tag_names << Tag.find(tag).name
|
||||||
end
|
end
|
||||||
render :json=>{"images" => @output, "tags" => @album.tag_ids, "tag_names" => @tag_names}.to_json
|
render :json=>{"images" => @output, "tags" => @album.tag_ids, "tag_names" => @tag_names}.to_json
|
||||||
end
|
end
|
||||||
|
@ -235,7 +221,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
if params['delete_cover'] == "true"
|
if params['delete_cover'] == "true"
|
||||||
@album.update_attributes(:cover=>"default")
|
@album.update_attributes(:cover=>"default")
|
||||||
end
|
end
|
||||||
@tags = GalleryTag.all
|
@tags = get_tags
|
||||||
render :action => :show
|
render :action => :show
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,10 +4,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@album = GalleryAlbum.find(params[:id])
|
@album = GalleryAlbum.find(params[:id])
|
||||||
@tags = Array.new
|
@tags = Tag.find(@album.tagged_ids).map{|t| t.name}
|
||||||
@album.tag_ids.each do |tag|
|
|
||||||
@tags << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_albums
|
def get_albums
|
||||||
|
@ -18,10 +15,10 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
|
||||||
if @tags
|
if @tags
|
||||||
if @tags.kind_of?(Array)
|
if @tags.kind_of?(Array)
|
||||||
@tags.each do |tag|
|
@tags.each do |tag|
|
||||||
@albums << GalleryAlbum.where(tag_ids: tag)
|
@albums << GalleryAlbum.where(tagged_ids: tag)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << GalleryAlbum.where(tag_ids: @tags)
|
@albums << GalleryAlbum.where(tagged_ids: @tags)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << GalleryAlbum.all
|
@albums << GalleryAlbum.all
|
||||||
|
@ -32,10 +29,10 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
|
||||||
if @tags
|
if @tags
|
||||||
if @tags.kind_of?(Array)
|
if @tags.kind_of?(Array)
|
||||||
@tags.each do |tag|
|
@tags.each do |tag|
|
||||||
@albums << category.gallery_albums.where(tag_ids: tag)
|
@albums << category.gallery_albums.where(tagged_ids: tag)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << category.gallery_albums.where(tag_ids: @tags)
|
@albums << category.gallery_albums.where(tagged_ids: @tags)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << category.gallery_albums.all
|
@albums << category.gallery_albums.all
|
||||||
|
@ -46,10 +43,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
|
||||||
@albums.each do |album|
|
@albums.each do |album|
|
||||||
@albs = Array.new
|
@albs = Array.new
|
||||||
album.each do |values|
|
album.each do |values|
|
||||||
tags = Array.new
|
tags = Tag.find(values.tagged_ids).map{|t| t.name}
|
||||||
values.tag_ids.each do |tag|
|
|
||||||
tags << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
category = GalleryCategory.find(values.gallery_category_id).name
|
category = GalleryCategory.find(values.gallery_category_id).name
|
||||||
@albs << {"_id"=>values.id,"show_path"=>panel_gallery_front_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}
|
@albs << {"_id"=>values.id,"show_path"=>panel_gallery_front_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
|
end
|
||||||
|
@ -63,10 +57,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
|
||||||
@images = @album.gallery_images.all
|
@images = @album.gallery_images.all
|
||||||
@output = Array.new
|
@output = Array.new
|
||||||
@images.each do |values|
|
@images.each do |values|
|
||||||
tags = Array.new
|
tags = Tag.find(values.tagged_ids).map{|t| t.name}
|
||||||
values.tag_ids.each do |tag|
|
|
||||||
tags << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
@output << {:_id => values.id,
|
@output << {:_id => values.id,
|
||||||
:theater_link => theater_panel_gallery_front_end_album_path(values),
|
:theater_link => theater_panel_gallery_front_end_album_path(values),
|
||||||
:description => values.description,
|
:description => values.description,
|
||||||
|
@ -95,10 +86,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
|
||||||
@album = GalleryAlbum.find(@albumid)
|
@album = GalleryAlbum.find(@albumid)
|
||||||
@images = @album.gallery_images.all
|
@images = @album.gallery_images.all
|
||||||
tags = @album.tag_ids
|
tags = @album.tag_ids
|
||||||
@tagnames = Array.new
|
@tagnames = Tag.find(tags.tagged_ids).map{|t| t.name}
|
||||||
tags.each do |tag|
|
|
||||||
@tagnames << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
@back_link = panel_gallery_front_end_album_path(@albumid)
|
@back_link = panel_gallery_front_end_album_path(@albumid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ include AdminHelper
|
||||||
@authenticated = false
|
@authenticated = false
|
||||||
@categorylist = GalleryCategory.all
|
@categorylist = GalleryCategory.all
|
||||||
@cid = params['cat']
|
@cid = params['cat']
|
||||||
@tags = GalleryTag.all
|
@tags = get_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_category
|
def new_category
|
||||||
|
@ -62,10 +62,10 @@ include AdminHelper
|
||||||
if @tags
|
if @tags
|
||||||
if @tags.kind_of?(Array)
|
if @tags.kind_of?(Array)
|
||||||
@tags.each do |tag|
|
@tags.each do |tag|
|
||||||
@albums << GalleryAlbum.where(tag_ids: tag)
|
@albums << GalleryAlbum.where(tagged_ids: tag)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << GalleryAlbum.where(tag_ids: @tags)
|
@albums << GalleryAlbum.where(tagged_ids: @tags)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << GalleryAlbum.all
|
@albums << GalleryAlbum.all
|
||||||
|
@ -76,10 +76,10 @@ include AdminHelper
|
||||||
if @tags
|
if @tags
|
||||||
if @tags.kind_of?(Array)
|
if @tags.kind_of?(Array)
|
||||||
@tags.each do |tag|
|
@tags.each do |tag|
|
||||||
@albums << category.gallery_albums.where(tag_ids: tag)
|
@albums << category.gallery_albums.where(tagged_ids: tag)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << category.gallery_albums.where(tag_ids: @tags)
|
@albums << category.gallery_albums.where(tagged_ids: @tags)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@albums << category.gallery_albums.all
|
@albums << category.gallery_albums.all
|
||||||
|
@ -90,10 +90,7 @@ include AdminHelper
|
||||||
@albums.each do |album|
|
@albums.each do |album|
|
||||||
@albs = Array.new
|
@albs = Array.new
|
||||||
album.each do |values|
|
album.each do |values|
|
||||||
tags = Array.new
|
tags = Tag.find(values.tagged_ids).map{|t| t.name}
|
||||||
values.tag_ids.each do |tag|
|
|
||||||
tags << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
category = GalleryCategory.find(values.gallery_category_id).name
|
category = GalleryCategory.find(values.gallery_category_id).name
|
||||||
@albs << {"_id"=>values.id,"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}
|
@albs << {"_id"=>values.id,"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
|
end
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
class GalleryImage
|
class GalleryImage
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
mount_uploader :file, GalleryUploader
|
mount_uploader :file, GalleryUploader
|
||||||
|
|
||||||
field :title
|
field :title
|
||||||
field :description, localize: true
|
field :description, localize: true
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
# has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
||||||
|
|
||||||
belongs_to :gallery_album
|
belongs_to :gallery_album
|
||||||
|
|
||||||
end
|
end
|
|
@ -4,6 +4,8 @@ class WritingBook
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
||||||
|
@ -17,7 +19,7 @@ class WritingBook
|
||||||
field :publisher, localize: true
|
field :publisher, localize: true
|
||||||
field :editor, localize: true
|
field :editor, localize: true
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "PersonalBookTag"
|
# has_and_belongs_to_many :tags, :class_name => "PersonalBookTag"
|
||||||
|
|
||||||
has_and_belongs_to_many :book_author_types
|
has_and_belongs_to_many :book_author_types
|
||||||
|
|
||||||
|
@ -78,10 +80,6 @@ class WritingBook
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
|
|
@ -3,6 +3,9 @@ class WritingConference
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
||||||
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
||||||
|
@ -13,7 +16,7 @@ class WritingConference
|
||||||
field :location, localize: true
|
field :location, localize: true
|
||||||
field :sponsor, localize: true
|
field :sponsor, localize: true
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "PersonalConferenceTag"
|
# has_and_belongs_to_many :tags, :class_name => "PersonalConferenceTag"
|
||||||
has_and_belongs_to_many :conference_author_types
|
has_and_belongs_to_many :conference_author_types
|
||||||
has_and_belongs_to_many :conference_paper_types
|
has_and_belongs_to_many :conference_paper_types
|
||||||
has_and_belongs_to_many :conference_co_authors
|
has_and_belongs_to_many :conference_co_authors
|
||||||
|
@ -79,10 +82,6 @@ class WritingConference
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
@ -122,7 +121,7 @@ class WritingConference
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_checkboxs
|
def clean_checkboxs
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
self.conference_author_type_ids.delete('')
|
self.conference_author_type_ids.delete('')
|
||||||
self.conference_level_type_ids.delete('')
|
self.conference_level_type_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,9 @@ class Diploma
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
||||||
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
||||||
|
@ -15,7 +18,7 @@ class Diploma
|
||||||
field :department, localize: true
|
field :department, localize: true
|
||||||
field :degree, localize: true
|
field :degree, localize: true
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "PersonalDiplomaTag"
|
# has_and_belongs_to_many :tags, :class_name => "PersonalDiplomaTag"
|
||||||
|
|
||||||
field :year
|
field :year
|
||||||
field :language
|
field :language
|
||||||
|
@ -51,10 +54,6 @@ class Diploma
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
@ -74,7 +73,7 @@ class Diploma
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_checkboxs
|
def clean_checkboxs
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -5,6 +5,9 @@ class Experience
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
||||||
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
||||||
|
@ -14,7 +17,7 @@ class Experience
|
||||||
field :department, localize: true
|
field :department, localize: true
|
||||||
field :job_title, localize: true
|
field :job_title, localize: true
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "PersonalExperienceTag"
|
# has_and_belongs_to_many :tags, :class_name => "PersonalExperienceTag"
|
||||||
|
|
||||||
belongs_to :experience_category
|
belongs_to :experience_category
|
||||||
|
|
||||||
|
@ -65,10 +68,6 @@ class Experience
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
@ -88,7 +87,7 @@ class Experience
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_checkboxs
|
def clean_checkboxs
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -5,13 +5,16 @@ class Honor
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
||||||
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "PersonalHonorTag"
|
# has_and_belongs_to_many :tags, :class_name => "PersonalHonorTag"
|
||||||
|
|
||||||
belongs_to :honor_category
|
belongs_to :honor_category
|
||||||
|
|
||||||
|
@ -62,10 +65,6 @@ class Honor
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
@ -85,7 +84,7 @@ class Honor
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_checkboxs
|
def clean_checkboxs
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -3,13 +3,16 @@ class WritingJournal
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
||||||
|
|
||||||
field :paper_title, localize: true
|
field :paper_title, localize: true
|
||||||
field :journal_title, localize: true
|
field :journal_title, localize: true
|
||||||
field :authors, localize: true
|
field :authors, localize: true
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "PersonalJournalTag"
|
# has_and_belongs_to_many :tags, :class_name => "PersonalJournalTag"
|
||||||
has_and_belongs_to_many :journal_author_types
|
has_and_belongs_to_many :journal_author_types
|
||||||
has_and_belongs_to_many :journal_level_types
|
has_and_belongs_to_many :journal_level_types
|
||||||
has_and_belongs_to_many :journal_co_authors
|
has_and_belongs_to_many :journal_co_authors
|
||||||
|
@ -80,10 +83,6 @@ class WritingJournal
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
@ -122,7 +121,7 @@ class WritingJournal
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_checkboxs
|
def clean_checkboxs
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
self.journal_author_type_ids.delete('')
|
self.journal_author_type_ids.delete('')
|
||||||
self.journal_level_type_ids.delete('')
|
self.journal_level_type_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,9 @@ class Lab
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
||||||
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
||||||
|
@ -15,7 +18,7 @@ class Lab
|
||||||
field :participating_professor, localize: true
|
field :participating_professor, localize: true
|
||||||
field :participating_student, localize: true
|
field :participating_student, localize: true
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "PersonalLabTag"
|
# has_and_belongs_to_many :tags, :class_name => "PersonalLabTag"
|
||||||
|
|
||||||
field :year
|
field :year
|
||||||
field :language
|
field :language
|
||||||
|
@ -71,10 +74,6 @@ class Lab
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
@ -102,7 +101,7 @@ class Lab
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_checkboxs
|
def clean_checkboxs
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -5,6 +5,9 @@ class WritingPatent
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
||||||
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
||||||
|
@ -13,7 +16,7 @@ class WritingPatent
|
||||||
field :patent_title, localize: true
|
field :patent_title, localize: true
|
||||||
field :authors, localize: true
|
field :authors, localize: true
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "PersonalPatentTag"
|
# has_and_belongs_to_many :tags, :class_name => "PersonalPatentTag"
|
||||||
|
|
||||||
belongs_to :writing_patent_category
|
belongs_to :writing_patent_category
|
||||||
|
|
||||||
|
@ -71,10 +74,6 @@ class WritingPatent
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
@ -102,7 +101,7 @@ class WritingPatent
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_checkboxs
|
def clean_checkboxs
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -5,6 +5,9 @@ class Project
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
||||||
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
||||||
|
@ -15,7 +18,7 @@ class Project
|
||||||
field :participator, localize: true
|
field :participator, localize: true
|
||||||
field :unit, localize: true
|
field :unit, localize: true
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "PersonalProjectTag"
|
# has_and_belongs_to_many :tags, :class_name => "PersonalProjectTag"
|
||||||
|
|
||||||
belongs_to :project_category
|
belongs_to :project_category
|
||||||
|
|
||||||
|
@ -73,10 +76,6 @@ class Project
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
@ -104,7 +103,7 @@ class Project
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_checkboxs
|
def clean_checkboxs
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -5,6 +5,9 @@ class Research
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
taggable
|
||||||
|
|
||||||
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
||||||
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
||||||
|
@ -14,7 +17,7 @@ class Research
|
||||||
field :authors, localize: true
|
field :authors, localize: true
|
||||||
field :extracted_chapters, localize: true
|
field :extracted_chapters, localize: true
|
||||||
|
|
||||||
has_and_belongs_to_many :tags, :class_name => "PersonalResearchTag"
|
# has_and_belongs_to_many :tags, :class_name => "PersonalResearchTag"
|
||||||
|
|
||||||
field :year
|
field :year
|
||||||
field :language
|
field :language
|
||||||
|
@ -68,10 +71,6 @@ class Research
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
@ -99,7 +98,7 @@ class Research
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_checkboxs
|
def clean_checkboxs
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -13,14 +13,12 @@ class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController
|
||||||
date_now = Time.now
|
date_now = Time.now
|
||||||
|
|
||||||
if !params[:category_id].blank?
|
if !params[:category_id].blank?
|
||||||
@web_links = WebLink.where( :is_hidden => false ).where(:web_link_category_id => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(10)
|
@web_links = WebLink.where( :is_hidden => false ).where(:web_link_category_id => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||||
@current_category = WebLinkCategory.from_id(params[:category_id]) rescue nil
|
@current_category = WebLinkCategory.from_id(params[:category_id]) rescue nil
|
||||||
elsif !params[:tag_id].blank?
|
elsif !params[:tag_id].blank?
|
||||||
@tag = WebResourceTag.find(params[:tag_id]) rescue nil
|
@web_links = WebLink.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||||
@tag = WebResourceTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
@web_links = @tag.archive_files.where( :is_hidden => false ).desc( :is_top ).page( params[:page_main] ).per(10)
|
|
||||||
else
|
else
|
||||||
@web_links = WebLink.where( :is_hidden => false ).desc( :is_top ).page( params[:page_main] ).per(10)
|
@web_links = WebLink.where( :is_hidden => false ).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||||
end
|
end
|
||||||
|
|
||||||
get_categorys
|
get_categorys
|
||||||
|
|
|
@ -10,14 +10,12 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if !params[:category_id].blank?
|
if !params[:category_id].blank?
|
||||||
@web_links = WebLink.where(:web_link_category => params[:category_id]).available_for_lang(I18n.locale).desc( :is_top, :postdate).page( params[:page]).per(10)
|
@web_links = WebLink.where(:web_link_category => params[:category_id]).available_for_lang(I18n.locale).desc( :is_top, :postdate).page( params[:page]).per(@page_num)
|
||||||
@current_category = WebLinkCategory.from_id(params[:category_id]) rescue nil
|
@current_category = WebLinkCategory.from_id(params[:category_id]) rescue nil
|
||||||
elsif !params[:tag_id].blank?
|
elsif !params[:tag_id].blank?
|
||||||
@tag = WebResourceTag.find(params[:tag_id]) rescue nil
|
@web_links = WebLink.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||||
@tag = WebResourceTag.where(key: params[:tag_id])[0] unless @tag
|
|
||||||
@web_links = @tag.web_links.desc( :is_top, :postdate).page( params[:page]).per(10)
|
|
||||||
else
|
else
|
||||||
@web_links = WebLink.available_for_lang(I18n.locale).desc( :is_top, :postdate).page( params[:page]).per(10)
|
@web_links = WebLink.available_for_lang(I18n.locale).desc( :is_top, :postdate).page( params[:page]).per(@page_num)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -57,10 +57,6 @@ class WebLink
|
||||||
self.is_top
|
self.is_top
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_tags
|
|
||||||
tags.order_by(I18n.locale, :asc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
@ -80,7 +76,7 @@ class WebLink
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_tags
|
def clean_tags
|
||||||
self.tag_ids.delete('')
|
self.tagged_ids.delete('')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue