Class: Decidim::Proposals::CollaborativeDraft

Inherits:
ApplicationRecord show all
Includes:
Coauthorable, FilterableResource, Followable, HasAttachments, HasCategory, HasComponent, HasReference, Loggable, CommentableCollaborativeDraft, Randomable, Reportable, Resourceable, ScopableResource, Traceable
Defined in:
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

Class Method Details

.ransackable_scopes(_auth_object = nil) ⇒ Object



65
66
67
# File 'app/models/decidim/proposals/collaborative_draft.rb', line 65

def self.ransackable_scopes(_auth_object = nil)
  [:with_any_state, :related_to, :with_any_scope, :with_any_category]
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)


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

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

#presenterObject



48
49
50
# File 'app/models/decidim/proposals/collaborative_draft.rb', line 48

def presenter
  Decidim::Proposals::CollaborativeDraftPresenter.new(self)
end

#reported_attributesObject

Public: Overrides the ‘reported_attributes` Reportable concern method.



53
54
55
# File 'app/models/decidim/proposals/collaborative_draft.rb', line 53

def reported_attributes
  [:body]
end

#reported_searchable_content_extrasObject

Public: Overrides the ‘reported_searchable_content_extras` Reportable concern method.



58
59
60
# File 'app/models/decidim/proposals/collaborative_draft.rb', line 58

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