Move Conference contact details to Contact

This commit is contained in:
Henne Vogelsang 2014-07-31 20:09:38 +02:00
parent eb3e6898d2
commit 5aa0d58c57
18 changed files with 67 additions and 58 deletions

View file

@ -26,6 +26,7 @@ class Admin::ContactsController < ApplicationController
end
private
# Use callbacks to share common setup or constraints between actions.
def set_contact
@contact = @conference.contact

View file

@ -37,7 +37,7 @@ class ConferenceRegistrationController < ApplicationController
if regs.where(email: user.email).count == 0
redirect_to(register_conference_path(id: conference.short_title),
alert: "This code is already in use.
Please contact #{conference.contact_email} for assistance.")
Please contact #{conference.contact.email} for assistance.")
return
end
end

View file

@ -83,8 +83,8 @@ class Mailbot < ActionMailer::Base
def build_email(conference, to, subject, body)
mail(to: to,
from: conference.contact_email,
reply_to: conference.contact_email,
from: conference.contact.email,
reply_to: conference.contact.email,
subject: subject,
body: body)
end

View file

@ -5,7 +5,7 @@ class Conference < ActiveRecord::Base
require 'uri'
serialize :events_per_week, Hash
attr_accessible :title, :short_title, :social_tag, :contact_email, :timezone, :html_export_path,
attr_accessible :title, :short_title, :timezone, :html_export_path,
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
:dietary_choices_attributes, :use_dietary_choices, :use_supporter_levels,
:supporter_levels_attributes, :social_events_attributes, :event_types_attributes,
@ -14,14 +14,14 @@ class Conference < ActiveRecord::Base
:use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes,
:vpositions_attributes, :use_volunteers, :media_id, :media_type, :color,
:description, :registration_description, :ticket_description,
:sponsorship_levels_attributes, :sponsors_attributes, :facebook_url, :google_url,
:twitter_url, :sponsor_description, :sponsor_email, :lodging_description,
:sponsorship_levels_attributes, :sponsors_attributes,
:sponsor_description, :sponsor_email, :lodging_description,
:include_registrations_in_splash, :include_sponsors_in_splash,
:include_tracks_in_splash, :include_tickets_in_splash,
:include_social_media_in_splash, :include_program_in_splash,
:include_program_in_splash,
:make_conference_public, :photos_attributes, :banner_photo,
:include_banner_in_splash, :targets, :targets_attributes, :campaigns,
:campaigns_attributes, :instagram_url
:campaigns_attributes
has_paper_trail
@ -83,13 +83,9 @@ class Conference < ActiveRecord::Base
size: { in: 0..500.kilobytes }
validates_presence_of :title,
:short_title,
:social_tag,
:start_date,
:end_date
validates :facebook_url, :twitter_url, :google_url,
format: URI::regexp(%w(http https)), allow_blank: true
validates_uniqueness_of :short_title
validates_format_of :short_title, with: /\A[a-zA-Z0-9_-]*\z/
before_create :generate_guid

View file

@ -1,8 +1,11 @@
class Contact < ActiveRecord::Base
attr_accessible :conference, :social_tag, :email, :facebook, :googleplus, :twitter, :instagram, :public
attr_accessible :conference_id, :social_tag, :email, :facebook, :googleplus, :twitter, :instagram, :public
belongs_to :conference
validates :conference, presence: true
# Conferences only have one contact
validates :conference_id, :uniqueness => {:message => "has already contact details"}
validates :conference_id, uniqueness: {message: "has already contact details"}
validates :facebook, :twitter, :googleplus, :instagram,
format: URI::regexp(%w(http https)), allow_blank: true
end

View file

@ -10,7 +10,7 @@ class ConferenceSerializer < ActiveModel::Serializer
end
def socialtag
object.social_tag
object.contact.social_tag
end
def revision

View file

@ -6,8 +6,6 @@
= f.input :include_program_in_splash, hint: 'On setting this true you will enable the program component to be displayed on the splash page.This component includes tracks, keynote speakers and the schedule'
= 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.input :color, :hint => "The color will be used eg for the dashboard.", :input_html => {:size => 6, :type => "color"}
= f.inputs name: 'Banner for Splash' do
= f.input :include_banner_in_splash, hint: 'This enable the Banner Photo with description to be displayed on the splash'
@ -33,7 +31,6 @@
= f.inputs :name => 'Social Media' do
- if !@conference.logo.blank?
= image_tag @conference.logo(:thumb)
= f.input :include_social_media_in_splash, hint: 'On setting this true you will enable the social media links to be displayed on the splash page'
= 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
@ -43,8 +40,4 @@
%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.input :facebook_url, hint: 'This will appear in the social media section as link to the Facebook page of your Conference'
= f.input :google_url, label: 'Google+ Url', hint: 'This will appear in the social media section as the link to the Google+ Page of your Conference'
= f.input :twitter_url, hint: 'This will appear in the social media section as the link to the Twitter Page of your Conference'
= f.input :instagram_url, hint: 'This will appear in the social media section as the link to the Instagram Page of your Conference'
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}

View file

@ -6,9 +6,6 @@
input_html: { required: 'required' }
= f.input :short_title, hint: "A short and unique handle for your conference, using only lower-case letters, numbers and underscores. This will be used to identify your conference in URLs etc. Example: 'froscon2011'",
input_html: { required: 'required' }
= f.input :social_tag, hint: "The hashtag you'll use on Twitter and Google+. Don't include the '#' sign!'",
input_html: { required: 'required' }
= 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 'Scheduling' do
= f.input :timezone, as: :time_zone, hint: 'Please select in what time zone your conference will take place.'
= f.input :start_date, as: :string, input_html: { id: 'conference-start-datepicker', required: 'required' }

View file

@ -4,19 +4,19 @@
%div.container#social-media.text-center
%div.row
- unless @conference.facebook_url.blank?
- unless @conference.contact.facebook.blank?
%div.col-md-3
= link_to "#{ @conference.facebook_url }" do
= link_to "#{ @conference.contact.facebook }" do
%i.fa.fa-facebook-square.fa-4x
- unless @conference.twitter_url.blank?
- unless @conference.contact.twitter.blank?
%div.col-md-3
= link_to "#{ @conference.twitter_url }" do
= link_to "#{ @conference.contact.twitter }" do
%i.fa.fa-twitter.fa-4x
- unless @conference.instagram_url.blank?
- unless @conference.contact.instagram.blank?
%div.col-md-3
= link_to "#{ @conference.instagram_url }" do
= link_to "#{ @conference.contact.instagram }" do
%i.fa.fa-instagram.fa-4x
- unless @conference.google_url.blank?
- unless @conference.contact.googleplus.blank?
%div.col-md-3
= link_to "#{ @conference.google_url }" do
= link_to "#{ @conference.contact.googleplus }" do
%i.fa.fa-google-plus-square.fa-4x

View file

@ -52,7 +52,7 @@
.pad
= render 'sponsor'
- if @conference.include_social_media_in_splash?
- if @conference.contact.public?
%section{ id: 'social-media' }
.pad
= render 'social_media'

View file

@ -1,6 +1,5 @@
Osem::Application.routes.draw do
devise_for :users, controllers: { registrations: :registrations,
omniauth_callbacks: 'users/omniauth_callbacks' },
path: 'accounts'

View file

@ -0,0 +1,34 @@
class MoveConferenceContactDetailsToContact < ActiveRecord::Migration
class TempConference < ActiveRecord::Base
self.table_name = 'conferences'
end
class TempContact < ActiveRecord::Base
self.table_name = 'contacts'
attr_accessible :conference_id, :social_tag, :email, :facebook, :googleplus, :twitter, :instagram, :public
end
def change
# Move all the settings to the new object
TempConference.all.each do |conference|
unless TempContact.exists?(conference_id: conference.id)
TempContact.create(social_tag: conference.social_tag,
email: conference.contact_email,
facebook: conference.facebook_url,
googleplus: conference.google_url,
twitter: conference.twitter_url,
instagram: conference.instagram_url,
public: conference.include_social_media_in_splash,
conference_id: conference.id)
end
end
# Then remove all the columns
remove_column :conferences, :social_tag
remove_column :conferences, :contact_email
remove_column :conferences, :facebook_url
remove_column :conferences, :google_url
remove_column :conferences, :twitter_url
remove_column :conferences, :instagram_url
remove_column :conferences, :include_social_media_in_splash
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: 20140731153332) do
ActiveRecord::Schema.define(version: 20140731165107) do
create_table "ahoy_events", force: true do |t|
t.uuid "visit_id"
@ -78,8 +78,6 @@ ActiveRecord::Schema.define(version: 20140731153332) do
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 "html_export_path"
t.date "start_date", null: false
@ -108,23 +106,18 @@ ActiveRecord::Schema.define(version: 20140731153332) do
t.text "ticket_description"
t.text "sponsor_description"
t.string "sponsor_email"
t.string "twitter_url"
t.string "facebook_url"
t.string "google_url"
t.text "lodging_description"
t.boolean "make_conference_public", default: false
t.boolean "include_registrations_in_splash", default: false
t.boolean "include_sponsors_in_splash", default: false
t.boolean "include_tracks_in_splash", default: false
t.boolean "include_tickets_in_splash", default: false
t.boolean "include_social_media_in_splash", default: false
t.boolean "include_program_in_splash", default: false
t.string "banner_photo_file_name"
t.string "banner_photo_content_type"
t.integer "banner_photo_file_size"
t.datetime "banner_photo_updated_at"
t.boolean "include_banner_in_splash", default: false
t.string "instagram_url"
t.text "events_per_week"
end

View file

@ -4,9 +4,7 @@ FactoryGirl.define do
factory :conference do
title 'The dog and pony show'
sequence(:short_title) { |n| "dps#{n}14" }
social_tag 'dps14'
timezone 'Amsterdam'
contact_email 'admin@example.com'
start_date { Date.today }
end_date { 6.days.from_now }
registration_start_date { 3.days.from_now }

View file

@ -15,7 +15,6 @@ feature Conference do
visit new_admin_conference_path
fill_in 'conference_title', with: 'Example Con'
fill_in 'conference_short_title', with: 'ExCon'
fill_in 'conference_social_tag', with: 'ExCon'
select('(GMT+01:00) Berlin', from: 'conference[timezone]')
@ -42,7 +41,6 @@ feature Conference do
visit edit_admin_conference_path(conference.short_title)
fill_in 'conference_title', with: 'New Con'
fill_in 'conference_short_title', with: 'NewCon'
fill_in 'conference_social_tag', with: 'NewCon'
click_button 'Update Conference'
expect(flash).
@ -51,7 +49,6 @@ feature Conference do
conference.reload
expect(conference.title).to eq('New Con')
expect(conference.short_title).to eq('NewCon')
expect(conference.social_tag).to eq('NewCon')
expect(Conference.count).to eq(expected_count)
end
end

View file

@ -1457,10 +1457,6 @@ describe Conference do
should validate_presence_of(:short_title)
end
it 'is not valid without a social tag' do
should validate_presence_of(:social_tag)
end
it 'is not valid without a start date' do
should validate_presence_of(:start_date)
end

View file

@ -7,6 +7,5 @@ describe 'admin/conference/edit' do
assign :conference, @conference
render template: 'admin/conference/edit.html.haml'
expect(rendered).to include('OpenSUSE')
expect(rendered).to include("#{@conference.contact_email}")
end
end

View file

@ -8,17 +8,20 @@ describe 'conference/show.html.haml' do
description: 'Lorem Ipsum',
sponsor_description: 'Lorem Ipsum Dolor',
sponsor_email: 'example@example.com',
facebook_url: 'http://www.fbexample.com',
google_url: 'http://www.google-example.com',
instagram_url: "http://instagram.com",
twitter_url: "http://twitter.com",
include_registrations_in_splash: true,
include_program_in_splash: true,
include_sponsors_in_splash: true,
include_social_media_in_splash: true,
include_tracks_in_splash: true,
include_tickets_in_splash: true,
include_banner_in_splash: true)
@conference.contact.update(facebook: 'http://www.fbexample.com',
googleplus: 'http://www.google-example.com',
instagram: 'http://instagram.com',
twitter: 'http://twitter.com',
public: true
)
@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)