Module: MnoEnterprise::Concerns::Models::Organization
- Extended by:
- ActiveSupport::Concern
- Included in:
- Organization
- Defined in:
- lib/mno_enterprise/concerns/models/organization.rb
Overview
Schema Information
Endpoint:
- /v1/organizations
- /v1/users/:user_id/organizations
id :integer not null, primary key
uid :string(255)
name :string(255)
created_at :datetime not null
updated_at :datetime not null
account_frozen :boolean default(FALSE)
free_trial_end_at :datetime
soa_enabled :boolean default(TRUE)
mails :text
logo :string(255)
latitude :float default(0.0)
longitude :float default(0.0)
geo_country_code :string(255)
geo_state_code :string(255)
geo_city :string(255)
geo_tz :string(255)
geo_currency :string(255)
meta_data :text
industry :string(255)
size :string(255)
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#add_user(user, role = 'Member') ⇒ Object
Add a user to the organization with the provided role TODO: specs.
- #has_credit_card_details? ⇒ Boolean
- #last_invoice ⇒ Object
-
#members(show_staged = false) ⇒ Object
Instance methods ================================================================== Return the list of users + active invites TODO: specs.
- #payment_restriction ⇒ Object
-
#remove_user(user) ⇒ Object
Remove a user from the organization TODO: specs.
- #to_audit_event ⇒ Object
-
#update_user(user, role = 'Member') ⇒ Object
Change a user role in the organization TODO: specs.
Instance Method Details
#add_user(user, role = 'Member') ⇒ Object
Add a user to the organization with the provided role TODO: specs
90 91 92 |
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 90 def add_user(user,role = 'Member') self.users.create(id: user.id, role: role) end |
#has_credit_card_details? ⇒ Boolean
127 128 129 |
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 127 def has_credit_card_details? credit_card.persisted? end |
#last_invoice ⇒ Object
94 95 96 97 |
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 94 def last_invoice inv = self.raw_last_invoice inv.id ? inv : nil end |
#members(show_staged = false) ⇒ Object
Instance methods
Return the list of users + active invites TODO: specs
83 84 85 86 |
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 83 def members(show_staged=false) invites = show_staged ? self.org_invites.active_or_staged : self.org_invites.active [self.users, invites.to_a].flatten end |
#payment_restriction ⇒ Object
123 124 125 |
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 123 def payment_restriction && ['payment_restriction'] end |
#remove_user(user) ⇒ Object
Remove a user from the organization TODO: specs
105 106 107 |
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 105 def remove_user(user) self.users.destroy(id: user.id) end |
#to_audit_event ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 115 def to_audit_event { id: id, uid: uid, name: name } end |
#update_user(user, role = 'Member') ⇒ Object
Change a user role in the organization TODO: specs
111 112 113 |
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 111 def update_user(user, role = 'Member') self.users.update(id: user.id, role: role) end |