-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add historic fields to participatory budget #3514
Add historic fields to participatory budget #3514
Conversation
feature "Tracking budgets" do | ||
|
||
background do | ||
@tracker = create(:tracker, user: create(:user, username: "Rachel", email: "rachel@trackers.org")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [102/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
end | ||
|
||
scenario "edit" do | ||
primary_progress_bar = create(:progress_bar, progressable: investment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/UselessAssignment: Useless assignment to variable - primary_progress_bar. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
end | ||
|
||
scenario "delete" do | ||
primary_progress_bar = create(:progress_bar, progressable: investment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/UselessAssignment: Useless assignment to variable - primary_progress_bar. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
investment2 = create(:budget_investment, | ||
budget: budget, title: "investment 2", | ||
heading: create(:budget_heading, name: "last_heading")) | ||
investment3 = create(:budget_investment, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/UselessAssignment: Useless assignment to variable - investment3. Did you mean investment1? (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
@@ -2,6 +2,9 @@ | |||
|
|||
<%= translatable_form_for [:admin, @budget] do |f| %> | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line detected.
app/models/budget.rb
Outdated
has_many :budget_valuators | ||
has_many :valuators, through: :budget_valuators | ||
# has_many :administrators, -> { where rol: "Administrator" }, through: :budget_rol_assignments, source: :user | ||
# has_many :valuators, -> { where rol: "Valuators" }, through: :budget_rol_assignments, source: :user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [103/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
app/models/budget.rb
Outdated
has_many :administrators, through: :budget_administrators | ||
has_many :budget_valuators | ||
has_many :valuators, through: :budget_valuators | ||
# has_many :administrators, -> { where rol: "Administrator" }, through: :budget_rol_assignments, source: :user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [112/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
app/models/abilities/tracker.rb
Outdated
include CanCan::Ability | ||
|
||
def initialize(user) | ||
tracker = user.tracker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/UselessAssignment: Useless assignment to variable - tracker. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
@@ -60,7 +60,7 @@ def initialize(user) | |||
can :manage, Dashboard::Action | |||
|
|||
can [:read, :update, :valuate, :destroy, :summary], SpendingProposal | |||
can [:index, :read, :new, :create, :update, :destroy, :calculate_winners], Budget | |||
can [:index, :read, :new, :create, :update, :destroy, :calculate_winners, :assigned_users_translation], Budget |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [116/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
app/helpers/users_helper.rb
Outdated
def show_admin_menu?(user = nil) | ||
current_administrator? || current_moderator? || current_valuator? || current_manager? || (user && user.administrator?) | ||
current_administrator? || current_moderator? || current_valuator? || current_manager? || current_tracker? || (user && user.administrator?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [142/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
tracker_count = $(".js-budget-list-checkbox-trackers:checkbox:checked").length | ||
budget = $(".js-budget-id").attr("id") | ||
url = "/admin/budgets/" + budget + "/assigned_users_translation.json" | ||
params = {administrators: admin_count, valuators: valuator_count, trackers: tracker_count} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curly braces must have the proper spacing. There should be 1 space inside "{".
Curly braces must have the proper spacing. There should be 1 space inside "}".
@@ -0,0 +1,25 @@ | |||
App.BudgetEditAssociations = | |||
|
|||
set_text: (response)-> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function arrows (-> and =>) must be spaced properly.
|
||
def investment_milestone_tags_select_options(budget) | ||
tags = Budget::Investment.by_budget(budget).tags_on(:milestone).order(:name).pluck(:name) | ||
tags = tags.concat budget.budget_milestone_tags.split(",") if budget.budget_milestone_tags.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [103/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
@@ -54,7 +54,15 @@ def current_ballot | |||
end | |||
|
|||
def investment_tags_select_options(budget) | |||
Budget::Investment.by_budget(budget).tags_on(:valuation).order(:name).select(:name).distinct | |||
tags = Budget::Investment.by_budget(budget).tags_on(:valuation).order(:name).pluck(:name) | |||
tags = tags.concat budget.budget_valuation_tags.split(",") if budget.budget_valuation_tags.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [103/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
private | ||
|
||
def verify_tracker | ||
raise CanCan::AccessDenied unless current_user.try(:tracker?) || current_user.try(:administrator?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [104/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
@@ -57,12 +69,39 @@ def destroy | |||
end | |||
end | |||
|
|||
def assigned_users_translation | |||
render json: { administrators: t("admin.budgets.edit.administrators", count: params[:administrators].to_i), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [111/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
@@ -122,6 +127,7 @@ def self.scoped_filter(params, current_filter) | |||
params[:max_total_supports]) if params[:max_total_supports].present? | |||
results = results.where(group_id: params[:group_id]) if params[:group_id].present? | |||
results = results.by_tag(params[:tag_name]) if params[:tag_name].present? | |||
results = results.by_tag(params[:milestone_tag_name]) if params[:milestone_tag_name].present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [114/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
@@ -59,7 +59,7 @@ def initialize(user) | |||
|
|||
can :manage, Dashboard::Action | |||
|
|||
can [:index, :read, :new, :create, :update, :destroy, :calculate_winners], Budget | |||
can [:index, :read, :new, :create, :update, :destroy, :calculate_winners, :assigned_users_translation], Budget |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [116/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
@@ -58,12 +70,39 @@ def destroy | |||
end | |||
end | |||
|
|||
def assigned_users_translation | |||
render json: { administrators: t("admin.budgets.edit.administrators", count: params[:administrators].to_i), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [111/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
References
#3481
Objectives
To be able to have diferent settings in diferent budgets.
Administrators will be able to set which administrators, valuators and trackers will be able to be assigned to budget investments.
Valuation and milestone default tags can also be added.
The help link could also be edited.
Visual Changes
Edit budget:
Select administrators:
Select trackers:
There are no trackers in the system:
Valuators tags:
Notes
Migrations are needed to add assignments tables, between users and budgets, and add new fields to budgets.