Skip to content
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

Merged
merged 1 commit into from
Jun 12, 2019
Merged

Add historic fields to participatory budget #3514

merged 1 commit into from
Jun 12, 2019

Conversation

Germangalia
Copy link
Contributor

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:

Screenshot from 2019-05-20 17-52-38

Screenshot from 2019-05-20 17-52-49

Select administrators:

Screenshot from 2019-05-20 17-53-20

Select trackers:

Screenshot from 2019-05-20 17-55-18

There are no trackers in the system:

Screenshot from 2019-05-20 18-11-10

Valuators tags:

Screenshot from 2019-05-20 18-11-50

Notes

Migrations are needed to add assignments tables, between users and budgets, and add new fields to budgets.

feature "Tracking budgets" do

background do
@tracker = create(:tracker, user: create(:user, username: "Rachel", email: "rachel@trackers.org"))

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)

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)

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,

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| %>


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra blank line detected.

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

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)

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

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)

include CanCan::Ability

def initialize(user)
tracker = user.tracker

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

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)

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?)

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}

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)->

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?

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?

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?)

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),

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?

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

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),

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Roadmap
  
Release 1.1.0
Development

Successfully merging this pull request may close these issues.

None yet

3 participants