Class: Decidim::Conference
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Decidim::Conference
- Includes:
- FilterableResource, Followable, HasAttachmentCollections, HasAttachments, HasReference, HasUploadValidations, Loggable, Participable, ParticipatorySpaceResourceable, Publicable, ScopableParticipatorySpace, Searchable, ShareableWithToken, SoftDeletable, Taxonomizable, Traceable, TranslatableResource
- Defined in:
- app/models/decidim/conference.rb
Overview
Interaction between a user and an organization can be done via a Conference. It is a unit of action from the Organization point of view that groups several components (proposals, debates…) that can be enabled or disabled.
Class Method Summary collapse
- .log_presenter_class_for(_log) ⇒ Object
-
.promoted ⇒ Object
Scope to return only the promoted conferences.
- .ransackable_associations(_auth_object = nil) ⇒ Object
- .ransackable_attributes(auth_object = nil) ⇒ Object
Instance Method Summary collapse
- #attachment_context ⇒ Object
- #closed? ⇒ Boolean
- #diploma_sent? ⇒ Boolean
- #has_available_slots? ⇒ Boolean
- #has_published_registration_types? ⇒ Boolean
- #has_registration_for?(user) ⇒ Boolean
- #has_registration_for_user_and_registration_type?(user, registration_type) ⇒ Boolean
- #remaining_slots ⇒ Object
- #shareable_url(share_token) ⇒ Object
- #to_param ⇒ Object
- #user_roles(role_name = nil) ⇒ Object
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
93 94 95 |
# File 'app/models/decidim/conference.rb', line 93 def self.log_presenter_class_for(_log) Decidim::Conferences::AdminLog::ConferencePresenter end |
.promoted ⇒ Object
Scope to return only the promoted conferences.
Returns an ActiveRecord::Relation.
89 90 91 |
# File 'app/models/decidim/conference.rb', line 89 def self.promoted where(promoted: true) end |
.ransackable_associations(_auth_object = nil) ⇒ Object
163 164 165 |
# File 'app/models/decidim/conference.rb', line 163 def self.ransackable_associations(_auth_object = nil) %w(taxonomies) end |
.ransackable_attributes(auth_object = nil) ⇒ Object
155 156 157 158 159 160 161 |
# File 'app/models/decidim/conference.rb', line 155 def self.ransackable_attributes(auth_object = nil) base = %w(title short_description description id) return base unless auth_object&.admin? base + %w(published_at) end |
Instance Method Details
#attachment_context ⇒ Object
144 145 146 |
# File 'app/models/decidim/conference.rb', line 144 def :admin end |
#closed? ⇒ Boolean
131 132 133 134 135 |
# File 'app/models/decidim/conference.rb', line 131 def closed? return false if end_date.blank? end_date < Date.current end |
#diploma_sent? ⇒ Boolean
125 126 127 128 129 |
# File 'app/models/decidim/conference.rb', line 125 def diploma_sent? return false if diploma_sent_at.nil? true end |
#has_available_slots? ⇒ Boolean
109 110 111 112 113 |
# File 'app/models/decidim/conference.rb', line 109 def has_available_slots? return true if available_slots.zero? available_slots > conference_registrations.count end |
#has_published_registration_types? ⇒ Boolean
115 116 117 118 119 |
# File 'app/models/decidim/conference.rb', line 115 def has_published_registration_types? return false if registration_types.empty? registration_types.any?(&:published_at?) end |
#has_registration_for?(user) ⇒ Boolean
101 102 103 |
# File 'app/models/decidim/conference.rb', line 101 def has_registration_for?(user) conference_registrations.where(user:).any? end |
#has_registration_for_user_and_registration_type?(user, registration_type) ⇒ Boolean
105 106 107 |
# File 'app/models/decidim/conference.rb', line 105 def has_registration_for_user_and_registration_type?(user, registration_type) conference_registrations.where(user:, registration_type:).any? end |
#remaining_slots ⇒ Object
121 122 123 |
# File 'app/models/decidim/conference.rb', line 121 def remaining_slots available_slots - conference_registrations.count end |
#shareable_url(share_token) ⇒ Object
148 149 150 |
# File 'app/models/decidim/conference.rb', line 148 def shareable_url(share_token) EngineRouter.main_proxy(self).conference_url(self, share_token: share_token.token) end |
#to_param ⇒ Object
97 98 99 |
# File 'app/models/decidim/conference.rb', line 97 def to_param slug end |
#user_roles(role_name = nil) ⇒ Object
137 138 139 140 141 142 |
# File 'app/models/decidim/conference.rb', line 137 def user_roles(role_name = nil) roles = Decidim::ConferenceUserRole.where(conference: self) return roles if role_name.blank? roles.where(role: role_name) end |