Class | EventsController
In: | app/controllers/events_controller.rb
Parent: | ApplicationController

Controlador para los eventos públicos.

### Methods

index show

### Public Instance methods

index()

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.

[Source]

        # 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:       conditions = {}
    28:       @dept_label = params[:dept_label]  || 'all'
    29:       if params[:dept_label]
    30:         tag_name = "_#{params[:dept_label]}".gsub(/[^\w_]/,'')
    31:         if Department.tag_names.include?(tag_name)
    32:           @dept = Department.find_by_tag_name(tag_name)
    33:           conditions["documents.organization_id"] = [@dept.id] + @dept.organization_ids
    34:           @title << ": #{@dept.name}"
    35:         end
    36:       end
    37:
    38:       joins = nil
    39:       @tag_label = params[:tag_label]
    40:       if @tag_label && Event.show_in_opts.map {|o| "_irekia_#{o}"}.include?(@tag_label)
    41:         if itag = Tag.find_by_sanitized_name_es(@tag_label)
    42:           conditions['taggings.tag_id'] = itag.id
    43:           joins = [:taggings]
    44:           @title << ": #{itag.name}"
    45:         end
    46:       end
    47:
    48:       @events = events_scope.paginate :page => params[:page], :conditions => conditions, :joins => joins
    49:
    50:     end

show()

Ver los datos públicos de un evento publicado.

[Source]

        # File app/controllers/events_controller.rb, line 53
    53:     def show
    54:       begin
    55:         @event = Event.in_irekia.published.find(params[:id])
    56:       rescue ActiveRecord::RecordNotFound
    57:         if can_edit?("events")
    58:           @event = Event.in_irekia.find(params[:id])
    59:         else
    60:           #raise ActiveRecord::RecordNotFound
    61:           bad_record
    62:           return
    63:         end
    64:       end
    65:
    66:       if @category
    67:         # Comprobar que la categoria y el documento estan relacionados
    68:         if @event.tags.private.collect(&:name_es) & @category.tags.private.collect(&:name_es) == []
    69:           logger.info "Categoria y documento no relacionados"
    70:           raise ActiveRecord::RecordNotFound
    71:         end
    72:       end
    73:
    74:       respond_to do |format|
    75:         format.html {
    76:           render
    77:         }
    78:         format.iphone {
    79:           render :layout => false
    80:         }
    81:       end
    82:
    83:     end

[Validate]