Commit Graph

46 Commits

Author SHA1 Message Date
Julian Herrero
dcad390933 Ability to attach an image to budgets
Co-authored-by: decabeza <alberto@decabeza.es>
2021-06-09 21:33:08 +02:00
decabeza
d78f2e03ad Render link to budget header
- Allow to define a link (text and url) on budget form for render on the budget
header.
- Improve styles

Co-authored-by: Senén Rodero Rodríguez <senenrodero@gmail.com>
2021-06-09 19:16:55 +02:00
Julian Herrero
2115eb5274 Allow creating budgets step by step
We introduce the first step (creating the budget).

Co-Authored-By: decabeza <alberto@decabeza.es>
2021-06-08 14:25:44 +02:00
Javi Martín
82e8de094b Extract budget form to a component
This way it will be easier to change it and reuse it.
2021-06-08 14:25:43 +02:00
decabeza
4ff8162a2e Add filter to show all budgets in admin 2021-02-23 18:39:45 +01:00
Julian Herrero
28caabecdf Refactor participatory budgets in draft mode
Previously the draft mode was a phase of the PB, but that had some
limitations.

Now the phase drafting disappears and therefore the PB can have the
status published or not published (in draft mode).

That will give more flexibility in order to navigate through the
different phases and see how it looks for administrators before
publishing the PB and everybody can see.

By default, the PB is always created in draft mode, so it gives you
the flexibility to adjust and modify anything before publishing it.
2021-02-23 17:05:24 +01:00
Julian Herrero
0b2b8b557d Fix staff not being loaded after creating budget 2021-02-23 16:28:00 +01:00
Ziyan Junaideen
1e3e8c1304 Add approval voting to budgets
Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-08-06 12:38:18 +02:00
Javi Martín
ac6d50e06b Remove tracker role
The current tracking section had a few issues:

* When browsing as an admin, this section becomes useless since no
investments are shown
* Browsing investments in the admin section, you're suddenly redirected
to the tracking section, making navigation confusing
* One test related to the officing dashboard failed due to these changes
and had been commented
* Several views and controller methods were copied from other sections,
leading to duplication and making the code harder to maintain
* Tracking routes were defined for proposals and legislation processes,
but in the tracking section only investments were shown
* Probably many more things, since these issues were detected after only
an hour reviewing and testing the code

So we're removing this untested section before releasing version 1.1. We
might add it back afterwards.
2019-11-01 20:08:46 +01:00
Javi Martín
62c4d41af4 Remove unused budget attributes
Tags and help links can be edited, but aren't used anywhere. Since we
don't know what the intended behavior was, I'm removing them for now.

My best guess is tags were supposed to be used so investments for a
budget can only be assigned tags present in the budget. Achieving that
behavior wouldn't be a trivial task.
2019-11-01 17:12:42 +01:00
Javi Martín
20001824e5 Use acts_as_taggable for budget tags
We were adding columns to the budgets table instead of using the same
logic we use everywhere else.
2019-11-01 17:12:42 +01:00
Javi Martín
483c75fb82 Extract methods to load budget staff 2019-11-01 16:49:14 +01:00
Javi Martín
458cffe50b Remove redundant .all calls 2019-11-01 16:49:14 +01:00
Javi Martín
6c323eaf3e Use JavaScript pluralize for budget staff
We were using two different systems to set translations in JavaScript:
to set the text for languages, we were using data attributes, and to set
the text for staff members, we were using AJAX calls.

I find data attributes keep the code more simple, since there's no need
to define an extra route and controller action. Furthermore, the user
experience is better because response times are faster.

So now both places use data attributes.
2019-10-31 16:21:39 +01:00
Javi Martín
d0d681a44b Add and apply EmptyLineAfterGuardClause rule
We were inconsistent on this one. I consider it particularly useful when
a method starts with a `return` statement.

In other cases, we probably shouldn't have a guard rule in the middle of
a method in any case, but that's a different refactoring.
2019-10-24 17:56:03 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Javi Martín
7ca55c44e0 Apply Rails/SaveBang rubocop rule
Having exceptions is better than having silent bugs.

There are a few methods I've kept the same way they were.

The `RelatedContentScore#score_with_opposite` method is a bit peculiar:
it creates scores for both itself and the opposite related content,
which means the opposite related content will try to create the same
scores as well.

We've already got a test to check `Budget::Ballot#add_investment` when
creating a line fails ("Edge case voting a non-elegible investment").

Finally, the method `User#send_oauth_confirmation_instructions` doesn't
update the record when the email address isn't already present, leading
to the test "Try to register with the email of an already existing user,
when an unconfirmed email was provided by oauth" fo fail if we raise an
exception for an invalid user. That's because updating a user's email
doesn't update the database automatically, but instead a confirmation
email is sent.

There are also a few false positives for classes which don't have bang
methods (like the GraphQL classes) or destroying attachments.

For these reasons, I'm adding the rule with a "Refactor" severity,
meaning it's a rule we can break if necessary.
2019-10-23 14:39:31 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
b5b07bccd3 Apply PercentLiteralDelimiters rubocop rule 2019-09-10 20:02:15 +02:00
German Galia
74083df10f Add historic fields to participatory budget 2019-06-12 18:03:53 +02:00
Julian Herrero
b122302c58 Use find instead of find_by_id
Better raise a 404 HTML NotFound exception than any other unexpected error.
2019-06-03 17:54:19 +02:00
rgarcia
998b4d9e39 Load budgets using slugs 2019-06-03 16:54:39 +02:00
Javi Martín
4f4dc2c2af Add show results and stats form to budgets 2019-05-22 11:50:03 +02:00
Javi Martín
1b323383a8 Don't destroy budgets with an associated poll
We were getting an exception due to foreign key database violations.
2019-05-13 13:44:58 +02:00
lalo
237a03552f Move admin budget investments tabs filters to advanced filters component 2019-04-03 22:27:48 +02:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
Julian Herrero
d76782f150 Make budgets translatable 2019-02-13 11:41:58 +01:00
Julian Herrero
6439be44f1 change CRUD for budget groups and headings
To make it more consistent with the rest of the Admin panel,
the CRUD for budget groups and headings has been changed
from the old "all-in-one" form to a separate form for each resource.
2018-12-14 16:34:54 +01:00
BertoCQ
d44db9cec4 Merge branch 'master' into feature/budget_phases 2018-01-16 17:47:47 +01:00
Bertocq
66691b644a Refactor Budget::PHASES constant to Budget::Phase::PHASE_KINDS 2018-01-16 12:18:13 +01:00
rgarcia
349780922d Add Budget.open scope
Before Budget.current could return multiple budgets, now there can only
be a single current_budget.

Adding the concept of open, which better reflects what the admin sees
in this page: A tab for open budgets and a tab for finished budgets
2018-01-15 22:01:59 +01:00
BertoCQ
6e96c8c057 Merge branch 'master' into feature/2275#destroy_budgets 2018-01-09 11:03:51 +01:00
Bertocq
03e1481fb1 Redirect admin to budget lists after editing a budget 2018-01-08 18:47:09 +01:00
Bertocq
799b96cc40 Add destroy action to admin budget controller 2018-01-08 18:21:45 +01:00
Bertocq
efacd0def3 Make calculate_winners explicitly delayed
Why:

* As seen on preproduction and production environments on Madrid's fork. Budget::Result#calculate_winners is very costly when done to all headings for a given budget (as requested on Admin::BudgetsController#calculate_winners) but its not when done individually for only a heading (as requested on Budget::Investment#recalculate_heading_winners)

How:

* Removing `handle_asynchronously :calculate_winners` from bellow Budget::Result#calculate_winners definition, to avoid making any call delayed. And explicitly calling `.delay` only when needed (on Admin::BudgetsController#calculate_winners)
2017-07-10 15:12:14 +02:00
Bertocq
154cdac332 Add calculate_winners on Admin Budget controller, route and ability for admins 2017-06-25 15:47:04 +02:00
kikito
9e4b2fda89 Adds phases to form 2017-01-01 15:03:58 +01:00
kikito
34ee8c1c48 Makes Budgets editable, and makes their description editable with html 2016-12-29 16:21:42 +01:00
kikito
2f446cf056 Renames "open" to "current" to avoid issues with existing method called "open" 2016-12-13 12:39:53 +01:00
Juanjo Bazán
2d56415048 adds feature flag for admin/budgets management 2016-09-07 15:13:39 +02:00
Juanjo Bazán
0f7e23bec4 adds budget's groups & headings to admin 2016-08-03 20:23:41 +02:00
Juanjo Bazán
724ccf175c adds budget show to admin 2016-07-29 14:52:37 +02:00
Juanjo Bazán
49bc6533e8 adds explicit permission to admin to read budgets 2016-07-29 13:39:08 +02:00
Juanjo Bazán
6fce9df451 adds admin creation of budgets 2016-07-29 13:34:41 +02:00
Alberto Garcia Cabeza
b69308b770 Adds example content for admin budget new 2016-07-28 13:04:30 +02:00
Juanjo Bazán
1ad78d599e adds admin budgets index 2016-07-28 12:36:39 +02:00