Skip to Content Skip to Search
Methods
A
F
L
M
N
O
P
R
S

Constants

Link = Data.define(:enabled, :to, :on_click) do alias_method :enabled?, :enabled end
 

Attributes

[RW] active_plan
[RW] feature
[RW] site
[RW] site_owner

Class Public methods

new(site_owner:, feature: nil, site: nil, for_transfer: false)

# File app/models/plan_upgrade.rb, line 12
def initialize(site_owner:, feature: nil, site: nil, for_transfer: false)
  @site_owner = site_owner
  @feature = feature&.to_sym
  @site = site
  @for_transfer = for_transfer
  @active_plan = get_active_plan
end

Instance Public methods

action()

# File app/models/plan_upgrade.rb, line 65
def action
  if site_owner?
    owner_action
  elsif site_admin?
    admin_action
  end
end

for_transfer?()

# File app/models/plan_upgrade.rb, line 81
def for_transfer?
  @for_transfer && site.present?
end

message()

# File app/models/plan_upgrade.rb, line 39
def message
  if bypassing_as_agency?
    agency_message
  elsif required? && site_owner?
    owner_message
  elsif required? && site_admin?
    admin_message
  elsif required? && for_transfer?
    pending_owner_message
  end
end

message?()

# File app/models/plan_upgrade.rb, line 51
def message?
  message.present?
end

name()

# File app/models/plan_upgrade.rb, line 20
def name
  recommended&.name || "NO RECOMMENDED PLAN FOUND"
end

outcome()

# File app/models/plan_upgrade.rb, line 73
def outcome
  if site_owner?
    owner_outcome
  elsif site_admin?
    admin_outcome
  end
end

required?()

# File app/models/plan_upgrade.rb, line 32
def required?
  !memberspace_site? &&
    !owner_is_super_admin? &&
    !bypassing_as_agency? &&
    !covered_by_active_plan?
end

Instance Private methods

pending_owner_message()

In the very short-term, we’re keeping this message generic, because the design for Agency/Upgrade/Downgrade code has gotten too complex.

# File app/models/plan_upgrade.rb, line 223
def pending_owner_message
  #:doc:
  "You need to upgrade your plan first. Please review the email that you received about connecting this site."
end

site_owner?()

site_owner may actually be a SiteAdmin

When site is present, treats site_owner as the site.owner, or as one of the site’s administrators

When site is nil, treats site_owner as a SiteOwner

# File app/models/plan_upgrade.rb, line 126
def site_owner?
  #:doc:
  if site.present?
    !site.agency_mode? && site_owner == site.owner
  else
    true
  end
end