Class: Poll
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Poll
- Includes:
- HasOwner, Toggleable
- Defined in:
- app/models/poll.rb
Constant Summary collapse
- PER_PAGE =
10
- NAME_LIMIT =
140
- DESCRIPTION_LIMIT =
255
Class Method Summary collapse
- .entity_parameters ⇒ Object
- .page_for_administration(page = 1) ⇒ Object
- .page_for_visitors(page = 1) ⇒ Object
Instance Method Summary collapse
Class Method Details
.entity_parameters ⇒ Object
37 38 39 |
# File 'app/models/poll.rb', line 37 def self.entity_parameters Poll.toggleable_attributes + %i(image name description end_date) end |
.page_for_administration(page = 1) ⇒ Object
28 29 30 |
# File 'app/models/poll.rb', line 28 def self.page_for_administration(page = 1) recent.page(page).per(PER_PAGE) end |
.page_for_visitors(page = 1) ⇒ Object
33 34 35 |
# File 'app/models/poll.rb', line 33 def self.page_for_visitors(page = 1) visible.recent.page(page).per(PER_PAGE) end |
Instance Method Details
#editable_by?(user) ⇒ Boolean
42 43 44 45 46 |
# File 'app/models/poll.rb', line 42 def editable_by?(user) return false if user.nil? privilege = :chief_poll_manager owned_by?(user) || UserPrivilege.user_has_privilege?(user, privilege) end |
#regional? ⇒ Boolean
53 54 55 |
# File 'app/models/poll.rb', line 53 def regional? !region_id.nil? end |
#visible_to?(user) ⇒ Boolean
49 50 51 |
# File 'app/models/poll.rb', line 49 def visible_to?(user) visible? || owned_by?(user) end |