|
|
|
@ -7,9 +7,6 @@ class User < ApplicationRecord |
|
|
|
# Marked as optional because we validate organisation_id below instead so that |
|
|
|
# Marked as optional because we validate organisation_id below instead so that |
|
|
|
# the error message is linked to the right field on the form |
|
|
|
# the error message is linked to the right field on the form |
|
|
|
belongs_to :organisation, optional: true |
|
|
|
belongs_to :organisation, optional: true |
|
|
|
has_many :owned_lettings_logs, through: :organisation |
|
|
|
|
|
|
|
has_many :managed_lettings_logs, through: :organisation |
|
|
|
|
|
|
|
has_many :owned_sales_logs, through: :organisation |
|
|
|
|
|
|
|
has_many :legacy_users |
|
|
|
has_many :legacy_users |
|
|
|
has_many :bulk_uploads |
|
|
|
has_many :bulk_uploads |
|
|
|
|
|
|
|
|
|
|
|
@ -68,10 +65,22 @@ class User < ApplicationRecord |
|
|
|
if support? |
|
|
|
if support? |
|
|
|
SalesLog.all |
|
|
|
SalesLog.all |
|
|
|
else |
|
|
|
else |
|
|
|
SalesLog.filter_by_organisation(organisation.absorbed_organisations << organisation) |
|
|
|
SalesLog.filter_by_owning_organisation(organisation.absorbed_organisations << organisation) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def owned_lettings_logs |
|
|
|
|
|
|
|
LettingsLog.filter_by_owning_organisation(organisation.absorbed_organisations << organisation) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def managed_lettings_logs |
|
|
|
|
|
|
|
LettingsLog.filter_by_managing_organisation(organisation.absorbed_organisations << organisation) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def owned_sales_logs |
|
|
|
|
|
|
|
SalesLog.filter_by_owning_organisation(organisation.absorbed_organisations << organisation) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def is_key_contact? |
|
|
|
def is_key_contact? |
|
|
|
is_key_contact |
|
|
|
is_key_contact |
|
|
|
end |
|
|
|
end |
|
|
|
|