Controlador para la traducción de Tags
Busca los tags duplicados
# File app/controllers/admin/tags_controller.rb, line 93 def find_duplicates @duplicated_tags = Tag.duplicated_tags end
Listado de tags
# File app/controllers/admin/tags_controller.rb, line 34 def index if params[:q] conditions = ["sanitized_name_es || ' ' || sanitized_name_eu || ' ' || sanitized_name_en LIKE ?", "%#{params[:q].tildes.downcase}%"] @title = "Tags: #{params[:q]}" elsif params[:l] @l = params[:l] if (@l=='A') conditions = ["sanitized_name_es LIKE ? and sanitized_name_es NOT LIKE ?", "#{@l.downcase}%","#{'acuerdosdelconsejodegobiernode'}%"] elsif @l.eql?('hashtag') conditions = "name_es LIKE '#%'" else conditions = ["sanitized_name_es LIKE ?", "#{@l.downcase}%"] end @title = "Tags: #{@l}" else conditions = nil end if conditions @tags = Tag.public.find(:all, :conditions => conditions, :order => "tildes(lower(name_es))") else @tags = [] end end
Busca los tags duplicados y los reagrupa en un sólo tag
# File app/controllers/admin/tags_controller.rb, line 98 def merge if params[:cancel] flash[:notice] = "Los tags se han dejado como estaban" else merge_duplicated_tags! # @duplicated_tags = Tag.duplicated_tags # # @duplicated_tags.group_by(&:sanitized_name_es).each do |san_name, tags| # tags.sort!{|c1, c2| c2.taggings.count <=> c1.taggings.count} # reference_tag = tags.first # duplicated_tags = tags - [tags.first] # duplicated_tags.each do |tag| # Tagging.update_all("tag_id=#{reference_tag.id}", "tag_id=#{tag.id}") # Tag.find(tag.id).destroy # end # end flash[:notice] = "Los tags se han agrupado" end redirect_to admin_tags_path end
# File app/controllers/admin/tags_controller.rb, line 76 def set_tag_kind @item = Tag.find(params[:id]) @item.update_attribute(:kind, params[:value]) render :update do |page| page.replace_html "tag_kind_#{params[:id]}_in_place_editor", @item.kind.to_s end end
# File app/controllers/admin/tags_controller.rb, line 84 def set_tag_kind_info @item = Tag.find(params[:id]) @item.update_attribute(:kind_info, params[:value]) render :update do |page| page.replace_html "tag_kind_info_#{params[:id]}_in_place_editor", @item.kind_info.to_s end end
# File app/controllers/admin/tags_controller.rb, line 131 def set_tag_name @tag = Tag.find(params[:id]) if @tag.update_attribute("name_#{params[:locale]}", params[:value]) render :update do |page| page.replace "tag_row_#{@tag.id}", :partial => "tag_row", :locals => {:tag => @tag} end else end end
# File app/controllers/admin/tags_controller.rb, line 120 def update @tag = Tag.find(params[:id]) render :update do |page| if @tag.update_attributes(params[:tag]) page.replace "tag_row_#{@tag.id}", :partial => "tag_row", :locals => {:tag => @tag} else page.alert("El estado del tag no se ha actualizado") end end end