Class: Decidim::Api::ApiUser
- Inherits:
-
UserBaseEntity
- Object
- ActiveRecord::Base
- Decidim::ApplicationRecord
- UserBaseEntity
- Decidim::Api::ApiUser
- Includes:
- Traceable
- Defined in:
- decidim-api/app/models/decidim/api/api_user.rb
Constant Summary
Constants inherited from UserBaseEntity
UserBaseEntity::REGEXP_NAME, UserBaseEntity::REGEXP_NICKNAME
Class Method Summary collapse
Instance Method Summary collapse
-
#accepts_conversation?(_user) ⇒ Boolean
Public: whether the user accepts direct messages from another.
-
#active_role ⇒ Object
Public: Returns the active role of the user.
- #admin_terms_accepted? ⇒ Boolean
- #confirmed? ⇒ Boolean
-
#deleted? ⇒ Boolean
Check if the user account has been deleted or not.
- #follows?(followable) ⇒ Boolean
-
#name ⇒ Object
Public: returns the user’s name or the default one.
- #needs_password_update? ⇒ Boolean
-
#officialized? ⇒ Boolean
Public: whether the user has been officialized or not.
- #presenter ⇒ Object
-
#role?(role) ⇒ Boolean
Checks if the user has the given
roleor not. - #tos_accepted? ⇒ Boolean
- #unread_conversations ⇒ Object
Methods inherited from UserBaseEntity
#followings_blocked?, #public_followings, #public_users_followings, ransackable_associations, ransackable_attributes, #users_followings
Methods included from HasUploadValidations
#attached_uploader, #maximum_avatar_size, #maximum_upload_size
Methods included from Followable
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
18 19 20 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 18 def self.log_presenter_class_for(_log) Decidim::AdminLog::UserPresenter end |
Instance Method Details
#accepts_conversation?(_user) ⇒ Boolean
Public: whether the user accepts direct messages from another
61 62 63 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 61 def accepts_conversation?(_user) false end |
#active_role ⇒ Object
Public: Returns the active role of the user
33 34 35 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 33 def active_role admin ? "admin" : roles.first end |
#admin_terms_accepted? ⇒ Boolean
73 74 75 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 73 def admin_terms_accepted? true end |
#confirmed? ⇒ Boolean
52 53 54 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 52 def confirmed? true end |
#deleted? ⇒ Boolean
Check if the user account has been deleted or not
43 44 45 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 43 def deleted? deleted_at.present? end |
#follows?(followable) ⇒ Boolean
56 57 58 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 56 def follows?(followable) Decidim::Follow.where(user: self, followable: followable).any? end |
#name ⇒ Object
Public: returns the user’s name or the default one
38 39 40 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 38 def name super || I18n.t("decidim.anonymous_user") end |
#needs_password_update? ⇒ Boolean
77 78 79 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 77 def needs_password_update? false end |
#officialized? ⇒ Boolean
Public: whether the user has been officialized or not
48 49 50 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 48 def officialized? !officialized_at.nil? end |
#presenter ⇒ Object
14 15 16 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 14 def presenter Decidim::Api::ApiUserPresenter.new(self) end |
#role?(role) ⇒ Boolean
Checks if the user has the given role or not.
role - a String or a Symbol that represents the role that is being
checked
Returns a boolean.
28 29 30 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 28 def role?(role) roles.include?(role.to_s) end |
#tos_accepted? ⇒ Boolean
69 70 71 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 69 def tos_accepted? true end |
#unread_conversations ⇒ Object
65 66 67 |
# File 'decidim-api/app/models/decidim/api/api_user.rb', line 65 def unread_conversations Decidim::Messaging::Conversation.unread_by(self) end |