Moves sponsor email attribute from conference to contact

This commit is contained in:
Chrisbr 2014-09-30 11:59:02 +02:00 committed by chrisbr
parent c0cdf3e6e5
commit 9376fe57e3
10 changed files with 49 additions and 11 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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