| Class | EventsController |
| In: |
app/controllers/events_controller.rb
|
| Parent: | ApplicationController |
Lista de los eventos actuales. Por defecto se muestran todos los eventos desde el día anterior al día actual.
La lista de puede restringir por departamento o por Tag. Se puede indicar también si hay que mostrar los eventos actuales o los del archivo.
# File app/controllers/events_controller.rb, line 11
11: def index
12: @title = t('documents.Events')
13:
14: @archive = params[:archive] || 'f'
15:
16: if @archive.eql?('f')
17: events_scope = Event.in_irekia.published.translated.future(Time.zone.now - 1.day)
18: #conditions = "ends_at::date >= now()::date"
19: # @title << ": #{t('events.comming_events')}"
20: @title << ": #{t('events.current_events')}"
21: else
22: #conditions = "ends_at::date < now()::date"
23: events_scope = Event.passed.in_irekia.published.translated
24: @title << ": #{t('events.archive')}"
25: end
26:
27: cj = get_list_conditions()
28: # conditions = {}
29: # @dept_label = params[:dept_label] || 'all'
30: # if params[:dept_label]
31: # tag_name = "_#{params[:dept_label]}".gsub(/[^\w_]/,'')
32: # if Department.tag_names.include?(tag_name)
33: # @dept = Department.find_by_tag_name(tag_name)
34: # conditions["documents.organization_id"] = [@dept.id] + @dept.organization_ids
35: # @title << ": #{@dept.name}"
36: # end
37: # end
38: #
39: # joins = nil
40: # @tag_label = params[:tag_label]
41: # if @tag_label && Event.show_in_opts.map {|o| "_irekia_#{o}"}.include?(@tag_label)
42: # if @itag = Tag.find_by_sanitized_name_es(@tag_label)
43: # conditions['taggings.tag_id'] = @itag.id
44: # joins = [:taggings]
45: # # @title << ": #{@itag.name}"
46: # end
47: # end
48:
49: @events = events_scope.paginate :page => params[:page], :conditions => cj[:conditions], :joins => cj[:joins]
50:
51: # respond_to do |format|
52: # format.html { render }
53: # format.ics { render :layout => false }
54: # end
55:
56: end
RSS de los eventos públicos
# File app/controllers/events_controller.rb, line 93
93: def myfeed
94: @title = t('documents.Events')
95: cj = get_list_conditions()
96: respond_to do |format|
97: format.ics {
98: @events = Event.in_irekia.published.translated.future(1.month.ago).find(:all, :conditions => cj[:conditions], :joins => cj[:joins])
99: render :layout => false
100: }
101: end
102: end
Ver los datos públicos de un evento publicado.
# File app/controllers/events_controller.rb, line 59
59: def show
60: @title = t('documents.Events')
61: begin
62: @event = Event.in_irekia.published.find(params[:id])
63: rescue ActiveRecord::RecordNotFound
64: if can_edit?("events")
65: @event = Event.in_irekia.find(params[:id])
66: else
67: #raise ActiveRecord::RecordNotFound
68: bad_record
69: return
70: end
71: end
72:
73: if @category
74: # Comprobar que la categoria y el documento estan relacionados
75: if @event.tags.private.collect(&:name_es) & @category.tags.private.collect(&:name_es) == []
76: logger.info "Categoria y documento no relacionados"
77: raise ActiveRecord::RecordNotFound
78: end
79: end
80:
81: respond_to do |format|
82: format.html { render }
83: format.ics { render :layout => false}
84: format.iphone
85: format.android
86: format.floki
87: format.ipad {render :layout => "application.floki"}
88: end
89:
90: end