Class: EventsController

Inherits:
ArtfullyOseController show all
Defined in:
app/controllers/events_controller.rb

Instance Method Summary collapse

Instance Method Details

#assignObject



69
70
71
72
73
74
75
76
77
# File 'app/controllers/events_controller.rb', line 69

def assign
  @event = Event.find(params[:event_id])
  @chart = Chart.find(params[:chart][:id])
  @event.assign_chart(@chart)

  flash[:error] = @event.errors.full_messages.to_sentence unless @event.errors.empty?

  redirect_to event_url(@event)
end

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/events_controller.rb', line 8

def create
  @event = Event.new(params[:event])
  @templates = current_organization.charts.template
  @event.organization_id = current_organization.id
  @event.is_free = !(current_organization.can? :access, :paid_ticketing)
  @event.venue.organization_id = current_organization.id
  @event.venue.time_zone = current_organization.time_zone
  @event.contact_email = current_organization.try(:email) || current_user.email

  if @event.save
    redirect_to edit_event_url(@event)
  else
    render :new
  end
end

#destroyObject



90
91
92
93
94
95
# File 'app/controllers/events_controller.rb', line 90

def destroy
  authorize! :destroy, @event
  @event.destroy
  flash[:notice] = "Your event has been deleted"
  redirect_to events_url
end

#editObject



61
62
63
# File 'app/controllers/events_controller.rb', line 61

def edit
  authorize! :edit, @event
end

#imageObject



65
66
67
# File 'app/controllers/events_controller.rb', line 65

def image
  authorize! :edit, @event
end

#indexObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/events_controller.rb', line 24

def index
  authorize! :view, Event

  scope = Event.unscoped.where(:deleted_at => nil).where(:organization_id => current_organization.id).includes(:shows).order('name ASC')
  scope = if params[:range].present? && params[:range] == 'all'
    @all = scope
  else
    @upcoming = scope.where :id => current_organization.shows.unplayed.pluck(:event_id).uniq
  end

  scope   = scope.where('LOWER(name) LIKE ?', "%#{params[:query].downcase}%") unless params[:query].blank?
  @events = scope
end

#messagesObject



113
114
# File 'app/controllers/events_controller.rb', line 113

def messages
end

#newObject



54
55
56
57
58
59
# File 'app/controllers/events_controller.rb', line 54

def new
  @event = current_organization.events.build(:producer => current_organization.name)
  @event.venue = Venue.new
  authorize! :new, @event
  @templates = current_organization.charts.template
end

#passesObject



110
111
# File 'app/controllers/events_controller.rb', line 110

def passes
end

#pricesObject



107
108
# File 'app/controllers/events_controller.rb', line 107

def prices
end

#resellObject



116
117
118
119
# File 'app/controllers/events_controller.rb', line 116

def resell
  @organization = current_organization
  @reseller_profiles = ResellerProfile.includes(:organization).order("organizations.name").all
end

#showObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/events_controller.rb', line 38

def show
  authorize! :view, @event
  @shows = @event.shows.paginate(:page => params[:page], :per_page => 25)

  respond_to do |format|
    format.json do
      render :json => @event.as_full_calendar_json
    end

    format.html do
      render :show
    end
  end

end


101
102
# File 'app/controllers/events_controller.rb', line 101

def storefront_link
end

#updateObject



79
80
81
82
83
84
85
86
87
88
# File 'app/controllers/events_controller.rb', line 79

def update
  authorize! :edit, @event

  if @event.update_attributes(params[:event])
    build_flash_message
    redirect_to redirect_path and return
  else
    render :edit
  end
end

#widgetObject



97
98
99
# File 'app/controllers/events_controller.rb', line 97

def widget
  @donation_kit = current_user.current_organization.kit(:regular_donation)
end

#wp_pluginObject



104
105
# File 'app/controllers/events_controller.rb', line 104

def wp_plugin
end