Open decabeza opened 2 years ago
The whole user segmentation part of consul probably needs an overhaul. It would be good to be able to select user segments when restricting access to processes not just based on Geozones.
I have a version of the user segments code which will show user segments for all of the open PB processes instead of the current one. That way you can select which open PB you want to email/download emails
As I type this I am thinking it might be good to have a segment which is All Open Budgets.......
I haven't fully tested it yet but it just requires some small changes to user_segments and some updates to the corresponding translations
class UserSegments
def self.segments
static_segments + budget_segments
end
def self.segment_name(segment)
if budget_segment?(segment)
budget_segment_name(segment)
elsif geozones[segment.to_s]
"Geozone: geozones[segment.to_s]&.name"
else
I18n.t("admin.segment_recipient.#{segment}", default: segment.to_s.humanize) if valid_segment?(segment)
end
end
and then define
private
def self.static_segments
%w[all_users
administrators
] + geozones.keys.map { |geozone| "geozone: #{geozone}" }
end
def self.budget_segments
open_budgets.map do |budget|
%W[
#{budget.name}_all_proposal_authors
#{budget.name}_proposal_authors
#{budget.name}_investment_authors
#{budget.name}_feasible_and_undecided_investment_authors
#{budget.name}_selected_investment_authors
#{budget.name}_winner_investment_authors
]
end.flatten
end
def self.open_budgets
Budget.where.not(phase: "finished").order(created_at: :desc).limit(2)
end
def self.budget_segment?(segment)
open_budgets.any? { |budget| segment.start_with?(budget.name) }
end
The corresponding locale file looks like this
segment_recipient:
all_users: All users
administrators: Administrators
all_proposal_authors: "Proposal authors (including archived and withdrawn)for PB: %{budget_name}"
proposal_authors: "Proposal authors for PB: %{budget_name}"
investment_authors: "Investment authors for PB: %{budget_name}"
feasible_and_undecided_investment_authors: "Authors of proposals in PB: %{budget_name} that do not comply with: [valuation finished unfeasible]"
selected_investment_authors: "Authors of selected investments in PB: %{budget_name}"
winner_investment_authors: "Authors of winner investments in the PB: %{budget_name}"
not_supported_on_current_budget: "Users that haven't supported investments in PB: %{budget_name}"
invalid_recipients_segment: "Recipients user segment is invalid"
geozone: "Geozone"
I haven't made a PR for this but it is maybe an improvement on what we have now?
Description
🗒️ This issue is related with https://github.com/consul/consul/issues/4991
Currently, Administrators can download users emails from
/admin/emails_download
, and select the email addresses list to download.There are several lists related to participatory budgets:
All of them refer to the "current budget", i.e. the last one created. But since CONSUL allows to have several active participatory budgets simultaneously. It should allow the administrator to select to which budget the user list corresponds.
Current Behavior
Expected Behavior
When selecting a list related to participatory budgets, a new select form with all participatory budgets should be displayed to select one.