Class: Decidim::Proposals::CollaborativeDraft

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

Instance Method Summary collapse

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)


41
42
43
# File 'app/models/decidim/proposals/collaborative_draft.rb', line 41

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

#open?Boolean

Returns:

  • (Boolean)


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

def open?
  state == "open"
end

#published?Boolean

Returns:

  • (Boolean)


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

def published?
  state == "published"
end

#reported_attributesObject

Public: Overrides the ‘reported_attributes` Reportable concern method.



63
64
65
# File 'app/models/decidim/proposals/collaborative_draft.rb', line 63

def reported_attributes
  [:body]
end

#reported_content_urlObject

Public: Overrides the ‘reported_content_url` Reportable concern method.



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

def reported_content_url
  ResourceLocatorPresenter.new(self).url
end

#reported_searchable_content_extrasObject

Public: Overrides the ‘reported_searchable_content_extras` Reportable concern method.



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

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

#withdrawn?Boolean

Returns:

  • (Boolean)


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

def withdrawn?
  state == "withdrawn"
end