diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb index 9cdcd0a2..1b29f5f1 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb @@ -10,7 +10,9 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController get_categorys(params[:web_link_category_id]) - @web_links = WebLink.search(params[:search],params[:category_id]) + @web_links = WebLink.search(params[:category_id]) + + get_tags() respond_to do |format| format.html # index.html.erb @@ -35,6 +37,8 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController def new @web_link = WebLink.new + get_tags() + get_categorys respond_to do |format| @@ -47,6 +51,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController def edit @web_link = WebLink.find(params[:id]) get_categorys + get_tags() end # POST /web_links @@ -74,6 +79,8 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController @web_link = WebLink.find(params[:id]) @web_link.update_user_id = current_user.id + + params[:web_link][:tag_ids] ||=[] respond_to do |format| if @web_link.update_attributes(params[:web_link]) @@ -106,4 +113,9 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController @web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true)) end + def get_tags() + module_app = ModuleApp.first(:conditions => {:key => 'web_resource'}) + @tags = Tag.all(:conditions => {:module_app_id => module_app.id}) + end + end diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb index e7400b27..c230140d 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb @@ -12,9 +12,7 @@ class Panel::WebResource::FrontEnd::WebLinksController < ObitWidgetController date_now = Time.now - # @web_links = WebLink.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(1) - - @web_links = WebLink.desc("is_top").page( params[:page]) + @web_links = WebLink.where( :is_hidden => false ).desc(:is_top, :name).page( params[:page]).per(20) get_categorys end diff --git a/vendor/built_in_modules/web_resource/app/models/web_link.rb b/vendor/built_in_modules/web_resource/app/models/web_link.rb index 364713a6..5f88a621 100644 --- a/vendor/built_in_modules/web_resource/app/models/web_link.rb +++ b/vendor/built_in_modules/web_resource/app/models/web_link.rb @@ -25,26 +25,15 @@ class WebLink before_save :set_key - def self.search( search = nil, category_id = nil ) + def self.search( category_id = nil ) - if category_id.to_s.size > 0 and search.to_s.size > 0 + if category_id.to_s.size > 0 - key = /#{search}/ - - find(:all, :conditions => {name: key, web_resource_category_id: category_id}).desc( :is_top, :postdate ) - - elsif category_id.to_s.size > 0 and search.to_s.size < 1 - - find(:all, :conditions => {web_resource_category_id: category_id}).desc( :is_top, :postdate ) - - elsif search.to_s.size > 0 and category_id.to_s.size < 1 - - key = /#{search}/ - - find(:all, :conditions => {name: key}).desc( :is_top, :postdate ) + find(:all, :conditions => {web_link_category_id: category_id}).desc( :is_top, :name ) + else - find(:all).desc( :is_top, :postdate) + find(:all).desc( :is_top, :name) end @@ -55,10 +44,10 @@ class WebLink 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) + # find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :name) + where( :is_hidden => false ).desc(:is_top, :name) # any_of({ :name => "test" },{:deadline => nil, :name => "123"}) - any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate) + # any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :name) end diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb index e57cba07..ce17555a 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb @@ -44,6 +44,14 @@ <%= f.check_box :is_hidden %><%= t('hidden') %> +