Auto complete para los tags
# File app/controllers/admin/documents_controller.rb, line 184 def auto_complete_for_document_tag_list_without_areas auto_complete_for_tag_list(params[:document][:tag_list_without_areas]) if @tags.length > 0 render :inline => "<%= content_tag(:ul, @tags.map {|t| content_tag(:li, t.nombre)}) %>" else render :nothing => true end end
Creación de nueva página
# File app/controllers/admin/documents_controller.rb, line 60 def create set_current_tab @title = t('sadmin.create_what', :what => @pretty_type) @document = @t.singularize.camelize.constantize.new(params[:document]) @debate = @document.debate if @document.save flash[:notice] = t('sadmin.guardado_correctamente', :article => t('documents.document').gender_article, :what => t('documents.Document')) redirect_to admin_document_path(@document.id) else render :action => 'new' end end
Eliminación de una noticia, evento, página
# File app/controllers/admin/documents_controller.rb, line 166 def destroy check_access set_current_tab if @document.destroy flash[:notice] = t('sadmin.eliminado_correctamente', :article => @document.class.human_name.gender_article, :what => @document.class.human_name) if @t.eql?("news") redirect_to sadmin_news_index_path and return else redirect_to admin_documents_path(:t => @t) end else flash[:error] = t('sadmin.no_eliminado_correctamente', :article => @document.class.human_name.gender_article, :what => @document.class.human_name) redirect_to :back end end
Formulario de modificación de una página
# File app/controllers/admin/documents_controller.rb, line 121 def edit check_access set_current_tab @title = t('sadmin.modificar_what', :what => @pretty_type) end
Listado de páginas
# File app/controllers/admin/documents_controller.rb, line 75 def index @sort_order = params[:sort] || "update" case @sort_order when "update" order = "updated_at DESC, title_es, published_at DESC" when "publish" order = "published_at DESC, title_es, updated_at DESC" when "title" order = "lower(tildes(title_es)), published_at DESC, updated_at DESC" end conditions = [] if params[:q].present? conditions << "lower(tildes(coalesce(title_es, '') || ' ' || coalesce(title_eu, ''))) like '%#{params[:q].tildes.downcase}%'" end set_current_tab if @t.eql?("news") redirect_to sadmin_news_index_path and return elsif (["event", "events"].include?(@t)) redirect_to sadmin_events_path and return end @documents = @t.singularize.camelize.constantize.paginate :page => params[:page], :per_page => 20, :order => order, :conditions => conditions.join(' AND ') @title = t("#{@t.tableize}.title") end
Formulario de nueva página
# File app/controllers/admin/documents_controller.rb, line 41 def new @t = params[:t] || 'doc' @title = t('sadmin.create_what', :what => @pretty_type) @document = @t.singularize.camelize.constantize.new set_current_tab if params[:debate_id].present? if @debate = Debate.find(params[:debate_id]) ["title_es", "title_eu", "title_en", "tag_list_es", "organization_id"].each do |m| @document.send("#{m}=", @debate.send(m)) end @document.multimedia_dir = "cont_#{@debate.multimedia_dir}" @document.debate = @debate end end end
Marca una página como publicada
# File app/controllers/admin/documents_controller.rb, line 194 def publish check_access @document.update_attributes(:published_at => Time.zone.now) redirect_to :back end
Vista de información adicional de una noticia, página o evento
# File app/controllers/admin/documents_controller.rb, line 109 def show check_access @w = params[:w] || "multimedia" if (@w.eql?("multimedia") && !can?("complete", "news")) || (@w.eql?("more_info") && !is_admin?) flash[:error] = "No puedes acceder a estas páginas" redirect_to admin_document_path(@document.id, :w => "traducciones") and return end @title = "#{@document.title}" set_current_tab end
Modificación de la información adicional de una noticia, evento, página
# File app/controllers/admin/documents_controller.rb, line 144 def update check_access @document.attributes = params[:document] set_current_tab @title = t('sadmin.modificar_what', :what => @pretty_type) if @document.save flash[:notice] = t('sadmin.guardado_correctamente', :article => @document.class.human_name.gender_article, :what => @document.class.human_name) if @document.respond_to?('draft_news') && @document.draft_news.to_i.eql?(1) && @document.is_a?(Event) && !@document.has_related_news? redirect_to new_sadmin_news_path(:related_event_id => @document.id) else redirect_to admin_document_path(@document.id, :w => params[:w]) end else if @document.is_a?(Event) @overlap_events_with_streaming = @document.overlapped_streaming end render :action => params[:return_to] || 'edit' end end