Class: Decidim::Proposals::CollaborativeDraft

Inherits:
ApplicationRecord show all
Includes:
Coauthorable, FilterableResource, Followable, HasAttachments, HasCategory, HasComponent, HasReference, Loggable, CommentableCollaborativeDraft, Randomable, Reportable, Resourceable, ScopableResource, Taxonomizable, Traceable
Defined in:
decidim-proposals/app/models/decidim/proposals/collaborative_draft.rb

Constant Summary collapse

STATES =
{ open: 0, published: 10, withdrawn: -1 }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Followable

#followers

Methods included from HasAttachments

#attachment_context

Class Method Details

.ransackable_associations(_auth_object = nil) ⇒ Object



75
76
77
# File 'decidim-proposals/app/models/decidim/proposals/collaborative_draft.rb', line 75

def self.ransackable_associations(_auth_object = nil)
  %w(taxonomies)
end

.ransackable_attributes(_auth_object = nil) ⇒ Object



71
72
73
# File 'decidim-proposals/app/models/decidim/proposals/collaborative_draft.rb', line 71

def self.ransackable_attributes(_auth_object = nil)
  %w(id_string search_text title body)
end

.ransackable_scopes(_auth_object = nil) ⇒ Object



67
68
69
# File 'decidim-proposals/app/models/decidim/proposals/collaborative_draft.rb', line 67

def self.ransackable_scopes(_auth_object = nil)
  [:with_any_state, :related_to, :with_any_taxonomies]
end

Instance Method Details

#editable_by?(user) ⇒ Boolean

Checks whether the user can edit the given proposal.

user - the user to check for authorship

Returns:

  • (Boolean)


45
46
47
# File 'decidim-proposals/app/models/decidim/proposals/collaborative_draft.rb', line 45

def editable_by?(user)
  authored_by?(user)
end

#reported_attributesObject

Public: Overrides the ‘reported_attributes` Reportable concern method.



55
56
57
# File 'decidim-proposals/app/models/decidim/proposals/collaborative_draft.rb', line 55

def reported_attributes
  [:body]
end

#reported_content_urlObject

Public: Overrides the ‘reported_content_url` Reportable concern method.



50
51
52
# File 'decidim-proposals/app/models/decidim/proposals/collaborative_draft.rb', line 50

def reported_content_url
  ResourceLocatorPresenter.new(self).url
end

#reported_searchable_content_extrasObject

Public: Overrides the ‘reported_searchable_content_extras` Reportable concern method.



60
61
62
# File 'decidim-proposals/app/models/decidim/proposals/collaborative_draft.rb', line 60

def reported_searchable_content_extras
  [authors.map(&:name).join("\n")]
end