Class: Decidim::UserGroup
Overview
A UserGroup is an organization of citizens
Constant Summary
Decidim::UserBaseEntity::REGEXP_NAME
Class Method Summary
collapse
Instance Method Summary
collapse
#following
#maximum_avatar_size, #maximum_upload_size
Methods included from Followable
#followers
Class Method Details
.export_serializer ⇒ Object
.log_presenter_class_for(_log) ⇒ Object
.user_collection(user) ⇒ Object
64
65
66
|
# File 'app/models/decidim/user_group.rb', line 64
def self.user_collection(user)
user.user_groups
end
|
.with_document_number(organization, number) ⇒ Object
34
35
36
37
|
# File 'app/models/decidim/user_group.rb', line 34
def self.with_document_number(organization, number)
where(decidim_organization_id: organization.id)
.where("extended_data->>'document_number' = ?", number)
end
|
Instance Method Details
#accepted_memberships ⇒ Object
sugar for the memberships query
#accepted_users ⇒ Object
easy way to return all the users accepted in this group
106
107
108
|
# File 'app/models/decidim/user_group.rb', line 106
def accepted_users
accepted_memberships.map(&:user)
end
|
#accepts_conversation?(_user) ⇒ Boolean
Currently, groups always accept conversations from anyone. This may change in the future in case the desired behaviour is to check if all (or any) of the administrators accepts conversations or there’s simply and option for this in the group preferences.
114
115
116
|
# File 'app/models/decidim/user_group.rb', line 114
def accepts_conversation?(_user)
true
end
|
#document_number ⇒ Object
72
73
74
|
# File 'app/models/decidim/user_group.rb', line 72
def document_number
extended_data["document_number"]
end
|
#pending? ⇒ Boolean
Public: Checks if the user group is pending.
60
61
62
|
# File 'app/models/decidim/user_group.rb', line 60
def pending?
verified_at.blank? && rejected_at.blank?
end
|
#phone ⇒ Object
76
77
78
|
# File 'app/models/decidim/user_group.rb', line 76
def phone
extended_data["phone"]
end
|
#presenter ⇒ Object
Returns the presenter for this author, to be used in the views. Required by ActsAsAuthor.
#reject! ⇒ Object
88
89
90
91
92
|
# File 'app/models/decidim/user_group.rb', line 88
def reject!
extended_data["verified_at"] = nil
extended_data["rejected_at"] = Time.current
save!
end
|
#rejected? ⇒ Boolean
Public: Checks if the user group is rejected.
55
56
57
|
# File 'app/models/decidim/user_group.rb', line 55
def rejected?
rejected_at.present?
end
|
#rejected_at ⇒ Object
80
81
82
|
# File 'app/models/decidim/user_group.rb', line 80
def rejected_at
extended_data["rejected_at"]
end
|
#unread_messages_count_for(user) ⇒ Object
118
119
120
121
|
# File 'app/models/decidim/user_group.rb', line 118
def unread_messages_count_for(user)
@unread_messages_count_for ||= {}
@unread_messages_count_for[user.id] ||= Decidim::Messaging::Conversation.user_collection(self).unread_messages_by(user).count
end
|
#verified? ⇒ Boolean
Public: Checks if the user group is verified.
50
51
52
|
# File 'app/models/decidim/user_group.rb', line 50
def verified?
verified_at.present?
end
|
#verified_at ⇒ Object
84
85
86
|
# File 'app/models/decidim/user_group.rb', line 84
def verified_at
extended_data["verified_at"]
end
|
#verify! ⇒ Object
94
95
96
97
98
|
# File 'app/models/decidim/user_group.rb', line 94
def verify!
extended_data["verified_at"] = Time.current
extended_data["rejected_at"] = nil
save!
end
|