Class: Decidim::Votings::PollingOfficerZone::ClosuresController

Inherits:
ApplicationController show all
Defined in:
decidim-elections/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb

Overview

Space to manage the election closure of a Polling Station

Instance Method Summary collapse

Methods included from UserProfile

#available_verification_workflows

Methods included from UserGroups

#enforce_user_groups_enabled

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#certifyObject


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 71

def certify
  enforce_permission_to :manage, :polling_station_results, polling_officer: polling_officer

  @form = form(ClosureCertifyForm).from_params(params).with_context(closure: closure)

  CertifyPollingStationClosure.call(@form, closure) do
    on(:ok) do
      flash[:notice] = t(".success")
    end

    on(:invalid) do
      flash[:alert] = t(".error")
    end
  end

  redirect_to polling_officer_election_closure_path(polling_officer, election)
end

#createObject


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 30

def create
  enforce_permission_to :manage, :polling_station_results, polling_officer: polling_officer
  @form = form(EnvelopesResultForm).from_params(params).with_context(polling_officer: polling_officer)

  CreatePollingStationClosure.call(@form) do
    on(:ok) do
      flash[:notice] = t(".success")
      redirect_to edit_polling_officer_election_closure_path(polling_officer, election)
    end

    on(:invalid) do
      flash[:alert] = t(".error")

      render :new
    end
  end
end

#editObject


48
49
50
51
52
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 48

def edit
  enforce_permission_to :manage, :polling_station_results, polling_officer: polling_officer

  @form = form(ClosureResultForm).from_model(closure)
end

#newObject


20
21
22
23
24
25
26
27
28
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 20

def new
  enforce_permission_to :manage, :polling_station_results, polling_officer: polling_officer

  @form = EnvelopesResultForm.new(
    polling_station_id: polling_station.id,
    election_id: election.id,
    election_votes_count: polling_station_election_votes_count
  )
end

#showObject


10
11
12
13
14
15
16
17
18
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 10

def show
  enforce_permission_to :manage, :polling_station_results, polling_officer: polling_officer

  @form = if closure.certificate_phase?
            form(ClosureCertifyForm).instance.with_context(closure: closure)
          elsif closure.signature_phase?
            form(ClosureSignForm).instance
          end
end

#signObject


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 89

def sign
  enforce_permission_to :manage, :polling_station_results, polling_officer: polling_officer

  @form = form(ClosureSignForm).from_params(params)

  SignPollingStationClosure.call(@form, closure) do
    on(:ok) do
      flash[:notice] = t(".success")
    end

    on(:invalid) do
      flash[:alert] = t(".error")
    end
  end

  redirect_to polling_officer_election_closure_path(polling_officer, election)
end

#updateObject


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 54

def update
  enforce_permission_to :manage, :polling_station_results, polling_officer: polling_officer
  @form = form(ClosureResultForm).from_params(params)

  CreatePollingStationResults.call(@form, closure) do
    on(:ok) do
      flash[:notice] = t(".success")
    end

    on(:invalid) do
      flash[:alert] = t(".error")
    end
  end

  redirect_to polling_officer_election_closure_path(polling_officer, election)
end