Class: Spina::Admin::Conferences::Delegate

Inherits:
ApplicationRecord show all
Defined in:
app/models/spina/admin/conferences/delegate.rb

Overview

Delegate records.

Validators

Presence

#first_name, #last_name.

Email address (using EmailAddressValidator)

#email_address.

HTTP(S) URL (using HttpUrlValidator)

#url.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#conferencesActiveRecord::Relation

Returns directly associated conferences.

Returns:

  • (ActiveRecord::Relation)

    directly associated conferences

See Also:



34
35
# File 'app/models/spina/admin/conferences/delegate.rb', line 34

has_and_belongs_to_many :conferences, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
association_foreign_key: :spina_conferences_conference_id

#dietary_requirementsActiveRecord::Relation

Returns directly associated dietary requirements.

Returns:

  • (ActiveRecord::Relation)

    directly associated dietary requirements

See Also:



44
45
# File 'app/models/spina/admin/conferences/delegate.rb', line 44

has_and_belongs_to_many :dietary_requirements, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
association_foreign_key: :spina_conferences_dietary_requirement_id

#email_addressString?

Returns the email address of the delegate.

Returns:

  • (String, nil)

    the email address of the delegate



# File 'app/models/spina/admin/conferences/delegate.rb', line 15


#first_nameString?

Returns the first name of the delegate.

Returns:

  • (String, nil)

    the first name of the delegate



# File 'app/models/spina/admin/conferences/delegate.rb', line 15


#institutionInstitution?

Returns directly associated institution.

Returns:

  • (Institution, nil)

    directly associated institution

See Also:



30
# File 'app/models/spina/admin/conferences/delegate.rb', line 30

belongs_to :institution, inverse_of: :delegates, touch: true

#last_nameString?

Returns the last name of the delegate.

Returns:

  • (String, nil)

    the last name of the delegate



# File 'app/models/spina/admin/conferences/delegate.rb', line 15


#presentationsActiveRecord::Relation

Returns directly associated presentations.

Returns:

  • (ActiveRecord::Relation)

    directly associated presentations

See Also:



39
40
# File 'app/models/spina/admin/conferences/delegate.rb', line 39

has_and_belongs_to_many :presentations, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
association_foreign_key: :spina_conferences_presentation_id

#urlString?

Returns the website belonging to the delegate.

Returns:

  • (String, nil)

    the website belonging to the delegate



# File 'app/models/spina/admin/conferences/delegate.rb', line 15


Class Method Details

.import(file) ⇒ void

This method returns an undefined value.

Imports a conference from CSV.

Parameters:

  • file (String)

    the CSV file to be read

See Also:



55
56
57
# File 'app/models/spina/admin/conferences/delegate.rb', line 55

def self.import(file)
  DelegateImportJob.perform_later Pathname.new(file).read
end

Instance Method Details

#full_nameString

Returns the first name and last name of the delegate.

Returns:

  • (String)

    the first name and last name of the delegate



60
61
62
63
64
# File 'app/models/spina/admin/conferences/delegate.rb', line 60

def full_name
  return if first_name.blank? || last_name.blank?

  Delegate.human_attribute_name :full_name, first_name: first_name, last_name: last_name
end

#full_name_and_institutionString

Returns the full name and institution of the delegate.

Returns:

  • (String)

    the full name and institution of the delegate



67
68
69
70
71
# File 'app/models/spina/admin/conferences/delegate.rb', line 67

def full_name_and_institution
  return if full_name.blank? || institution.blank?

  Delegate.human_attribute_name :name_and_institution, name: full_name, institution: institution.name
end

#reversed_nameString

Returns the last name and first name of the delegate.

Returns:

  • (String)

    the last name and first name of the delegate



74
75
76
77
78
# File 'app/models/spina/admin/conferences/delegate.rb', line 74

def reversed_name
  return if first_name.blank? || last_name.blank?

  Delegate.human_attribute_name :reversed_name, first_name: first_name, last_name: last_name
end

#reversed_name_and_institutionString

Returns the reversed name and institution of the delegate.

Returns:

  • (String)

    the reversed name and institution of the delegate



81
82
83
84
85
# File 'app/models/spina/admin/conferences/delegate.rb', line 81

def reversed_name_and_institution
  return if reversed_name.blank? || institution.blank?

  Delegate.human_attribute_name :name_and_institution, name: reversed_name, institution: institution.name
end

#sortedActiveRecord::Relation

Returns all delegates, ordered by last name and first name.

Returns:

  • (ActiveRecord::Relation)

    all delegates, ordered by last name and first name



25
# File 'app/models/spina/admin/conferences/delegate.rb', line 25

scope :sorted, -> { order :last_name, :first_name }