decidim-reporting_proposals 0.2.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.json +1 -0
- data/.github/workflows/lint.yml +1 -0
- data/.github/workflows/test_integration.yml +5 -1
- data/.github/workflows/test_unit.yml +5 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +269 -227
- data/README.md +108 -16
- data/app/cells/concerns/decidim/reporting_proposals/proposals_picker_cell_override.rb +24 -0
- data/app/commands/concerns/decidim/admin/hide_resource_override.rb +34 -0
- data/app/commands/concerns/decidim/proposals/admin/answer_proposal_override.rb +41 -0
- data/app/commands/concerns/decidim/proposals/admin/assign_proposals_to_valuator_override.rb +30 -0
- data/app/commands/concerns/decidim/proposals/publish_proposal_override.rb +72 -0
- data/app/commands/concerns/decidim/reporting_proposals/admin/create_answer_override.rb +17 -0
- data/app/commands/concerns/decidim/reporting_proposals/admin/create_result_override.rb +17 -0
- data/app/commands/concerns/decidim/reporting_proposals/admin/update_result_override.rb +34 -0
- data/app/commands/concerns/decidim/reporting_proposals/close_meeting_override.rb +15 -0
- data/app/commands/concerns/decidim/reporting_proposals/create_project_override.rb +15 -0
- data/app/commands/concerns/decidim/templates/admin/copy_questionnaire_template_override.rb +32 -0
- data/app/commands/concerns/decidim/templates/admin/create_questionnaire_template_override.rb +32 -0
- data/app/commands/decidim/templates/admin/copy_proposal_answer_template.rb +35 -0
- data/app/commands/decidim/templates/admin/create_proposal_answer_template.rb +48 -0
- data/app/commands/decidim/templates/admin/update_proposal_answer_template.rb +52 -0
- data/app/controllers/concerns/decidim/proposals/admin/valuation_assignments_controller_override.rb +35 -0
- data/app/controllers/concerns/decidim/templates/admin/application_controller_override.rb +20 -0
- data/app/controllers/decidim/reporting_proposals/admin/proposal_notes_controller.rb +4 -5
- data/app/controllers/decidim/templates/admin/proposal_answer_templates_controller.rb +181 -0
- data/app/events/concerns/decidim/proposals/publish_proposal_event_override.rb +35 -0
- data/app/forms/concerns/decidim/reporting_proposals/close_meeting_form_override.rb +28 -0
- data/app/forms/concerns/decidim/reporting_proposals/form_builder_override.rb +1 -3
- data/app/forms/concerns/decidim/reporting_proposals/map_included_proposals_for_form_override.rb +28 -0
- data/app/forms/concerns/decidim/reporting_proposals/map_related_proposals_for_form_override.rb +28 -0
- data/app/forms/decidim/templates/admin/proposal_answer_template_form.rb +21 -0
- data/app/helpers/concerns/decidim/reporting_proposals/resource_helper_override.rb +25 -0
- data/app/mailers/concerns/decidim/admin/hidden_resource_mailer.rb +28 -0
- data/app/mailers/concerns/decidim/proposals/admin/notification_answer_proposal_mailer.rb +25 -0
- data/app/mailers/concerns/decidim/proposals/admin/proposals_valuator_mailer.rb +30 -0
- data/app/mailers/concerns/decidim/proposals/notification_publish_proposal_mailer.rb +23 -0
- data/app/mailers/concerns/decidim/reported_mailer_override.rb +16 -0
- data/app/models/concerns/decidim/reporting_proposals/participatory_space_role_config/valuator_override.rb +4 -1
- data/app/overrides/decidim/proposals/admin/proposal_answers/_form/add_template_chooser.html.erb.deface +5 -0
- data/app/overrides/decidim/proposals/admin/proposals/show/add_address.html.erb.deface +3 -0
- data/app/overrides/decidim/proposals/admin/proposals/show/add_valuators_form.html.erb.deface +19 -0
- data/app/overrides/decidim/reported_mailer/report/add_link_to_admin.html.erb.deface +5 -0
- data/app/packs/entrypoints/decidim_templates_admin.js +1 -0
- data/app/packs/src/decidim/reporting_proposals/user_camera_inputs.js +37 -39
- data/app/packs/src/decidim/templates/admin/proposal_answer_template_chooser.js +27 -0
- data/app/packs/stylesheets/decidim/reporting_proposals/manage_component_admin.scss +31 -0
- data/app/presenters/concerns/decidim/resource_locator_presenter_override.rb +38 -0
- data/app/resources/concerns/decidim/resource_manifest_override.rb +14 -0
- data/app/views/decidim/admin/hidden_resource_mailer/notify_mail.html.erb +12 -0
- data/app/views/decidim/proposals/admin/notification_answer_proposal_mailer/notify_proposal_author.html.erb +7 -0
- data/app/views/decidim/proposals/admin/proposals/_address.html.erb +13 -0
- data/app/views/decidim/proposals/admin/proposals_valuator_mailer/notify_proposals_valuator.html.erb +17 -0
- data/app/views/decidim/proposals/notification_publish_proposal_mailer/notify_proposal_author.html.erb +7 -0
- data/app/views/decidim/proposals/proposals/index.js.erb +19 -0
- data/app/views/decidim/templates/admin/proposal_answer_templates/_form.html.erb +34 -0
- data/app/views/decidim/templates/admin/proposal_answer_templates/_template_chooser.html.erb +16 -0
- data/app/views/decidim/templates/admin/proposal_answer_templates/edit.html.erb +3 -0
- data/app/views/decidim/templates/admin/proposal_answer_templates/index.html.erb +52 -0
- data/app/views/decidim/templates/admin/proposal_answer_templates/new.html.erb +6 -0
- data/config/assets.rb +2 -1
- data/config/i18n-tasks.yml +3 -0
- data/config/locales/ca.yml +81 -7
- data/config/locales/de.yml +77 -3
- data/config/locales/en.yml +87 -0
- data/config/locales/es.yml +328 -254
- data/db/migrate/20230404103706_add_target_and_field_values_to_decidim_templates_templates.rb +12 -0
- data/db/migrate/20230404104741_migrate_templatable.rb +13 -0
- data/decidim-reporting_proposals.gemspec +5 -0
- data/lib/decidim/reporting_proposals/admin_engine.rb +16 -1
- data/lib/decidim/reporting_proposals/component.rb +1 -1
- data/lib/decidim/reporting_proposals/config.rb +10 -5
- data/lib/decidim/reporting_proposals/engine.rb +38 -1
- data/lib/decidim/reporting_proposals/test/factories.rb +10 -0
- data/lib/decidim/reporting_proposals/version.rb +2 -7
- metadata +152 -2
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Templates
|
5
|
+
module Admin
|
6
|
+
class UpdateProposalAnswerTemplate < Rectify::Command
|
7
|
+
# Initializes the command.
|
8
|
+
#
|
9
|
+
# template - The Template to update.
|
10
|
+
# form - The form object containing the data to update.
|
11
|
+
# user - The user that updates the template.
|
12
|
+
def initialize(template, form, user)
|
13
|
+
@template = template
|
14
|
+
@form = form
|
15
|
+
@user = user
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
return broadcast(:invalid) unless @form.valid?
|
20
|
+
return broadcast(:invalid) unless @user.organization == @template.organization
|
21
|
+
|
22
|
+
@template = Decidim.traceability.update!(
|
23
|
+
@template,
|
24
|
+
@user,
|
25
|
+
name: @form.name,
|
26
|
+
description: @form.description,
|
27
|
+
field_values: { internal_state: @form.internal_state },
|
28
|
+
target: :proposal_answer
|
29
|
+
)
|
30
|
+
|
31
|
+
resource = identify_templateable_resource
|
32
|
+
@template.update!(templatable: resource)
|
33
|
+
|
34
|
+
broadcast(:ok, @template)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def identify_templateable_resource
|
40
|
+
resource = @form.scope_for_availability.split("-")
|
41
|
+
case resource.first
|
42
|
+
when "organizations"
|
43
|
+
@form.current_organization
|
44
|
+
when "components"
|
45
|
+
component = Decidim::Component.find_by(id: resource.last)
|
46
|
+
component&.participatory_space&.decidim_organization_id == @form.current_organization.id ? component : nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/app/controllers/concerns/decidim/proposals/admin/valuation_assignments_controller_override.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
module ValuationAssignmentsControllerOverride
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
def create
|
11
|
+
enforce_permission_to :assign_to_valuator, :proposals
|
12
|
+
@form = form(Admin::ValuationAssignmentForm).from_params(params)
|
13
|
+
Admin::AssignProposalsToValuator.call(@form) do
|
14
|
+
on(:ok) do |_proposal|
|
15
|
+
flash[:notice] = I18n.t("valuation_assignments.create.success", scope: "decidim.proposals.admin")
|
16
|
+
redirect_to after_add_evaluator_url
|
17
|
+
end
|
18
|
+
|
19
|
+
on(:invalid) do
|
20
|
+
flash.now[:alert] = I18n.t("valuation_assignments.create.invalid", scope: "decidim.proposals.admin")
|
21
|
+
redirect_to after_add_evaluator_url
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def after_add_evaluator_url
|
27
|
+
return request.referer if request.referer.present? && request.referer =~ %r{manage/proposals/[0-9]+}
|
28
|
+
|
29
|
+
EngineRouter.admin_proxy(current_component).root_path
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Templates
|
5
|
+
module Admin
|
6
|
+
module ApplicationControllerOverride
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
def template_types
|
11
|
+
@template_types ||= {
|
12
|
+
I18n.t("template_types.questionnaires", scope: "decidim.templates") => decidim_admin_templates.questionnaire_templates_path,
|
13
|
+
I18n.t("template_types.proposal_answer_templates", scope: "decidim.templates") => decidim_admin_templates.proposal_answer_templates_path
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,11 +6,6 @@ module Decidim
|
|
6
6
|
class ProposalNotesController < Admin::ApplicationController
|
7
7
|
helper_method :note
|
8
8
|
|
9
|
-
def edit
|
10
|
-
enforce_permission_to :edit_note, :proposal_note, proposal_note: note
|
11
|
-
@notes_form = form(Decidim::Proposals::Admin::ProposalNoteForm).from_model(note)
|
12
|
-
end
|
13
|
-
|
14
9
|
def update
|
15
10
|
enforce_permission_to :edit_note, :proposal_note, proposal_note: note
|
16
11
|
@notes_form = form(Decidim::Proposals::Admin::ProposalNoteForm).from_params(params)
|
@@ -27,6 +22,10 @@ module Decidim
|
|
27
22
|
end
|
28
23
|
end
|
29
24
|
|
25
|
+
def current_component
|
26
|
+
note&.proposal&.component
|
27
|
+
end
|
28
|
+
|
30
29
|
private
|
31
30
|
|
32
31
|
def note
|
@@ -0,0 +1,181 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Templates
|
5
|
+
module Admin
|
6
|
+
class ProposalAnswerTemplatesController < Decidim::Templates::Admin::ApplicationController
|
7
|
+
include Decidim::TranslatableAttributes
|
8
|
+
include Decidim::Paginable
|
9
|
+
|
10
|
+
helper_method :availability_option_as_text, :availability_options_for_select
|
11
|
+
|
12
|
+
rescue_from ActiveRecord::RecordNotFound do |exception|
|
13
|
+
if request.xhr?
|
14
|
+
render json: { msg: I18n.t("templates.fetch.error", scope: "decidim.admin"), error: exception.message }, status: :unprocessable_entity
|
15
|
+
else
|
16
|
+
throw exception
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def new
|
21
|
+
enforce_permission_to :create, :template
|
22
|
+
@form = form(ProposalAnswerTemplateForm).instance
|
23
|
+
end
|
24
|
+
|
25
|
+
def edit
|
26
|
+
enforce_permission_to :update, :template, template: template
|
27
|
+
@form = form(ProposalAnswerTemplateForm).from_model(template)
|
28
|
+
end
|
29
|
+
|
30
|
+
def create
|
31
|
+
enforce_permission_to :create, :template
|
32
|
+
|
33
|
+
@form = form(ProposalAnswerTemplateForm).from_params(params)
|
34
|
+
|
35
|
+
CreateProposalAnswerTemplate.call(@form) do
|
36
|
+
on(:ok) do |_template|
|
37
|
+
flash[:notice] = I18n.t("templates.create.success", scope: "decidim.admin")
|
38
|
+
redirect_to proposal_answer_templates_path
|
39
|
+
end
|
40
|
+
|
41
|
+
on(:invalid) do
|
42
|
+
flash.now[:alert] = I18n.t("templates.create.error", scope: "decidim.admin")
|
43
|
+
render :new
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def destroy
|
49
|
+
enforce_permission_to :destroy, :template, template: template
|
50
|
+
|
51
|
+
DestroyTemplate.call(template, current_user) do
|
52
|
+
on(:ok) do
|
53
|
+
flash[:notice] = I18n.t("templates.destroy.success", scope: "decidim.admin")
|
54
|
+
redirect_to action: :index
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def fetch
|
60
|
+
enforce_permission_to :read, :template, template: template
|
61
|
+
|
62
|
+
response_object = {
|
63
|
+
state: template.field_values["internal_state"],
|
64
|
+
template: populate_template_interpolations(proposal)
|
65
|
+
}
|
66
|
+
|
67
|
+
respond_to do |format|
|
68
|
+
format.json do
|
69
|
+
render json: response_object.to_json
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def update
|
75
|
+
enforce_permission_to :update, :template, template: template
|
76
|
+
@form = form(ProposalAnswerTemplateForm).from_params(params)
|
77
|
+
UpdateProposalAnswerTemplate.call(template, @form, current_user) do
|
78
|
+
on(:ok) do |_questionnaire_template|
|
79
|
+
flash[:notice] = I18n.t("templates.update.success", scope: "decidim.admin")
|
80
|
+
redirect_to proposal_answer_templates_path
|
81
|
+
end
|
82
|
+
|
83
|
+
on(:invalid) do |template|
|
84
|
+
@template = template
|
85
|
+
flash.now[:error] = I18n.t("templates.update.error", scope: "decidim.admin")
|
86
|
+
render action: :edit
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def copy
|
92
|
+
enforce_permission_to :copy, :template
|
93
|
+
|
94
|
+
CopyProposalAnswerTemplate.call(template) do
|
95
|
+
on(:ok) do
|
96
|
+
flash[:notice] = I18n.t("templates.copy.success", scope: "decidim.admin")
|
97
|
+
redirect_to action: :index
|
98
|
+
end
|
99
|
+
|
100
|
+
on(:invalid) do
|
101
|
+
flash[:alert] = I18n.t("templates.copy.error", scope: "decidim.admin")
|
102
|
+
redirect_to action: :index
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def index
|
108
|
+
enforce_permission_to :index, :templates
|
109
|
+
@templates = collection
|
110
|
+
|
111
|
+
respond_to do |format|
|
112
|
+
format.html { render :index }
|
113
|
+
format.json do
|
114
|
+
term = params[:term]
|
115
|
+
|
116
|
+
@templates = search(term)
|
117
|
+
|
118
|
+
render json: @templates.map { |t| { value: t.id, label: translated_attribute(t.name) } }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
private
|
124
|
+
|
125
|
+
def populate_template_interpolations(proposal)
|
126
|
+
template.description.map do |row|
|
127
|
+
language = row.first
|
128
|
+
value = row.last
|
129
|
+
value.gsub!("%{organization}", proposal.organization.name)
|
130
|
+
value.gsub!("%{name}", proposal.creator_author.name)
|
131
|
+
value.gsub!("%{admin}", current_user.name)
|
132
|
+
|
133
|
+
[language, value]
|
134
|
+
end.to_h
|
135
|
+
end
|
136
|
+
|
137
|
+
def proposal
|
138
|
+
@proposal ||= Decidim::Proposals::Proposal.find(params[:proposal_id])
|
139
|
+
end
|
140
|
+
|
141
|
+
def availability_option_as_text(template)
|
142
|
+
return unless template.templatable_type
|
143
|
+
|
144
|
+
key = "#{template.templatable_type.demodulize.tableize}-#{template.templatable_id}"
|
145
|
+
avaliablity_options[key].presence || t("templates.missing_resource", scope: "decidim.admin")
|
146
|
+
end
|
147
|
+
|
148
|
+
def availability_options_for_select
|
149
|
+
avaliablity_options.collect { |key, value| [value, key] }.to_a
|
150
|
+
end
|
151
|
+
|
152
|
+
def avaliablity_options
|
153
|
+
@avaliablity_options = {}
|
154
|
+
Decidim::Component.includes(:participatory_space).where(manifest_name: accepted_components)
|
155
|
+
.select { |a| a.participatory_space&.decidim_organization_id == current_organization.id }.each do |component|
|
156
|
+
@avaliablity_options["components-#{component.id}"] = formated_name(component)
|
157
|
+
end
|
158
|
+
global_scope = { "organizations-#{current_organization.id}" => t("global_scope", scope: "decidim.templates.admin.proposal_answer_templates.index") }
|
159
|
+
@avaliablity_options = global_scope.merge(Hash[@avaliablity_options.sort_by { |_, val| val }])
|
160
|
+
end
|
161
|
+
|
162
|
+
def formated_name(component)
|
163
|
+
space_type = t(component.participatory_space.class.name.underscore, scope: "activerecord.models", count: 1)
|
164
|
+
"#{space_type}: #{translated_attribute(component.participatory_space.title)} > #{translated_attribute(component.name)}"
|
165
|
+
end
|
166
|
+
|
167
|
+
def accepted_components
|
168
|
+
[:proposals]
|
169
|
+
end
|
170
|
+
|
171
|
+
def template
|
172
|
+
@template ||= Template.find(params[:id])
|
173
|
+
end
|
174
|
+
|
175
|
+
def collection
|
176
|
+
@collection ||= paginate(current_organization.templates.where(target: :proposal_answer).order(:id))
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module PublishProposalEventOverride
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
def i18n_options
|
10
|
+
return super if author.blank?
|
11
|
+
|
12
|
+
author_path = link_to("@#{author.nickname}", profile_path(author.nickname))
|
13
|
+
author_string = "#{author.name} #{author_path}"
|
14
|
+
super.merge({ author: author_string })
|
15
|
+
resource_admin_url ||= Decidim::ResourceLocatorPresenter.new(resource).admin_url
|
16
|
+
resource_admin_path = link_to(I18n.t(".admin_panel", scope: i18n_scope), resource_admin_url)
|
17
|
+
|
18
|
+
super.merge({ author: author_string, admin_url: resource_admin_path })
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def i18n_scope
|
24
|
+
return super unless participatory_space_event?
|
25
|
+
|
26
|
+
@i18n_scope ||= if extra[:type].to_s == "admin"
|
27
|
+
"decidim.events.proposals.proposal_published_for_admin"
|
28
|
+
else
|
29
|
+
"decidim.events.proposals.proposal_published_for_space"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ReportingProposals
|
5
|
+
module CloseMeetingFormOverride
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
alias_method :map_model_original, :map_model
|
10
|
+
|
11
|
+
def map_model(model)
|
12
|
+
map_model_original(model)
|
13
|
+
self.proposal_ids += model.linked_resources(:reporting_proposals, "proposals_from_meeting").pluck(:id)
|
14
|
+
end
|
15
|
+
|
16
|
+
def proposals
|
17
|
+
@proposals ||= begin
|
18
|
+
proposals_query = Decidim.find_resource_manifest(:proposals).try(:resource_scope, current_component)
|
19
|
+
reporting_proposals_query = Decidim.find_resource_manifest(:reporting_proposals).try(:resource_scope, current_component)
|
20
|
+
(reporting_proposals_query ? proposals_query.or(reporting_proposals_query) : proposals_query)
|
21
|
+
&.where(id: proposal_ids)
|
22
|
+
&.order(title: :asc)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -38,9 +38,7 @@ module Decidim
|
|
38
38
|
|
39
39
|
return unless Decidim::ReportingProposals.use_camera_button.include?(@template.current_component.manifest_name.to_sym)
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
true
|
41
|
+
object_name == :add_photos
|
44
42
|
end
|
45
43
|
end
|
46
44
|
end
|
data/app/forms/concerns/decidim/reporting_proposals/map_included_proposals_for_form_override.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ReportingProposals
|
5
|
+
module MapIncludedProposalsForFormOverride
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
alias_method :map_model_original, :map_model
|
10
|
+
|
11
|
+
def map_model(model)
|
12
|
+
map_model_original(model)
|
13
|
+
self.proposal_ids += model.linked_resources(:reporting_proposals, "included_proposals").pluck(:id)
|
14
|
+
end
|
15
|
+
|
16
|
+
def proposals
|
17
|
+
@proposals ||= begin
|
18
|
+
proposals_query = Decidim.find_resource_manifest(:proposals).try(:resource_scope, current_component)
|
19
|
+
reporting_proposals_query = Decidim.find_resource_manifest(:reporting_proposals).try(:resource_scope, current_component)
|
20
|
+
(reporting_proposals_query ? proposals_query.or(reporting_proposals_query) : proposals_query)
|
21
|
+
&.where(id: proposal_ids)
|
22
|
+
&.order(title: :asc)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/app/forms/concerns/decidim/reporting_proposals/map_related_proposals_for_form_override.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ReportingProposals
|
5
|
+
module MapRelatedProposalsForFormOverride
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
alias_method :map_model_original, :map_model
|
10
|
+
|
11
|
+
def map_model(model)
|
12
|
+
map_model_original(model)
|
13
|
+
self.proposal_ids += model.linked_resources(:reporting_proposals, "related_proposals").pluck(:id)
|
14
|
+
end
|
15
|
+
|
16
|
+
def proposals
|
17
|
+
@proposals ||= begin
|
18
|
+
proposals_query = Decidim.find_resource_manifest(:proposals).try(:resource_scope, current_component)
|
19
|
+
reporting_proposals_query = Decidim.find_resource_manifest(:reporting_proposals).try(:resource_scope, current_component)
|
20
|
+
(reporting_proposals_query ? proposals_query.or(reporting_proposals_query) : proposals_query)
|
21
|
+
&.where(id: proposal_ids)
|
22
|
+
&.order(title: :asc)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Templates
|
5
|
+
module Admin
|
6
|
+
class ProposalAnswerTemplateForm < TemplateForm
|
7
|
+
attribute :internal_state, String
|
8
|
+
attribute :scope_for_availability, String
|
9
|
+
|
10
|
+
validates :internal_state, presence: true
|
11
|
+
|
12
|
+
def map_model(model)
|
13
|
+
self.scope_for_availability = "#{model.templatable_type.try(:demodulize).try(:tableize)}-#{model.templatable_id.to_i}"
|
14
|
+
(model.field_values || []).to_h.map do |k, v|
|
15
|
+
self[k.to_sym] = v
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ReportingProposals
|
5
|
+
module ResourceHelperOverride
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
def linked_resources_for(resource, type, link_name)
|
10
|
+
linked_resources = resource.linked_resources(type, link_name).group_by { |linked_resource| linked_resource.class.name }
|
11
|
+
linked_resources.merge!(resource.linked_resources(:reporting_proposals, link_name).group_by { |linked_resource| linked_resource.class.name }) if type == :proposals
|
12
|
+
|
13
|
+
safe_join(linked_resources.map do |klass, resources|
|
14
|
+
resource_manifest = klass.constantize.resource_manifest
|
15
|
+
content_tag(:div, class: "section") do
|
16
|
+
i18n_name = "#{resource.class.name.demodulize.underscore}_#{resource_manifest.name}"
|
17
|
+
content_tag(:h3, I18n.t(i18n_name, scope: "decidim.resource_links.#{link_name}"), class: "section-heading") +
|
18
|
+
render(partial: resource_manifest.template, locals: { resources: resources })
|
19
|
+
end
|
20
|
+
end)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A custom mailer to mail Decidim users
|
6
|
+
# that they have been hidden
|
7
|
+
class HiddenResourceMailer < Decidim::ApplicationMailer
|
8
|
+
include Decidim::TranslationsHelper
|
9
|
+
include Decidim::SanitizeHelper
|
10
|
+
include Decidim::ApplicationHelper
|
11
|
+
include Decidim::TranslatableAttributes
|
12
|
+
|
13
|
+
helper Decidim::ResourceHelper
|
14
|
+
helper Decidim::TranslationsHelper
|
15
|
+
helper Decidim::ApplicationHelper
|
16
|
+
|
17
|
+
def notify_mail(resource, resource_authors, reason)
|
18
|
+
@resource_authors = resource_authors
|
19
|
+
@organization = resource.organization
|
20
|
+
@resource = resource
|
21
|
+
@reason = reason
|
22
|
+
|
23
|
+
mail(to: resource_authors.pluck(:email).uniq,
|
24
|
+
subject: I18n.t("decidim.admin.hidden_resource_mailer.notify_mail.subject"))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
class NotificationAnswerProposalMailer < Decidim::ApplicationMailer
|
7
|
+
include Decidim::TranslationsHelper
|
8
|
+
include Decidim::SanitizeHelper
|
9
|
+
|
10
|
+
helper Decidim::ResourceHelper
|
11
|
+
helper Decidim::TranslationsHelper
|
12
|
+
|
13
|
+
def notify_proposal_author(proposal, recipient)
|
14
|
+
@proposal = proposal
|
15
|
+
@organization = proposal.organization
|
16
|
+
@recipient = recipient
|
17
|
+
|
18
|
+
with_user(recipient) do
|
19
|
+
mail(to: recipient.email, subject: t("subject", scope: "decidim.reporting_proposals.admin.notification_answer_proposal_mailer.notify_proposal_author"))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
class ProposalsValuatorMailer < Decidim::ApplicationMailer
|
7
|
+
include Decidim::TranslationsHelper
|
8
|
+
include Decidim::SanitizeHelper
|
9
|
+
include Decidim::ApplicationHelper
|
10
|
+
include Decidim::TranslatableAttributes
|
11
|
+
|
12
|
+
helper Decidim::ResourceHelper
|
13
|
+
helper Decidim::TranslationsHelper
|
14
|
+
helper Decidim::ApplicationHelper
|
15
|
+
|
16
|
+
def notify_proposals_valuator(user, admin, proposals)
|
17
|
+
@valuator_user = user
|
18
|
+
@admin = admin
|
19
|
+
@proposals = proposals
|
20
|
+
@organization = user.organization
|
21
|
+
|
22
|
+
with_user(user) do
|
23
|
+
mail to: "#{user.name} <#{user.email}>",
|
24
|
+
subject: t("subject", scope: "decidim.proposals.admin.proposals_valuator_mailer.notify_proposals_valuator")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
class NotificationPublishProposalMailer < Decidim::ApplicationMailer
|
6
|
+
include Decidim::TranslationsHelper
|
7
|
+
include Decidim::SanitizeHelper
|
8
|
+
|
9
|
+
helper Decidim::ResourceHelper
|
10
|
+
helper Decidim::TranslationsHelper
|
11
|
+
|
12
|
+
def notify_proposal_author(proposal, recipient)
|
13
|
+
@proposal = proposal
|
14
|
+
@organization = proposal.organization
|
15
|
+
@recipient = recipient
|
16
|
+
|
17
|
+
with_user(recipient) do
|
18
|
+
mail(to: recipient.email, subject: t("subject", scope: "decidim.reporting_proposals.notification_publish_proposal_mailer.notify_proposal_author"))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ReportedMailerOverride
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
helper Decidim::ComponentPathHelper
|
9
|
+
helper_method :resource_admin_url
|
10
|
+
|
11
|
+
def resource_admin_url
|
12
|
+
@resource_admin_url ||= Decidim::ResourceLocatorPresenter.new(@reportable).admin_url
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -7,8 +7,11 @@ module Decidim
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
+
# it is important to ensure that the aliased method name is unique in case of other modules are doing the same
|
11
|
+
alias_method :decidim_reporting_proposals_original_accepted_components, :accepted_components
|
12
|
+
|
10
13
|
def accepted_components
|
11
|
-
[:
|
14
|
+
decidim_reporting_proposals_original_accepted_components + [:reporting_proposals]
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!-- insert_after "#valuators" -->
|
2
|
+
|
3
|
+
<% if allowed_to? :assign_to_valuator, :proposals %>
|
4
|
+
<div id="js-assign-proposal-to-valuator-actions" class="js-bulk-action-form form-single-proposal"
|
5
|
+
style="max-width:400px">
|
6
|
+
<%= form_tag(valuation_assignment_path, method: :post, id: "js-form-assign-proposal-to-valuator",
|
7
|
+
class: "flex--lc flex-gap--1") do %>
|
8
|
+
<div class="checkboxes hide">
|
9
|
+
<%= check_box_tag "proposal_ids[]", proposal.id, true,
|
10
|
+
class: "js-check-all-proposal js-proposal-id-#{proposal.id}" %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<%= bulk_valuators_select(current_participatory_space, t("decidim.proposals.admin.proposals.index.assign_to_valuator")) %>
|
14
|
+
<%= submit_tag(t("decidim.proposals.admin.proposals.index.assign_to_valuator_button"),
|
15
|
+
id: "js-submit-assign-proposal-to-valuator",
|
16
|
+
class: "button small button--simple float-left") %>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|