diff --git a/Gemfile b/Gemfile
index 346aee78..e6ab1ac9 100644
--- a/Gemfile
+++ b/Gemfile
@@ -90,6 +90,7 @@ gem 'rdoc-generator-fivefish'
# We use factory_girl for seeds
gem 'factory_girl_rails'
+gem 'money-rails'
# Use guard and spring for testing in development
group :development do
# rspec Guard rules
diff --git a/Gemfile.lock b/Gemfile.lock
index 2b1c3bd1..7d0663b7 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -158,6 +158,15 @@ GEM
mime-types (1.25.1)
mini_portile (0.6.0)
minitest (5.3.3)
+ monetize (0.3.0)
+ money (~> 6.1.0.beta1)
+ money (6.1.1)
+ i18n (~> 0.6.4)
+ money-rails (0.10.0)
+ activesupport (>= 3.0)
+ monetize (~> 0.3.0)
+ money (~> 6.1.1)
+ railties (>= 3.0)
multi_json (1.9.2)
mysql2 (0.3.15)
nio4r (1.0.0)
@@ -329,6 +338,7 @@ DEPENDENCIES
jquery-rails
jquery-ui-rails
letter_opener
+ money-rails
mysql2
paper_trail
paperclip
diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb
index 659d7168..e91e8dea 100644
--- a/app/helpers/home_helper.rb
+++ b/app/helpers/home_helper.rb
@@ -12,19 +12,19 @@ module HomeHelper
# * %B %d - %B %d, %Y (January 31 - February 02 2014)
# All other cases
# * %B %d, %Y - %B %d, %Y (December 30, 2013 - January 02, 2014)
- def conference_date_string(conf)
- startstr = "Unknown - "
- endstr = "Unknown"
+ def conference_date_string(start_date, end_date)
+ startstr = 'Unknown - '
+ endstr = 'Unknown'
# When the conference in the same motn
- if conf.start_date.month == conf.end_date.month and conf.start_date.year == conf.end_date.year
- startstr = conf.start_date.strftime("%B %d - ")
- endstr = conf.end_date.strftime("%d, %Y")
- elsif conf.start_date.month != conf.end_date.month && conf.start_date.year == conf.end_date.year
- startstr = conf.start_date.strftime("%B %d - ")
- endstr = conf.end_date.strftime("%B %d, %Y")
+ if start_date.month == end_date.month && start_date.year == end_date.year
+ startstr = start_date.strftime('%B %d - ')
+ endstr = end_date.strftime('%d, %Y')
+ elsif start_date.month != end_date.month && start_date.year == end_date.year
+ startstr = start_date.strftime('%B %d - ')
+ endstr = end_date.strftime('%B %d, %Y')
else
- startstr = conf.start_date.strftime("%B %d, %Y - ")
- endstr = conf.end_date.strftime("%B %d, %Y")
+ startstr = start_date.strftime('%B %d, %Y - ')
+ endstr = end_date.strftime('%B %d, %Y')
end
result = startstr + endstr
diff --git a/app/models/conference.rb b/app/models/conference.rb
index c7847610..686ef5f0 100644
--- a/app/models/conference.rb
+++ b/app/models/conference.rb
@@ -9,7 +9,7 @@ class Conference < ActiveRecord::Base
:questions_attributes, :question_ids, :answers_attributes, :answer_ids,
:difficulty_levels_attributes, :use_difficulty_levels,
:use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers,
- :media_id, :media_type
+ :media_id, :media_type, :registration_description, :ticket_description
has_paper_trail
diff --git a/app/models/supporter_level.rb b/app/models/supporter_level.rb
index e51c1be5..2f1ca6c5 100644
--- a/app/models/supporter_level.rb
+++ b/app/models/supporter_level.rb
@@ -1,6 +1,11 @@
class SupporterLevel < ActiveRecord::Base
belongs_to :conference
has_many :supporter_registrations
-
- attr_accessible :conference, :title, :url
+ monetize :price_cents, with_model_currency: :price_currency
+ attr_accessible :conference, :title, :url, :description, :price_currency, :amount, :price_cents
+ validate :convert_money_to_cents
+ private
+ def convert_money_to_cents
+ self.price_cents = (self.amount.to_d * 100).to_i
+ end
end
diff --git a/app/views/admin/conference/show.html.haml b/app/views/admin/conference/show.html.haml
index f78d0597..231d2aac 100644
--- a/app/views/admin/conference/show.html.haml
+++ b/app/views/admin/conference/show.html.haml
@@ -1,3 +1,31 @@
.row
.col-md-8
- %h1 Dashboard for #{@conference.title}
\ No newline at end of file
+ %h1 Dashboard for #{@conference.title}
+ .col-md-9
+ = semantic_form_for(@conference, :url => admin_conference_path(@conference.short_title),:html => {:multipart => true}) do |f|
+ = f.input :title, :hint => "The full name of the conference, such as 'OpenSUSE Conference 2013'"
+ = f.input :short_title, :hint => "A short title, such as 'osc2013', to be used in URLs"
+ = f.input :social_tag, :hint => "The hashtag you'll use on Twitter and Google+. Don't include the '#' sign!'"
+ = f.input :contact_email, :hint => "Contact email address for your conference. Will be used as reply-to address in emails sent out by the system."
+
+ = f.inputs :name => "Scheduling" do
+ = f.input :timezone, :as => :time_zone, :hint => "The conference time zone"
+ = f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" }
+ = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" }
+ = f.input :registration_description, hint: 'This description will appear in the splash page in registration section'
+ = f.input :registration_start_date, :as => :string, :input_html => { :id => "conference-reg-start-datepicker", :readonly => "readonly" }
+ = f.input :registration_end_date, :as => :string, :input_html => { :id => "conference-reg-end-datepicker", :readonly => "readonly" }
+
+ = f.inputs :name => "Media" do
+ - if !@conference.logo.blank?
+ = image_tag @conference.logo(:thumb)
+ = f.input :logo, :label => "Conference Logo", :hint => "This will be displayed on the front page."
+ = f.input :media_type, :as => :select, :label => "Conference Promo Media Type", :class=>"form-control", :collection => Conference.media_types.values, :include_blank => false, :hint => "This media-item will be used to represent this conference at various places in OSEM."
+ = f.input :media_id, :label => "Conference Promo Media ID", :as => :string
+ %p{:class => "help-block media-type", :id => "youtube-help"} Go to your YouTube video, click on "share" and copy everything behind http://youtu.be/"
+ %p{:class => "help-block media-type", :id => "slideshare-help", :style => "display:none"} Go to your SlideShare, click on "share" -> "embed" and copy the id
+ %p{:class => "help-block media-type", :id => "flickr-help", :style => "display:none"} Go to your flickr image, click on "Grab the link" -> "Show short url" and copy everything behind https://flic.kr/p/
+ %p{:class => "help-block media-type", :id => "vimeo-help", :style => "display:none"} Go to your vimeo video, click on "share" and copy everything behind http://vimeo.com/
+ %p{:class => "help-block media-type", :id => "speakerdeck-help", :style => "display:none"} Go to your SpeakerDeck, click on "share" -> "embed" and copy the data-id
+ %p{:class => "help-block media-type", :id => "instagram-help", :style => "display:none"} Go to your Instagram photo page and copy everything behind instagram.com/p/ (without trailing /# hash symbol)
+ = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
diff --git a/app/views/admin/supporter_levels/_supporter_level_fields.html.erb b/app/views/admin/supporter_levels/_supporter_level_fields.html.erb
index ec793dc7..7df80c2b 100644
--- a/app/views/admin/supporter_levels/_supporter_level_fields.html.erb
+++ b/app/views/admin/supporter_levels/_supporter_level_fields.html.erb
@@ -1,7 +1,11 @@
<%= f.inputs do %>
- <%= f.input :title%>
+ <%= f.input :title %>
<%= f.input :url %>
+ <%= f.input :price_currency, collection: Money::Currency.table.map{ |x| x[1][:iso_code] }, label: 'Price Currency' %>
+ <%= f.input :amount, hint: 'Enter your price in only.For 100$ enter 100 and so on' %>
+ <%= f.input :description, hint: 'This will be displayed on supoorter level category in
+ splash page' %>
<%= remove_association_link :supporter_level, f %>
<% end %>
diff --git a/app/views/admin/supporter_levels/index.html.haml b/app/views/admin/supporter_levels/index.html.haml
index 71a9305a..f7dbfdc3 100644
--- a/app/views/admin/supporter_levels/index.html.haml
+++ b/app/views/admin/supporter_levels/index.html.haml
@@ -2,5 +2,6 @@
.col-md-8
= semantic_form_for(@conference, :url => admin_conference_supporter_level_path(@conference.short_title, @conference.supporter_levels)) do |f|
= f.input :use_supporter_levels, :label => false
+ = f.input :ticket_description, hint: 'This will be displayed in Tickets segment of splash page'
= dynamic_association :supporter_levels, "Supporter Levels", f
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml
index 021d213f..5e78117f 100644
--- a/app/views/conference/show.html.haml
+++ b/app/views/conference/show.html.haml
@@ -1,3 +1,32 @@
= content_for :splash_logo do
= link_to @conference.title, "#", :class => 'navbar-brand'
-= render :partial => "home/conference_details", :locals => {:conference => @conference}
\ No newline at end of file
+= content_for :splash_header do
+ %ul.nav.navbar-nav
+ %li
+ %a{ href: '#registration' } Registration
+%div.container#registration.text-center
+ %div.row.col-md-12
+ %h2 Registration
+ - if !@conference.registration_description.blank?
+ %p
+ = @conference.registration_description
+ %h4 Registration period #{ conference_date_string(@conference.registration_start_date, @conference.registration_end_date)}
+ - if @conference.registration_open?
+ = link_to "Register for #{@conference.short_title}", register_conference_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank'
+ %div.row
+ %h3 Tickets
+ - if !@conference.ticket_description.blank?
+ %p #{ @conference.ticket_description }
+ - if @conference.use_supporter_levels?
+ - @conference.supporter_levels.each do |s|
+ %div.col-md-6
+ - if !s.title.blank?
+ %h4 #{ s.title }
+ -if !s.description.blank?
+ %p #{ s.description }
+ - if !s.url.blank?
+ %div.btn-group
+ = link_to "Buy Ticket", s.url, class: 'btn btn-success', target: '_blank'
+ - if !s.price_cents.blank?
+ = button_tag "#{ humanized_money_with_symbol s.price}", class: 'btn btn-success'
+
diff --git a/app/views/home/_conference_details.html.haml b/app/views/home/_conference_details.html.haml
index 335b25ed..1e4a0c18 100644
--- a/app/views/home/_conference_details.html.haml
+++ b/app/views/home/_conference_details.html.haml
@@ -9,7 +9,7 @@
= conference.title
%small
%b
- = conference_date_string(conference)
+ = conference_date_string(conference.start_date, conference.end_date)
- if conference.venue.name and conference.venue.website and conference.venue.address
%p
%small
diff --git a/db/migrate/20140522162159_add_registration_description_to_conference.rb b/db/migrate/20140522162159_add_registration_description_to_conference.rb
new file mode 100644
index 00000000..b893de72
--- /dev/null
+++ b/db/migrate/20140522162159_add_registration_description_to_conference.rb
@@ -0,0 +1,5 @@
+class AddRegistrationDescriptionToConference < ActiveRecord::Migration
+ def change
+ add_column :conferences, :registration_description, :text
+ end
+end
diff --git a/db/migrate/20140523070701_add_ticket_description_to_conference.rb b/db/migrate/20140523070701_add_ticket_description_to_conference.rb
new file mode 100644
index 00000000..ccb610d9
--- /dev/null
+++ b/db/migrate/20140523070701_add_ticket_description_to_conference.rb
@@ -0,0 +1,5 @@
+class AddTicketDescriptionToConference < ActiveRecord::Migration
+ def change
+ add_column :conferences, :ticket_description, :text
+ end
+end
diff --git a/db/migrate/20140523092754_add_description_to_supporter_level.rb b/db/migrate/20140523092754_add_description_to_supporter_level.rb
new file mode 100644
index 00000000..4473c851
--- /dev/null
+++ b/db/migrate/20140523092754_add_description_to_supporter_level.rb
@@ -0,0 +1,5 @@
+class AddDescriptionToSupporterLevel < ActiveRecord::Migration
+ def change
+ add_column :supporter_levels, :description, :text
+ end
+end
diff --git a/db/migrate/20140523115738_add_price_to_supporter_level.rb b/db/migrate/20140523115738_add_price_to_supporter_level.rb
new file mode 100644
index 00000000..97742421
--- /dev/null
+++ b/db/migrate/20140523115738_add_price_to_supporter_level.rb
@@ -0,0 +1,5 @@
+class AddPriceToSupporterLevel < ActiveRecord::Migration
+ def change
+ add_money :supporter_levels, :price
+ end
+end
diff --git a/db/migrate/20140523145705_add_amount_to_supporter_level.rb b/db/migrate/20140523145705_add_amount_to_supporter_level.rb
new file mode 100644
index 00000000..26132dca
--- /dev/null
+++ b/db/migrate/20140523145705_add_amount_to_supporter_level.rb
@@ -0,0 +1,5 @@
+class AddAmountToSupporterLevel < ActiveRecord::Migration
+ def change
+ add_column :supporter_levels, :amount, :float
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 3ea44dfc..4ed94a73 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20140514140013) do
+ActiveRecord::Schema.define(version: 20140523145705) do
create_table "answers", force: true do |t|
t.string "title"
@@ -51,15 +51,15 @@ ActiveRecord::Schema.define(version: 20140514140013) do
add_index "comments", ["user_id"], name: "index_comments_on_user_id"
create_table "conferences", force: true do |t|
- t.string "guid", null: false
- t.string "title", null: false
- t.string "short_title", null: false
+ t.string "guid", null: false
+ t.string "title", null: false
+ t.string "short_title", null: false
t.string "social_tag"
- t.string "contact_email", null: false
- t.string "timezone", null: false
+ t.string "contact_email", null: false
+ t.string "timezone", null: false
t.string "html_export_path"
- t.date "start_date", null: false
- t.date "end_date", null: false
+ t.date "start_date", null: false
+ t.date "end_date", null: false
t.integer "venue_id"
t.datetime "created_at"
t.datetime "updated_at"
@@ -69,15 +69,18 @@ ActiveRecord::Schema.define(version: 20140514140013) do
t.string "logo_content_type"
t.integer "logo_file_size"
t.datetime "logo_updated_at"
- t.boolean "use_dietary_choices", default: false
- t.boolean "use_supporter_levels", default: false
+ t.boolean "use_dietary_choices", default: false
+ t.boolean "use_supporter_levels", default: false
t.integer "revision"
- t.boolean "use_vpositions", default: false
- t.boolean "use_vdays", default: false
- t.boolean "use_difficulty_levels", default: false
+ t.boolean "use_vpositions", default: false
+ t.boolean "use_vdays", default: false
+ t.boolean "use_difficulty_levels", default: false
t.boolean "use_volunteers"
t.string "media_id"
t.string "media_type"
+ t.string "description"
+ t.text "registration_description"
+ t.text "ticket_description"
end
create_table "conferences_questions", id: false, force: true do |t|
@@ -184,12 +187,12 @@ ActiveRecord::Schema.define(version: 20140514140013) do
end
create_table "people", force: true do |t|
- t.string "guid", null: false
+ t.string "guid", null: false
t.string "first_name", default: ""
t.string "last_name", default: ""
t.string "public_name", default: ""
t.string "company", default: ""
- t.string "email", null: false
+ t.string "email", null: false
t.boolean "email_public"
t.string "avatar_file_name"
t.string "avatar_content_type"
@@ -204,6 +207,7 @@ ActiveRecord::Schema.define(version: 20140514140013) do
t.string "tshirt"
t.string "mobile"
t.string "languages"
+ t.boolean "featured", default: false
end
create_table "qanswers", force: true do |t|
@@ -287,8 +291,14 @@ ActiveRecord::Schema.define(version: 20140514140013) do
create_table "supporter_levels", force: true do |t|
t.integer "conference_id"
- t.string "title", null: false
+ t.string "title", null: false
t.string "url"
+ t.text "ticket_description"
+ t.float "price"
+ t.text "description"
+ t.integer "price_cents", default: 0, null: false
+ t.string "price_currency", default: "USD", null: false
+ t.float "amount"
end
create_table "supporter_registrations", force: true do |t|
diff --git a/spec/factories/supporter_levels.rb b/spec/factories/supporter_levels.rb
index 9edc89de..40d14f58 100644
--- a/spec/factories/supporter_levels.rb
+++ b/spec/factories/supporter_levels.rb
@@ -2,6 +2,8 @@ FactoryGirl.define do
factory :supporter_level do
title 'Example Supporter Level'
url 'www.example.com'
+ amount '2200'
+ price_currency 'USD'
conference
end
diff --git a/spec/features/supporter_levels_spec.rb b/spec/features/supporter_levels_spec.rb
index ee55a385..28a1f1f2 100644
--- a/spec/features/supporter_levels_spec.rb
+++ b/spec/features/supporter_levels_spec.rb
@@ -24,7 +24,15 @@ feature SupporterLevel do
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input').
set('http://www.google.de')
-
+ page.
+ find('div.nested-fields:nth-of-type(1) div:nth-of-type(3) select').
+ set('USD')
+ page.
+ find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input').
+ set('223.0')
+ page.
+ find('div.nested-fields:nth-of-type(1) div:nth-of-type(5) textarea').
+ set('Lorem Ipsum')
click_button 'Update Conference'
# Validations
@@ -33,6 +41,12 @@ feature SupporterLevel do
value).to eq('Example supporter level')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input').
value).to eq('http://www.google.de')
+ expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(3) select').
+ value).to eq('USD')
+ expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input').
+ value).to eq('223.0')
+ expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(5) textarea').
+ value).to eq('Lorem Ipsum')
# Remove supporter level
click_link 'Remove supporter_level'
diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb
index b822a73e..4cb4e287 100644
--- a/spec/views/conference/show.html.haml_spec.rb
+++ b/spec/views/conference/show.html.haml_spec.rb
@@ -2,9 +2,16 @@ require 'spec_helper'
describe 'conference/show.html.haml' do
it 'renders conference details' do
@conference = create(:conference)
+ @conference.registration_description = 'Lorem Ipsum'
+ @conference.registration_start_date = Date.today
+ @conference.registration_end_date = Date.today + 7.days
+ @conference.use_supporter_levels = true
+ @conference.save!
+ @conference.supporter_levels = [create(:supporter_level)]
assign :conference, @conference
render
- expect(render).to include("#{@conference.title}")
+ expect(render).to include("#{ @conference.registration_description }")
+ expect(render).to include('Example Supporter Level')
end
end