decidim-proposals 0.14.4 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/app/assets/images/decidim/gamification/badges/accepted_proposals.svg +194 -104
- data/app/assets/images/decidim/gamification/badges/proposals.svg +192 -108
- data/app/assets/javascripts/decidim/proposals/admin/proposals.es6 +25 -20
- data/app/cells/decidim/proposals/proposal_activity_cell.rb +19 -0
- data/app/commands/decidim/proposals/admin/answer_proposal.rb +6 -2
- data/app/commands/decidim/proposals/admin/create_proposal.rb +4 -4
- data/app/commands/decidim/proposals/admin/import_participatory_text.rb +49 -0
- data/app/commands/decidim/proposals/admin/import_proposals.rb +7 -21
- data/app/commands/decidim/proposals/admin/merge_proposals.rb +68 -0
- data/app/commands/decidim/proposals/admin/publish_participatory_text.rb +65 -0
- data/app/commands/decidim/proposals/admin/split_proposals.rb +67 -0
- data/app/commands/decidim/proposals/admin/update_proposal.rb +67 -0
- data/app/commands/decidim/proposals/create_collaborative_draft.rb +19 -14
- data/app/commands/decidim/proposals/create_proposal.rb +4 -2
- data/app/commands/decidim/proposals/endorse_proposal.rb +5 -1
- data/app/commands/decidim/proposals/publish_proposal.rb +15 -3
- data/app/commands/decidim/proposals/unvote_proposal.rb +34 -3
- data/app/commands/decidim/proposals/vote_proposal.rb +32 -2
- data/app/controllers/decidim/proposals/admin/participatory_texts_controller.rb +62 -0
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +28 -1
- data/app/controllers/decidim/proposals/admin/proposals_merges_controller.rb +27 -0
- data/app/controllers/decidim/proposals/admin/proposals_splits_controller.rb +27 -0
- data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +0 -1
- data/app/controllers/decidim/proposals/proposal_endorsements_controller.rb +6 -2
- data/app/controllers/decidim/proposals/proposal_votes_controller.rb +15 -0
- data/app/controllers/decidim/proposals/proposals_controller.rb +1 -1
- data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +28 -0
- data/app/forms/decidim/proposals/admin/preview_participatory_text_form.rb +21 -0
- data/app/forms/decidim/proposals/admin/proposal_form.rb +4 -1
- data/app/forms/decidim/proposals/admin/proposals_fork_form.rb +57 -0
- data/app/forms/decidim/proposals/admin/proposals_merge_form.rb +13 -0
- data/app/forms/decidim/proposals/admin/proposals_split_form.rb +12 -0
- data/app/helpers/decidim/proposals/application_helper.rb +23 -0
- data/app/helpers/decidim/proposals/map_helper.rb +1 -1
- data/app/helpers/decidim/proposals/participatory_texts_helper.rb +18 -0
- data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +1 -1
- data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +2 -1
- data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +3 -4
- data/app/models/decidim/proposals/participatory_text.rb +13 -0
- data/app/models/decidim/proposals/proposal.rb +31 -9
- data/app/models/decidim/proposals/proposal_vote.rb +21 -1
- data/app/permissions/decidim/proposals/admin/permissions.rb +30 -0
- data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +5 -1
- data/app/presenters/decidim/proposals/log/resource_presenter.rb +18 -0
- data/app/presenters/decidim/proposals/official_author_presenter.rb +4 -0
- data/app/queries/decidim/proposals/metrics/accepted_proposals_metric_manage.rb +29 -0
- data/app/queries/decidim/proposals/metrics/proposals_metric_manage.rb +53 -0
- data/app/queries/decidim/proposals/metrics/votes_metric_manage.rb +57 -0
- data/app/services/decidim/proposals/proposal_builder.rb +72 -0
- data/app/services/decidim/proposals/proposal_search.rb +2 -2
- data/app/views/decidim/proposals/admin/participatory_texts/_article-preview.html.erb +13 -0
- data/app/views/decidim/proposals/admin/participatory_texts/_bulk-actions.html.erb +1 -0
- data/app/views/decidim/proposals/admin/participatory_texts/index.html.erb +43 -0
- data/app/views/decidim/proposals/admin/participatory_texts/new_import.html.erb +39 -0
- data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +7 -2
- data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +4 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_dropdown.html.erb +36 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_merge.html.erb +15 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_recategorize.html.erb +15 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_split.html.erb +15 -0
- data/app/views/decidim/proposals/admin/proposals/edit.html.erb +7 -0
- data/app/views/decidim/proposals/admin/proposals/index.html.erb +2 -2
- data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +2 -2
- data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +1 -1
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -1
- data/app/views/decidim/proposals/proposal_endorsements/_identity.html.erb +5 -1
- data/app/views/decidim/proposals/proposal_endorsements/update_buttons_and_counters.js.erb +1 -1
- data/app/views/decidim/proposals/proposal_votes/update_buttons_and_counters.js.erb +13 -4
- data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_endorsement_identities_cabin.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/_proposal_similar.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/_voting_rules.html.erb +15 -4
- data/app/views/decidim/proposals/proposals/new.html.erb +1 -1
- data/config/locales/ca.yml +72 -4
- data/config/locales/de.yml +71 -3
- data/config/locales/en.yml +71 -3
- data/config/locales/es-PY.yml +71 -3
- data/config/locales/es.yml +73 -5
- data/config/locales/eu.yml +71 -3
- data/config/locales/fi.yml +81 -13
- data/config/locales/fr.yml +71 -3
- data/config/locales/gl.yml +71 -3
- data/config/locales/hu.yml +71 -3
- data/config/locales/it.yml +71 -3
- data/config/locales/nl.yml +71 -3
- data/config/locales/pl.yml +71 -3
- data/config/locales/pt-BR.yml +72 -4
- data/config/locales/pt.yml +71 -3
- data/config/locales/sv.yml +71 -3
- data/db/migrate/20180927111721_create_participatory_texts.rb +13 -0
- data/db/migrate/20180930125321_add_participatory_text_level_to_proposals.rb +7 -0
- data/db/migrate/20180930125321_add_position_to_proposals.rb +7 -0
- data/db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb +16 -0
- data/db/migrate/20181010114622_add_temporary_votes.rb +9 -0
- data/db/migrate/20181016132225_add_organization_as_author.rb +13 -0
- data/db/migrate/20181017084221_make_author_polymorhpic_for_proposal_endorsements.rb +31 -0
- data/lib/decidim/content_parsers/proposal_parser.rb +9 -3
- data/lib/decidim/proposals.rb +3 -1
- data/lib/decidim/proposals/admin_engine.rb +12 -1
- data/lib/decidim/proposals/component.rb +60 -23
- data/lib/decidim/proposals/engine.rb +55 -12
- data/lib/decidim/proposals/markdown_to_proposals.rb +90 -0
- data/lib/decidim/proposals/participatory_text_section.rb +21 -0
- data/lib/decidim/proposals/test/factories.rb +35 -7
- data/lib/decidim/proposals/version.rb +1 -1
- metadata +86 -19
@@ -42,23 +42,28 @@ module Decidim
|
|
42
42
|
attr_reader :form, :collaborative_draft, :attachment
|
43
43
|
|
44
44
|
def create_collaborative_draft
|
45
|
-
@collaborative_draft = Decidim.traceability.
|
45
|
+
@collaborative_draft = Decidim.traceability.perform_action!(
|
46
|
+
:create,
|
46
47
|
CollaborativeDraft,
|
47
|
-
@form.current_user
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
48
|
+
@form.current_user
|
49
|
+
) do
|
50
|
+
draft = CollaborativeDraft.new(
|
51
|
+
title: form.title,
|
52
|
+
body: form.body,
|
53
|
+
category: form.category,
|
54
|
+
scope: form.scope,
|
55
|
+
component: form.component,
|
56
|
+
address: form.address,
|
57
|
+
latitude: form.latitude,
|
58
|
+
longitude: form.longitude,
|
59
|
+
state: "open"
|
60
|
+
)
|
61
|
+
draft.coauthorships.build(author: @current_user, user_group: @form.user_group)
|
62
|
+
draft.save!
|
63
|
+
draft
|
64
|
+
end
|
58
65
|
|
59
66
|
@attached_to = @collaborative_draft
|
60
|
-
|
61
|
-
@collaborative_draft.add_coauthor(@current_user, user_group: @form.user_group)
|
62
67
|
end
|
63
68
|
|
64
69
|
def user_group
|
@@ -45,12 +45,14 @@ module Decidim
|
|
45
45
|
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
|
46
46
|
parsed_body = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.body, current_organization: form.current_organization).rewrite
|
47
47
|
|
48
|
-
@proposal = Proposal.
|
48
|
+
@proposal = Proposal.new(
|
49
49
|
title: parsed_title,
|
50
50
|
body: parsed_body,
|
51
51
|
component: form.component
|
52
52
|
)
|
53
|
-
proposal.add_coauthor(@current_user, user_group: user_group)
|
53
|
+
@proposal.add_coauthor(@current_user, user_group: user_group)
|
54
|
+
@proposal.save!
|
55
|
+
@proposal
|
54
56
|
end
|
55
57
|
|
56
58
|
def proposal_limit_reached?
|
@@ -35,10 +35,14 @@ module Decidim
|
|
35
35
|
|
36
36
|
def build_proposal_endorsement
|
37
37
|
endorsement = @proposal.endorsements.build(author: @current_user)
|
38
|
-
endorsement.user_group =
|
38
|
+
endorsement.user_group = user_groups.find(@current_group_id) if @current_group_id.present?
|
39
39
|
endorsement
|
40
40
|
end
|
41
41
|
|
42
|
+
def user_groups
|
43
|
+
Decidim::UserGroups::ManageableUserGroups.for(@current_user).verified
|
44
|
+
end
|
45
|
+
|
42
46
|
def notify_endorser_followers
|
43
47
|
recipient_ids = @current_user.followers.pluck(:id)
|
44
48
|
Decidim::EventsManager.publish(
|
@@ -23,7 +23,15 @@ module Decidim
|
|
23
23
|
return broadcast(:invalid) unless @proposal.authored_by?(@current_user)
|
24
24
|
|
25
25
|
transaction do
|
26
|
-
|
26
|
+
Decidim.traceability.perform_action!(
|
27
|
+
"publish",
|
28
|
+
@proposal,
|
29
|
+
@current_user,
|
30
|
+
visibility: "public-only"
|
31
|
+
) do
|
32
|
+
@proposal.update published_at: Time.current
|
33
|
+
end
|
34
|
+
|
27
35
|
increment_scores
|
28
36
|
send_notification
|
29
37
|
send_notification_to_participatory_space
|
@@ -66,8 +74,12 @@ module Decidim
|
|
66
74
|
end
|
67
75
|
|
68
76
|
def increment_scores
|
69
|
-
@proposal.
|
70
|
-
|
77
|
+
@proposal.coauthorships.find_each do |coauthorship|
|
78
|
+
if coauthorship.user_group
|
79
|
+
Decidim::Gamification.increment_score(coauthorship.user_group, :proposals)
|
80
|
+
else
|
81
|
+
Decidim::Gamification.increment_score(coauthorship.author, :proposals)
|
82
|
+
end
|
71
83
|
end
|
72
84
|
end
|
73
85
|
end
|
@@ -21,13 +21,44 @@ module Decidim
|
|
21
21
|
# Returns nothing.
|
22
22
|
def call
|
23
23
|
ActiveRecord::Base.transaction do
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
ProposalVote.where(
|
25
|
+
author: @current_user,
|
26
|
+
proposal: @proposal
|
27
|
+
).destroy_all
|
28
|
+
|
29
|
+
update_temporary_votes
|
27
30
|
end
|
28
31
|
|
32
|
+
Decidim::Gamification.decrement_score(@current_user, :proposal_votes)
|
33
|
+
|
29
34
|
broadcast(:ok, @proposal)
|
30
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def component
|
40
|
+
@component ||= @proposal.component
|
41
|
+
end
|
42
|
+
|
43
|
+
def minimum_votes_per_user
|
44
|
+
component.settings.minimum_votes_per_user
|
45
|
+
end
|
46
|
+
|
47
|
+
def minimum_votes_per_user?
|
48
|
+
minimum_votes_per_user.positive?
|
49
|
+
end
|
50
|
+
|
51
|
+
def update_temporary_votes
|
52
|
+
return unless minimum_votes_per_user? && user_votes.count < minimum_votes_per_user
|
53
|
+
user_votes.each { |vote| vote.update(temporary: true) }
|
54
|
+
end
|
55
|
+
|
56
|
+
def user_votes
|
57
|
+
@user_votes ||= ProposalVote.where(
|
58
|
+
author: @current_user,
|
59
|
+
proposal: Proposal.where(component: component)
|
60
|
+
)
|
61
|
+
end
|
31
62
|
end
|
32
63
|
end
|
33
64
|
end
|
@@ -25,7 +25,10 @@ module Decidim
|
|
25
25
|
build_proposal_vote
|
26
26
|
return broadcast(:invalid) unless vote.valid?
|
27
27
|
|
28
|
-
|
28
|
+
ActiveRecord::Base.transaction do
|
29
|
+
vote.save!
|
30
|
+
update_temporary_votes
|
31
|
+
end
|
29
32
|
|
30
33
|
Decidim::Gamification.increment_score(@current_user, :proposal_votes)
|
31
34
|
|
@@ -36,8 +39,35 @@ module Decidim
|
|
36
39
|
|
37
40
|
private
|
38
41
|
|
42
|
+
def component
|
43
|
+
@component ||= @proposal.component
|
44
|
+
end
|
45
|
+
|
46
|
+
def minimum_votes_per_user
|
47
|
+
component.settings.minimum_votes_per_user
|
48
|
+
end
|
49
|
+
|
50
|
+
def minimum_votes_per_user?
|
51
|
+
minimum_votes_per_user.positive?
|
52
|
+
end
|
53
|
+
|
54
|
+
def update_temporary_votes
|
55
|
+
return unless minimum_votes_per_user? && user_votes.count >= minimum_votes_per_user
|
56
|
+
user_votes.each { |vote| vote.update(temporary: false) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def user_votes
|
60
|
+
@user_votes ||= ProposalVote.where(
|
61
|
+
author: @current_user,
|
62
|
+
proposal: Proposal.where(component: component)
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
39
66
|
def build_proposal_vote
|
40
|
-
@vote = @proposal.votes.build(
|
67
|
+
@vote = @proposal.votes.build(
|
68
|
+
author: @current_user,
|
69
|
+
temporary: minimum_votes_per_user?
|
70
|
+
)
|
41
71
|
end
|
42
72
|
end
|
43
73
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
# This controller manages the participatory texts area.
|
7
|
+
class ParticipatoryTextsController < Admin::ApplicationController
|
8
|
+
helper_method :proposal
|
9
|
+
helper ParticipatoryTextsHelper
|
10
|
+
|
11
|
+
def index
|
12
|
+
@drafts = Proposal.where(component: current_component).drafts.order(:position)
|
13
|
+
@preview_form = form(Admin::PreviewParticipatoryTextForm).instance
|
14
|
+
@preview_form.from_models(@drafts)
|
15
|
+
end
|
16
|
+
|
17
|
+
def new_import
|
18
|
+
enforce_permission_to :import, :participatory_texts
|
19
|
+
@import = form(Admin::ImportParticipatoryTextForm).instance
|
20
|
+
end
|
21
|
+
|
22
|
+
def import
|
23
|
+
enforce_permission_to :import, :participatory_texts
|
24
|
+
@import = form(Admin::ImportParticipatoryTextForm).from_params(params)
|
25
|
+
|
26
|
+
Admin::ImportParticipatoryText.call(@import) do
|
27
|
+
on(:ok) do
|
28
|
+
flash[:notice] = I18n.t("participatory_texts.import.success", scope: "decidim.proposals.admin")
|
29
|
+
redirect_to participatory_texts_path(component_id: current_component.id, initiative_slug: "asdf")
|
30
|
+
end
|
31
|
+
|
32
|
+
on(:invalid) do
|
33
|
+
flash.now[:alert] = I18n.t("participatory_texts.import.invalid", scope: "decidim.proposals.admin")
|
34
|
+
render action: "new_import"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def publish
|
40
|
+
enforce_permission_to :publish, :participatory_texts
|
41
|
+
form_params = params.require(:preview_participatory_text).permit!
|
42
|
+
@preview_form = form(Admin::PreviewParticipatoryTextForm).from_params(proposals: form_params[:proposals_attributes]&.values)
|
43
|
+
|
44
|
+
PublishParticipatoryText.call(@preview_form) do
|
45
|
+
on(:ok) do
|
46
|
+
flash[:notice] = I18n.t("participatory_texts.publish.success", scope: "decidim.proposals.admin")
|
47
|
+
redirect_to proposals_path
|
48
|
+
end
|
49
|
+
|
50
|
+
on(:invalid) do |failures|
|
51
|
+
alert_msg = [I18n.t("participatory_texts.publish.invalid", scope: "decidim.proposals.admin")]
|
52
|
+
failures.each_pair { |id, msg| alert_msg << "ID:[#{id}] #{msg}" }
|
53
|
+
flash.now[:alert] = alert_msg.join("<br/>").html_safe
|
54
|
+
index
|
55
|
+
render action: "index"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -61,10 +61,37 @@ module Decidim
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
def edit
|
65
|
+
enforce_permission_to :edit, :proposal, proposal: proposal
|
66
|
+
@form = form(Admin::ProposalForm).from_model(proposal)
|
67
|
+
@form.attachment = form(AttachmentForm).from_params({})
|
68
|
+
end
|
69
|
+
|
70
|
+
def update
|
71
|
+
enforce_permission_to :edit, :proposal, proposal: proposal
|
72
|
+
|
73
|
+
@form = form(Admin::ProposalForm).from_params(params)
|
74
|
+
Admin::UpdateProposal.call(@form, @proposal) do
|
75
|
+
on(:ok) do |_proposal|
|
76
|
+
flash[:notice] = I18n.t("proposals.update.success", scope: "decidim")
|
77
|
+
redirect_to proposals_path
|
78
|
+
end
|
79
|
+
|
80
|
+
on(:invalid) do
|
81
|
+
flash.now[:alert] = I18n.t("proposals.update.error", scope: "decidim")
|
82
|
+
render :edit
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
64
87
|
private
|
65
88
|
|
66
89
|
def query
|
67
|
-
@query ||=
|
90
|
+
@query ||= if current_component.settings.participatory_texts_enabled?
|
91
|
+
Proposal.where(component: current_component).published.order(:position).ransack(params[:q])
|
92
|
+
else
|
93
|
+
Proposal.where(component: current_component).published.ransack(params[:q])
|
94
|
+
end
|
68
95
|
end
|
69
96
|
|
70
97
|
def proposals
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
class ProposalsMergesController < Admin::ApplicationController
|
7
|
+
def create
|
8
|
+
enforce_permission_to :merge, :proposals
|
9
|
+
|
10
|
+
@form = form(Admin::ProposalsMergeForm).from_params(params)
|
11
|
+
|
12
|
+
Admin::MergeProposals.call(@form) do
|
13
|
+
on(:ok) do |_proposal|
|
14
|
+
flash[:notice] = I18n.t("proposals_merges.create.success", scope: "decidim.proposals.admin")
|
15
|
+
redirect_to EngineRouter.admin_proxy(@form.target_component).root_path
|
16
|
+
end
|
17
|
+
|
18
|
+
on(:invalid) do
|
19
|
+
flash[:alert] = I18n.t("proposals_merges.create.invalid", scope: "decidim.proposals.admin")
|
20
|
+
redirect_to EngineRouter.admin_proxy(current_component).root_path
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
class ProposalsSplitsController < Admin::ApplicationController
|
7
|
+
def create
|
8
|
+
enforce_permission_to :split, :proposals
|
9
|
+
|
10
|
+
@form = form(Admin::ProposalsSplitForm).from_params(params)
|
11
|
+
|
12
|
+
Admin::SplitProposals.call(@form) do
|
13
|
+
on(:ok) do |_proposal|
|
14
|
+
flash[:notice] = I18n.t("proposals_splits.create.success", scope: "decidim.proposals.admin")
|
15
|
+
redirect_to EngineRouter.admin_proxy(@form.target_component).root_path
|
16
|
+
end
|
17
|
+
|
18
|
+
on(:invalid) do
|
19
|
+
flash.now[:alert] = I18n.t("proposals_splits.create.invalid", scope: "decidim.proposals.admin")
|
20
|
+
redirect_to EngineRouter.admin_proxy(current_component).root_path
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -29,7 +29,7 @@ module Decidim
|
|
29
29
|
enforce_permission_to :unendorse, :proposal, proposal: proposal
|
30
30
|
@from_proposals_list = params[:from_proposals_list] == "true"
|
31
31
|
user_group_id = params[:user_group_id]
|
32
|
-
user_group =
|
32
|
+
user_group = user_groups.find(user_group_id) if user_group_id
|
33
33
|
|
34
34
|
UnendorseProposal.call(proposal, current_user, user_group) do
|
35
35
|
on(:ok) do
|
@@ -42,12 +42,16 @@ module Decidim
|
|
42
42
|
def identities
|
43
43
|
enforce_permission_to :endorse, :proposal, proposal: proposal
|
44
44
|
|
45
|
-
@user_verified_groups = current_user.
|
45
|
+
@user_verified_groups = Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
|
46
46
|
render :identities, layout: false
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
|
+
def user_groups
|
52
|
+
Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
|
53
|
+
end
|
54
|
+
|
51
55
|
def proposal
|
52
56
|
@proposal ||= Proposal.where(component: current_component).find(params[:proposal_id])
|
53
57
|
end
|
@@ -5,6 +5,7 @@ module Decidim
|
|
5
5
|
# Exposes the proposal vote resource so users can vote proposals.
|
6
6
|
class ProposalVotesController < Decidim::Proposals::ApplicationController
|
7
7
|
include ProposalVotesHelper
|
8
|
+
include Rectify::ControllerHelpers
|
8
9
|
|
9
10
|
helper_method :proposal
|
10
11
|
|
@@ -17,6 +18,13 @@ module Decidim
|
|
17
18
|
VoteProposal.call(proposal, current_user) do
|
18
19
|
on(:ok) do
|
19
20
|
proposal.reload
|
21
|
+
|
22
|
+
proposals = ProposalVote.where(
|
23
|
+
author: current_user,
|
24
|
+
proposal: Proposal.where(component: current_component)
|
25
|
+
).map(&:proposal)
|
26
|
+
|
27
|
+
expose(proposals: proposals)
|
20
28
|
render :update_buttons_and_counters
|
21
29
|
end
|
22
30
|
|
@@ -33,6 +41,13 @@ module Decidim
|
|
33
41
|
UnvoteProposal.call(proposal, current_user) do
|
34
42
|
on(:ok) do
|
35
43
|
proposal.reload
|
44
|
+
|
45
|
+
proposals = ProposalVote.where(
|
46
|
+
author: current_user,
|
47
|
+
proposal: Proposal.where(component: current_component)
|
48
|
+
).map(&:proposal)
|
49
|
+
|
50
|
+
expose(proposals: proposals + [proposal])
|
36
51
|
render :update_buttons_and_counters
|
37
52
|
end
|
38
53
|
end
|
@@ -203,7 +203,7 @@ module Decidim
|
|
203
203
|
end
|
204
204
|
|
205
205
|
def proposal_draft
|
206
|
-
Proposal.
|
206
|
+
Proposal.from_all_author_identities(current_user).not_hidden.where(component: current_component).find_by(published_at: nil)
|
207
207
|
end
|
208
208
|
|
209
209
|
def ensure_is_draft
|