This commit is contained in:
Gopesh Tulsyan 2014-05-26 11:52:07 +00:00
commit ed8d56b21e
19 changed files with 172 additions and 36 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,3 +1,31 @@
.row
.col-md-8
%h1 Dashboard for #{@conference.title}
%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"}

View file

@ -1,7 +1,11 @@
<div class="nested-fields">
<%= 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 %>
</div>

View file

@ -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"}

View file

@ -1,3 +1,32 @@
= content_for :splash_logo do
= link_to @conference.title, "#", :class => 'navbar-brand'
= render :partial => "home/conference_details", :locals => {:conference => @conference}
= 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'

View file

@ -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

View file

@ -0,0 +1,5 @@
class AddRegistrationDescriptionToConference < ActiveRecord::Migration
def change
add_column :conferences, :registration_description, :text
end
end

View file

@ -0,0 +1,5 @@
class AddTicketDescriptionToConference < ActiveRecord::Migration
def change
add_column :conferences, :ticket_description, :text
end
end

View file

@ -0,0 +1,5 @@
class AddDescriptionToSupporterLevel < ActiveRecord::Migration
def change
add_column :supporter_levels, :description, :text
end
end

View file

@ -0,0 +1,5 @@
class AddPriceToSupporterLevel < ActiveRecord::Migration
def change
add_money :supporter_levels, :price
end
end

View file

@ -0,0 +1,5 @@
class AddAmountToSupporterLevel < ActiveRecord::Migration
def change
add_column :supporter_levels, :amount, :float
end
end

View file

@ -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|

View file

@ -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

View file

@ -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'

View file

@ -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