Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Altered for booking system

  • Loading branch information...
commit a9e25296b33c2ebe9f99d307558776eb26df2910 1 parent 36255fe
carboes authored
30 app/controllers/admin/events_controller.rb
View
@@ -20,24 +20,26 @@ def index
end
def setup_options
- 2.times do
+ extra = 5 - @event.event_options.length
+ extra.times do
@event.event_options.push(EventOption.new)
end
end
- # def create
- # @event = Branch.create!(params[:event])
- # #@event.event_options.destroy_all(:name => '')
- # redirect_to :action => :index
- # end
- #
- # def update
- # find_event
- # @event.update_attributes(params[:event])
- # @event.update_attributes(:gc_updated => false)
- # #@event.event_options.destroy_all(:name => '')
- # redirect_to :action => :index
- # end
+ def create
+ @event = Event.create!(params[:event])
+ @event.update_attributes(:gc_updated => false)
+ EventOption.destroy_all(:event_id => @event.id, :name => '')
+ redirect_to :action => :index
+ end
+
+ def update
+ #find_event
+ @event.update_attributes(params[:event])
+ @event.update_attributes(:gc_updated => false)
+ EventOption.destroy_all(:event_id => @event.id, :name => '')
+ redirect_to :action => :index
+ end
protected
1  app/models/event.rb
View
@@ -2,6 +2,7 @@ class Event < ActiveRecord::Base
has_many :event_categorizations
has_many :categories, :through => :event_categorizations, :source => :event_category
has_many :event_options
+ has_many :booking_events
default_scope order('start_at ASC')
25 app/models/event_option.rb
View
@@ -0,0 +1,25 @@
+class EventOption < ActiveRecord::Base
+ default_scope order('name ASC')
+
+ belongs_to :events
+ has_many :event_options
+
+ #validates :name, :presence => true
+ validates :ticket_price, :numericality => true, :allow_blank => true
+
+ #has_friendly_id :name, :use_slug => true
+
+ def summary
+ summary = name
+ summary += " - #{ticket_price}" if ticket_price?
+ return summary
+ end
+
+ def price
+ ticket_price? ? ticket_price : 0#event.ticket_price
+ end
+
+ def deposit
+ min_deposit? ? min_deposit : 0#self.event.min_deposit
+ end
+end
19 app/views/admin/events/_event_option.haml
View
@@ -0,0 +1,19 @@
+- @controller.setup_options
+%table
+ %thead
+ %tr
+ %td Option Name
+ %td Option Price
+ %td Minimum Deposit
+ %tbody
+ - f.fields_for :event_options do |builder|
+ %tr
+ %td
+ = builder.text_field :name
+ %td
+ &pound;
+ = builder.text_field :ticket_price
+ %td
+ &pound;
+ = builder.text_field :min_deposit
+
25 app/views/admin/events/_form.html.erb
View
@@ -83,6 +83,11 @@
</div>
<div class='field'>
+ <%= f.label :min_deposit -%>
+ &pound; <%= f.text_field :min_deposit -%>
+ </div>
+
+ <div class='field'>
<%= f.label :ticket_link -%>
<%= f.text_field :ticket_link, :class => 'larger wide' -%>
</div>
@@ -96,30 +101,12 @@
:locals => {
:gc_link => @event.gc_link
} %>
-
</div>
<% end -%>
<div class='field'>
<h2>Options</h2>
- <%- @controller.setup_options %>
- <table>
- <thead>
- <tr>
- <td>
- Name
- </td>
- <td>
- Ticket Price
- </td>
- </tr>
- </thead>
- <tbody>
- <%- f.fields_for :event_options do |builder| %>
- <%= render :partial => 'event_option', :locals => { :f => builder } %>
- <%- end %>
- </tbody>
- </table>
+ <%= render :partial => 'event_option', :locals => { :f => f } %>
</div>
<%= render :partial => "/shared/admin/form_actions",
4 app/views/events/_event.haml
View
@@ -8,8 +8,8 @@
= image_fu event.image
%p
- %button.book Book now
- = link_to 'Add to Calendar', event.gc_link, :target => '_blank'
+ %button.book{:'data-id' => event.id, :'data-name' => event.title, :'data-type' => 'event'} Book now
+ = render :partial => '/calendar/event', :locals => { :gc_link => event.gc_link }
%section.event_info
/- unless individual
32 app/views/events/_sidebar.haml
View
@@ -8,16 +8,12 @@
#events_sidebar
- #booking_items
- %h2 My Bookings
- %aside.sidebar_module
- %ul
- %button.checkout Checkout
- %button.clear Clear
+ = render :partial => '/bookings/cart'
- / %aside.sidebar_module.rss
- / %h3 RSS
- / = link_to "Subscribe", events_path(:format => :rss)
+ %aside.sidebar_module.rss
+ %h3 RSS
+ = link_to "Subscribe", events_path(:format => :rss)
+
.panel
%h2 Upcoming Courses
%aside.sidebar_module.events
@@ -43,15 +39,15 @@
/ - @event_categories.each do |category|
/ %li
/ = link_to category.name+'s', category_events_path(category)
-
- / - unless controller.action_name == "index" or controller.action_name == "archive"
- / %aside.sidebar_module.other_events
- / %h2
- / = t('.other')
- / %ul#events
- / - @other_events.each do |event|
- / %li
- / = link_to event.title, event_url(event)
+
+ - unless controller.action_name == "index" or controller.action_name == "archive"
+ %aside.sidebar_module.other_events
+ %h2
+ = t('.other')
+ %ul#events
+ - @other_events.each do |event|
+ %li
+ = link_to event.title, event_url(event)
.panel
%h2 Archives
%aside.sidebar_module.archives
2  app/views/events/show.haml
View
@@ -7,7 +7,7 @@
- content_for :body_content_title do
/= @event.title
- content_for :body_content_left do
- #events
+ #events.bookings
= render :partial => 'event', :locals => { :event => @event, :individual => true }
= render 'events/sidebar'
= render :partial => "/shared/content_page"
Please sign in to comment.
Something went wrong with that request. Please try again.