diff --git a/app/models/conference.rb b/app/models/conference.rb index f53a1c1c..db77eaae 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -15,7 +15,7 @@ class Conference < ActiveRecord::Base :use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers, :color, :sponsorship_levels_attributes, :sponsors_attributes, - :sponsor_email, :photos_attributes, :targets, :targets_attributes, + :photos_attributes, :targets, :targets_attributes, :campaigns, :campaigns_attributes has_paper_trail diff --git a/app/models/contact.rb b/app/models/contact.rb index 6efa8db0..829088b7 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -1,5 +1,7 @@ class Contact < ActiveRecord::Base - attr_accessible :conference_id, :social_tag, :email, :facebook, :googleplus, :twitter, :instagram, :public + attr_accessible :conference_id, :social_tag, :email, :facebook, :googleplus, :twitter, + :instagram, :public, :sponsor_email + belongs_to :conference validates :conference, presence: true diff --git a/app/views/admin/conference/_edit_form.html.haml b/app/views/admin/conference/_edit_form.html.haml index e69695d0..c4708b00 100644 --- a/app/views/admin/conference/_edit_form.html.haml +++ b/app/views/admin/conference/_edit_form.html.haml @@ -11,5 +11,4 @@ = 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 :sponsor_email, hint: 'This will appear in the sponsor segment of the splash for the sponsors to contact to the organizers' = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/contacts/_form.html.haml b/app/views/admin/contacts/_form.html.haml index 6d077891..320f9f90 100644 --- a/app/views/admin/contacts/_form.html.haml +++ b/app/views/admin/contacts/_form.html.haml @@ -3,6 +3,7 @@ = semantic_form_for(@contact, :url => admin_conference_contact_path(@conference.short_title),:html => {:multipart => true}) do |f| = f.inputs :name => 'Contact' do = f.input :email, hint: 'Contact email address for your conference. Will be used as reply-to address in emails sent out by the system.' + = f.input :sponsor_email, hint: 'This will appear in the sponsor segment of the splash for the sponsors to contact to the organizers' = f.inputs :name => 'Social Media' do = f.input :social_tag, hint: "The hashtag you'll use on Twitter and Google+. Don't include the '#' sign!'" = f.input :facebook, hint: 'This will appear in the social media section as link to the Facebook page of your Conference' diff --git a/app/views/admin/contacts/_show.html.haml b/app/views/admin/contacts/_show.html.haml index 71b4929f..025c2046 100644 --- a/app/views/admin/contacts/_show.html.haml +++ b/app/views/admin/contacts/_show.html.haml @@ -4,6 +4,11 @@ = link_to "#{ @contact.email }" do %i.fa.fa-envelope.fa-3x = @contact.email + - unless @contact.sponsor_email.blank? + %li + = link_to "#{ @contact.sponsor_email }" do + %i.fa.fa-money.fa-3x + = @contact.sponsor_email - unless @contact.social_tag.blank? %li = link_to "#{ @contact.social_tag }" do diff --git a/app/views/conference/_sponsor.html.haml b/app/views/conference/_sponsor.html.haml index 6ee72f44..a0d6187a 100644 --- a/app/views/conference/_sponsor.html.haml +++ b/app/views/conference/_sponsor.html.haml @@ -8,8 +8,8 @@ -if !@conference.splashpage.sponsor_description.blank? .lead = markdown(@conference.splashpage.sponsor_description) - -if !@conference.sponsor_email.blank? - %h3= mail_to "#{ @conference.sponsor_email }", 'Become a Sponsor' + -if @conference.contact && @conference.contact.sponsor_email.present? + %h3= mail_to "#{ @conference.contact.sponsor_email }", 'Become a Sponsor' - if !@conference.sponsorship_levels.blank? - @conference.sponsorship_levels.each do |l| - if !l.sponsors.blank? diff --git a/db/migrate/20140930092923_move_sponsor_email_to_contact.rb b/db/migrate/20140930092923_move_sponsor_email_to_contact.rb new file mode 100644 index 00000000..2fe5f47a --- /dev/null +++ b/db/migrate/20140930092923_move_sponsor_email_to_contact.rb @@ -0,0 +1,26 @@ +class MoveSponsorEmailToContact < ActiveRecord::Migration + class TempConference < ActiveRecord::Base + self.table_name = 'conferences' + end + + class TempContact < ActiveRecord::Base + self.table_name = 'contacts' + end + + def change + add_column :contacts, :sponsor_email, :string + + TempConference.all.each do |conference| + contact = TempContact.find_by(conference_id: conference.id) + if contact + contact.sponsor_email = conference.sponsor_email + contact.save + else + Contact.create(conference_id: conference.id, + sponsors_email: conference.sponsor_email) + end + end + + remove_column :conferences, :sponsor_email + end +end diff --git a/db/schema.rb b/db/schema.rb index 8d861931..be775cc5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -105,7 +105,6 @@ ActiveRecord::Schema.define(version: 20141106141750) do t.boolean "use_difficulty_levels", default: false t.boolean "use_volunteers" t.string "color" - t.string "sponsor_email" t.text "events_per_week" end @@ -124,6 +123,7 @@ ActiveRecord::Schema.define(version: 20141106141750) do t.integer "conference_id" t.datetime "created_at" t.datetime "updated_at" + t.string "sponsor_email" end create_table "delayed_jobs", force: true do |t| diff --git a/spec/features/contact_spec.rb b/spec/features/contact_spec.rb index 1876ae0d..2054e6d9 100644 --- a/spec/features/contact_spec.rb +++ b/spec/features/contact_spec.rb @@ -16,6 +16,7 @@ feature Contact do visit edit_admin_conference_contact_path(conference.short_title) click_link 'Edit' fill_in 'contact_email', with: 'example@example.com' + fill_in 'contact_sponsor_email', with: 'sponsor@example.com' fill_in 'contact_social_tag', with: 'example' fill_in 'contact_facebook', with: 'http:\\www.facebook.com' fill_in 'contact_twitter', with: 'http:\\www.twitter.com' @@ -28,6 +29,7 @@ feature Contact do contact.reload expect(contact.email).to eq('example@example.com') + expect(contact.sponsor_email).to eq('sponsor@example.com') expect(contact.social_tag).to eq('example') expect(contact.facebook).to eq('http:\\www.facebook.com') expect(contact.twitter).to eq('http:\\www.twitter.com') diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index a30b850b..4203834b 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -2,8 +2,7 @@ require 'spec_helper' describe 'conference/show.html.haml' do before(:each) do allow(view).to receive(:date_string).and_return('January 17 - 21 2014') - @conference = create(:conference, - sponsor_email: 'example@example.com') + @conference = create(:conference) @conference.splashpage = create(:splashpage, banner_description: 'Lorem Ipsum', @@ -18,21 +17,25 @@ describe 'conference/show.html.haml' do include_social_media: true, include_venue: true, include_lodgings: true) - @conference.contact.update(facebook: 'http://www.fbexample.com', + + @conference.contact.update(sponsor_email: 'example@example.com', + facebook: 'http://www.fbexample.com', googleplus: 'http://www.google-example.com', instagram: 'http://instagram.com', twitter: 'http://twitter.com') + @conference.registration_period = create(:registration_period, start_date: Date.today, end_date: Date.tomorrow) + @conference.call_for_papers = create(:call_for_papers, conference: @conference, include_cfp_in_splash: true) - @conference.call_for_papers = create(:call_for_papers, conference: @conference, - include_cfp_in_splash: true) + @conference.sponsorship_levels << create(:sponsorship_level, conference: @conference) @sponsorship_level = @conference.sponsorship_levels.first @sponsorship_level.sponsors << create(:sponsor, sponsorship_level: @sponsorship_level, conference: @conference) + @conference.venue = create(:venue) @conference.venue.lodgings << create(:lodging, venue: @conference.venue) assign :conference, @conference