Class: Decidim::Debates::CloseDebateForm

Inherits:
Form
  • Object
show all
Defined in:
app/forms/decidim/debates/close_debate_form.rb

Overview

This class holds a Form to close debates from Decidim’s public views.

Instance Method Summary collapse

Instance Method Details

#closed_atObject



15
16
17
# File 'app/forms/decidim/debates/close_debate_form.rb', line 15

def closed_at
  debate&.closed_at || Time.current
end

#debateObject



28
29
30
# File 'app/forms/decidim/debates/close_debate_form.rb', line 28

def debate
  @debate ||= Debate.find_by(id:)
end

#map_model(debate) ⇒ Object



19
20
21
22
23
24
25
26
# File 'app/forms/decidim/debates/close_debate_form.rb', line 19

def map_model(debate)
  super

  # Debates can be translated in different languages from the admin but
  # the public form does not allow it. When a user closes a debate the
  # user locale is taken as the text locale.
  self.conclusions = debate.conclusions&.values&.first
end