Another round of splash design
* Add map to splash * Reverse venue<->conference relation * Split venue address into fields * Don't go through venue for lodgings anymore
This commit is contained in:
parent
30e8ab856c
commit
cb227a0afc
55 changed files with 717 additions and 548 deletions
|
|
@ -43,21 +43,15 @@ class Ability
|
|||
|
||||
def user_with_roles(user)
|
||||
conf_ids_for_organizer = []
|
||||
venue_ids_for_organizer = []
|
||||
conf_ids_for_cfp = []
|
||||
venue_ids_for_cfp = []
|
||||
conf_ids_for_info_desk = []
|
||||
conf_ids_for_volunteer_coordinator = []
|
||||
|
||||
# Ids of all the conferences for which the user has an 'organizer' role
|
||||
conf_ids_for_organizer =
|
||||
Conference.with_role(:organizer, user).pluck(:id) if user.has_role? :organizer, :any
|
||||
venue_ids_for_organizer =
|
||||
Conference.with_role(:organizer, user).pluck(:venue_id) if user.has_role? :organizer, :any
|
||||
conf_ids_for_cfp =
|
||||
Conference.with_role(:cfp, user).pluck(:id) if user.has_role? :cfp, :any
|
||||
venue_ids_for_cfp =
|
||||
Conference.with_role(:cfp, user).pluck(:venue_id) if user.has_role? :cfp, :any
|
||||
# Ids of all the conferences for which the user has an 'info_desk' role
|
||||
conf_ids_for_info_desk =
|
||||
Conference.with_role(:info_desk, user).pluck(:id) if user.has_role? :info_desk, :any
|
||||
|
|
@ -74,8 +68,6 @@ class Ability
|
|||
# can :manage, Conference do |conference|
|
||||
# conference.id = conf_ids_for_organizer
|
||||
# end
|
||||
can :manage, Venue, id: venue_ids_for_organizer
|
||||
can :index, Venue, id: venue_ids_for_cfp
|
||||
can :manage, Registration, conference_id: conf_ids_for_organizer + conf_ids_for_info_desk
|
||||
can :manage, Question, conference_id: conf_ids_for_organizer + conf_ids_for_info_desk
|
||||
cannot [:edit, :update, :destroy], Question, global: true
|
||||
|
|
@ -92,7 +84,9 @@ class Ability
|
|||
can :manage, DifficultyLevel, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||
can :manage, EmailSettings, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||
can :manage, Campaign, conference_id: conf_ids_for_organizer
|
||||
can :manage, Lodging, venue_id: venue_ids_for_organizer
|
||||
can :manage, Venue, conference_id: conf_ids_for_organizer
|
||||
can :index, Venue, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||
can :manage, Lodging, conference_id: conf_ids_for_organizer
|
||||
can :manage, Photo, conference_id: conf_ids_for_organizer
|
||||
can :manage, Room, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||
can :manage, Sponsor, conference_id: conf_ids_for_organizer
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class Conference < ActiveRecord::Base
|
|||
has_one :registration_period, dependent: :destroy
|
||||
has_one :email_settings, dependent: :destroy
|
||||
has_one :call_for_papers, dependent: :destroy
|
||||
has_one :venue, dependent: :destroy
|
||||
has_many :social_events, dependent: :destroy
|
||||
has_many :ticket_purchases
|
||||
has_many :supporters, through: :ticket_purchases, source: :user
|
||||
|
|
@ -53,6 +54,7 @@ class Conference < ActiveRecord::Base
|
|||
has_many :tracks, dependent: :destroy
|
||||
has_many :difficulty_levels, dependent: :destroy
|
||||
has_many :rooms, dependent: :destroy
|
||||
has_many :lodgings, dependent: :destroy
|
||||
has_many :registrations, dependent: :destroy
|
||||
has_many :participants, through: :registrations, source: :user
|
||||
has_many :vdays, dependent: :destroy
|
||||
|
|
@ -64,7 +66,6 @@ class Conference < ActiveRecord::Base
|
|||
has_many :campaigns, dependent: :destroy
|
||||
has_many :commercials, as: :commercialable, dependent: :destroy
|
||||
has_many :subscriptions, dependent: :destroy
|
||||
belongs_to :venue
|
||||
|
||||
accepts_nested_attributes_for :rooms, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true
|
||||
accepts_nested_attributes_for :tracks, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true
|
||||
|
|
@ -99,7 +100,6 @@ class Conference < ActiveRecord::Base
|
|||
validates_uniqueness_of :short_title
|
||||
validates_format_of :short_title, with: /\A[a-zA-Z0-9_-]*\z/
|
||||
before_create :generate_guid
|
||||
before_create :create_venue
|
||||
before_create :create_event_types
|
||||
before_create :create_email_settings
|
||||
before_create :add_color
|
||||
|
|
@ -727,14 +727,13 @@ class Conference < ActiveRecord::Base
|
|||
rooms.count > 0
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if venue has a name, address and website.
|
||||
# Checks if the conference has a venue object.
|
||||
#
|
||||
# ====Returns
|
||||
# * +True+ -> If venue has a name, address and website.
|
||||
# * +False+ -> venue has a no name, address or website.
|
||||
# * +True+ -> If conference has a venue object.
|
||||
# * +False+ -> IF conference has no venue object.
|
||||
def venue_set?
|
||||
!!venue && !!venue.name && !!venue.address && !!venue.website
|
||||
!!venue
|
||||
end
|
||||
|
||||
##
|
||||
|
|
@ -885,14 +884,6 @@ class Conference < ActiveRecord::Base
|
|||
result
|
||||
end
|
||||
|
||||
##
|
||||
# Creates a Venue for this Conference. Used as before_create.
|
||||
#
|
||||
def create_venue
|
||||
self.venue_id = Venue.create.id
|
||||
true
|
||||
end
|
||||
|
||||
##
|
||||
# Creates default EventTypes for this Conference. Used as before_create.
|
||||
#
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class Lodging < ActiveRecord::Base
|
||||
attr_accessible :name, :description, :photo, :website_link, :venue_id
|
||||
belongs_to :venue
|
||||
attr_accessible :name, :description, :photo, :website_link, :conference_id
|
||||
belongs_to :conference
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +1,39 @@
|
|||
class Venue < ActiveRecord::Base
|
||||
attr_accessible :name, :description, :website, :address, :photo, :lodgings_attributes,
|
||||
:include_venue_in_splash, :include_lodgings_in_splash
|
||||
has_many :conferences
|
||||
belongs_to :conference
|
||||
has_many :lodgings
|
||||
before_create :generate_guid
|
||||
|
||||
attr_accessible :name, :street, :postalcode, :city, :country, :longitude, :latitude, :description, :website, :photo, :lodgings_attributes, :conference_id
|
||||
validates :name, :street, :city, :country, presence: true
|
||||
|
||||
has_attached_file :photo,
|
||||
styles: { thumb: '100x100>', large: '300x300>' }
|
||||
|
||||
validates_attachment_content_type :photo,
|
||||
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
||||
size: { in: 0..500.kilobytes }
|
||||
|
||||
accepts_nested_attributes_for :lodgings, allow_destroy: true
|
||||
|
||||
after_update :send_mail_notification
|
||||
|
||||
def address
|
||||
"#{conference.venue.street}, #{conference.venue.postalcode} #{conference.venue.city}, #{conference.venue.country}"
|
||||
end
|
||||
|
||||
def country_name
|
||||
name = ISO3166::Country[country]
|
||||
name.name if name
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def send_mail_notification
|
||||
conferences.each do |conference|
|
||||
Mailbot.delay.send_email_on_venue_update(conference) if venue_notify?(conference)
|
||||
end
|
||||
Mailbot.delay.send_email_on_venue_update(conference) if venue_notify?(conference)
|
||||
end
|
||||
|
||||
def venue_notify?(conference)
|
||||
(self.name_changed? || self.address_changed?) &&
|
||||
(!self.name.blank? && !self.address.blank?) &&
|
||||
(self.name_changed? || self.street_changed?) &&
|
||||
(!self.name.blank? && !self.street.blank?) &&
|
||||
(conference.email_settings.send_on_venue_update &&
|
||||
!conference.email_settings.venue_update_subject.blank? &&
|
||||
conference.email_settings.venue_update_template)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue