Class: EventsController

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

Instance Method Summary collapse

Instance Method Details

#assignObject



59
60
61
62
63
64
65
66
67
# File 'app/controllers/events_controller.rb', line 59

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



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

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



51
52
53
# File 'app/controllers/events_controller.rb', line 51

def edit
  authorize! :edit, @event
end

#imageObject



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

def image
  authorize! :edit, @event
end

#indexObject



23
24
25
26
# File 'app/controllers/events_controller.rb', line 23

def index
  authorize! :view, Event
  @events = current_organization.events.includes(:shows, :venue).order('updated_at DESC')
end

#messagesObject



127
128
# File 'app/controllers/events_controller.rb', line 127

def messages
end

#newObject



44
45
46
47
48
49
# File 'app/controllers/events_controller.rb', line 44

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

#pricesObject



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

def prices
end

#resellObject



130
131
132
133
# File 'app/controllers/events_controller.rb', line 130

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

#showObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/events_controller.rb', line 28

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


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

def storefront_link
end

#temp_discount_formObject



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'app/controllers/events_controller.rb', line 113

def temp_discount_form
  find_event

  @discount = TempDiscount.new
  @discount.promotion_type = 'two-for-one'

  @event.charts.collect(&:sections).flatten.each do |section|
    @discount.discount_sections.new(
      :section => section,
      :price => section.price
    )
  end
end

#temp_discounts_indexObject



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

def temp_discounts_index
  find_event
end

#updateObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'app/controllers/events_controller.rb', line 69

def update
  authorize! :edit, @event

  if @event.update_attributes(params[:event])
    if user_requesting_next_step?
      if user_just_uploaded_an_image?
        redirect_to messages_event_path(@event)
      elsif user_set_special_instructions?
        redirect_to event_shows_path(@event)
      else
        redirect_to edit_event_venue_path(@event)
      end
    else
      flash[:notice] = "Your event has been updated."
      redirect_to event_url(@event)
    end
  else
    render :edit
  end
end

#widgetObject



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

def widget
end

#wp_pluginObject



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

def wp_plugin
end