| Class | Admin::DocumentsController |
| In: |
app/controllers/admin/documents_controller.rb
|
| Parent: | Admin::BaseController |
Auto complete para los tags
# File app/controllers/admin/documents_controller.rb, line 152
152: def auto_complete_for_document_tag_list_es
153: auto_complete_for_tag_list(params[:document][:tag_list_es])
154: if @tags.length > 0
155: render :inline => "<%= content_tag(:ul, @tags.map {|t| content_tag(:li, t.nombre)}) %>"
156: else
157: render :nothing => true
158: end
159: end
Creación de nueva página
# File app/controllers/admin/documents_controller.rb, line 29
29: def create
30: set_current_tab
31: @title = t('sadmin.create_what', :what => @pretty_type)
32: @document = @t.singularize.camelize.constantize.new(params[:document])
33:
34: if @document.save
35: flash[:notice] = t('sadmin.guardado_correctamente', :article => t('documents.Document').gender_article, :what => t('documents.Document'))
36: redirect_to admin_document_path(@document.id)
37: else
38: render :action => 'new'
39: end
40: end
Eliminación de una noticia, evento, página
# File app/controllers/admin/documents_controller.rb, line 134
134: def destroy
135: check_access
136: set_current_tab
137:
138: if @document.destroy
139: flash[:notice] = t('sadmin.eliminado_correctamente', :article => @document.class.human_name.gender_article, :what => @document.class.human_name)
140: if @t.eql?("news")
141: redirect_to sadmin_news_index_path and return
142: else
143: redirect_to admin_documents_path(:t => @t)
144: end
145: else
146: flash[:error] = t('sadmin.no_eliminado_correctamente', :article => @document.class.human_name.gender_article, :what => @document.class.human_name)
147: redirect_to :back
148: end
149: end
Formulario de modificación de una página
# File app/controllers/admin/documents_controller.rb, line 89
89: def edit
90: check_access
91: set_current_tab
92: @title = t('sadmin.modificar_what', :what => @pretty_type)
93: end
Modificación de la información adicional de una noticia, evento, página
# File app/controllers/admin/documents_controller.rb, line 96
96: def edit_tags
97: check_access
98: if (@document.is_a?(News) && !can?("complete", "news")) || (@document.is_a?(Event) && !is_admin?)
99: flash[:error] = "No puedes acceder a estas páginas"
100: redirect_to admin_document_path(@document.id, :w => "traducciones") and return
101: end
102: set_current_tab
103: @w = params[:w] || "multimedia"
104: @title = t('sadmin.modificar_what', :what => @pretty_type)
105:
106: if @document.is_a?(Event)
107: @overlap_events_with_streaming = @document.overlapped_streaming
108: end
109: end
Listado de páginas
# File app/controllers/admin/documents_controller.rb, line 43
43: def index
44: @sort_order = params[:sort] || "update"
45:
46: case @sort_order
47: when "update"
48: order = "updated_at DESC, title_es, published_at DESC"
49: when "publish"
50: order = "published_at DESC, title_es, updated_at DESC"
51: when "title"
52: order = "lower(tildes(title_es)), published_at DESC, updated_at DESC"
53: end
54:
55: conditions = []
56: if params[:q].present?
57: conditions << "lower(tildes(coalesce(title_es, '') || ' ' || coalesce(title_eu, ''))) like '%#{params[:q].tildes.downcase}%'"
58: end
59:
60: set_current_tab
61:
62: if @t.eql?("news")
63: redirect_to sadmin_news_index_path and return
64: elsif (["event", "events"].include?(@t))
65: redirect_to sadmin_events_path and return
66: end
67:
68: @documents = @t.singularize.camelize.constantize.paginate :page => params[:page], :per_page => 20,
69: :order => order,
70: :conditions => conditions.join(' AND ')
71:
72: @title = t("documents.#{@t.titleize}")
73:
74: end
Formulario de nueva página
# File app/controllers/admin/documents_controller.rb, line 20
20: def new
21: @t = params[:t] || 'doc'
22: @title = t('sadmin.create_what', :what => @pretty_type)
23: @document = @t.singularize.camelize.constantize.new
24:
25: set_current_tab
26: end
Marca una página como publicada
# File app/controllers/admin/documents_controller.rb, line 162
162: def publish
163: check_access
164: @document.update_attributes(:draft => false, :published_at => nil)
165: redirect_to :back
166: end
Vista de información adicional de una noticia, página o evento
# File app/controllers/admin/documents_controller.rb, line 77
77: def show
78: check_access
79: @w = params[:w] || "multimedia"
80: if (@w.eql?("multimedia") && !can?("complete", "news")) || (@w.eql?("more_info") && !is_admin?)
81: flash[:error] = "No puedes acceder a estas páginas"
82: redirect_to admin_document_path(@document.id, :w => "traducciones") and return
83: end
84: @title = "#{@document.title}"
85: set_current_tab
86: end
Modificación de la información adicional de una noticia, evento, página
# File app/controllers/admin/documents_controller.rb, line 112
112: def update
113: check_access
114: @document.attributes = params[:document]
115: set_current_tab
116: @title = t('sadmin.modificar_what', :what => @pretty_type)
117:
118: if @document.save
119: flash[:notice] = t('sadmin.guardado_correctamente', :article => @document.class.human_name.gender_article, :what => @document.class.human_name)
120: if @document.respond_to?('draft_news') && @document.draft_news.to_i.eql?(1) && @document.is_a?(Event) && !@document.has_related_news?
121: redirect_to new_sadmin_news_path(:related_event_id => @document.id)
122: else
123: redirect_to admin_document_path(@document.id, :w => params[:w])
124: end
125: else
126: if @document.is_a?(Event)
127: @overlap_events_with_streaming = @document.overlapped_streaming
128: end
129: render :action => params[:return_to] || 'edit'
130: end
131: end