| Class | Admin::DocumentsController |
| In: |
app/controllers/admin/documents_controller.rb
|
| Parent: | Admin::BaseController |
# File app/controllers/admin/documents_controller.rb, line 137
137: def auto_complete_for_document_tag_list_es
138: auto_complete_for_tag_list(params[:document][:tag_list_es])
139: if @tags.length > 0
140: render :inline => "<%= content_tag(:ul, @tags.map {|t| content_tag(:li, t.nombre)}) %>"
141: else
142: render :nothing => true
143: end
144: end
# 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', :what => t('documents.Document'))
36: redirect_to admin_document_path(@document.id)
37: else
38: render :action => 'new'
39: end
40: end
# File app/controllers/admin/documents_controller.rb, line 120
120: def destroy
121: check_access
122: set_current_tab
123:
124: if @document.destroy
125: flash[:notice] = t('sadmin.eliminado_correctamente', :what => t('documents.News'))
126: if @t.eql?("news")
127: redirect_to sadmin_news_index_path and return
128: else
129: redirect_to admin_documents_path(:t => @t)
130: end
131: else
132: flash[:error] = t('sadmin.no_eliminado_correctamente', :what => t('documents.News'))
133: redirect_to :back
134: end
135: end
# 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
# File app/controllers/admin/documents_controller.rb, line 95
95: def edit_tags
96: check_access
97: if (@document.is_a?(News) && !can?("complete", "news")) || (@document.is_a?(Event) && !is_admin?)
98: flash[:error] = "No puedes acceder a estas páginas"
99: redirect_to admin_document_path(@document.id, :w => "traducciones") and return
100: end
101: set_current_tab
102: @w = params[:w] || "multimedia"
103: @title = t('sadmin.modificar_what', :what => @pretty_type)
104: end
/Cosas solo de paginas
# File app/controllers/admin/documents_controller.rb, line 44
44: def index
45: @sort_order = params[:sort] || "update"
46:
47: case @sort_order
48: when "update"
49: order = "updated_at DESC, title_es, published_at DESC"
50: when "publish"
51: order = "published_at DESC, title_es, updated_at DESC"
52: when "title"
53: order = "lower(tildes(title_es)), published_at DESC, updated_at DESC"
54: end
55:
56: conditions = []
57: if params[:q].present?
58: conditions << "lower(tildes(coalesce(title_es, '') || ' ' || coalesce(title_eu, ''))) like '%#{params[:q].tildes.downcase}%'"
59: end
60:
61: set_current_tab
62:
63: if @t.eql?("news")
64: redirect_to sadmin_news_index_path and return
65: elsif (["event", "events"].include?(@t))
66: redirect_to sadmin_events_path and return
67: end
68:
69: @documents = @t.singularize.camelize.constantize.paginate :page => params[:page], :per_page => 20,
70: :order => order,
71: :conditions => conditions.join(' AND ')
72:
73: @title = t("documents.#{@t.titleize}")
74:
75: end
Cosas solo de paginas
# File app/controllers/admin/documents_controller.rb, line 21
21: def new
22: @t = params[:t] || 'doc'
23: @title = t('sadmin.create_what', :what => @pretty_type)
24: @document = @t.singularize.camelize.constantize.new
25:
26: set_current_tab
27: end
# File app/controllers/admin/documents_controller.rb, line 146
146: def publish
147: check_access
148: @document.update_attributes(:draft => false, :published_at => nil)
149: submit_to_ubervu(@document)
150: redirect_to :back
151: end
# File app/controllers/admin/documents_controller.rb, line 78
78: def show
79: check_access
80: @w = params[:w] || "multimedia"
81: if (@w.eql?("multimedia") && !can?("complete", "news")) || (@w.eql?("more_info") && !is_admin?)
82: flash[:error] = "No puedes acceder a estas páginas"
83: redirect_to admin_document_path(@document.id, :w => "traducciones") and return
84: end
85: @title = "#{@document.title}"
86: set_current_tab
87: end
# File app/controllers/admin/documents_controller.rb, line 106
106: def update
107: check_access
108: @document.attributes = params[:document]
109: set_current_tab
110: @title = t('sadmin.modificar_what', :what => @pretty_type)
111:
112: if @document.save
113: flash[:notice] = t('sadmin.guardado_correctamente', :what => @pretty_type)
114: redirect_to admin_document_path(@document.id, :w => params[:w])
115: else
116: render :action => params[:return_to] || 'edit'
117: end
118: end