Commit Graph

17267 Commits

Author SHA1 Message Date
Javi Martín
f487e9f0d0 Reorganize gitignore file
So it's easier to follow.
2022-04-06 14:19:55 +02:00
Javi Martín
fc70ba3db5 Define paths in gitignore in a consistent way
We used a slash as a prefix in some cases but not in other cases. Now
we're defining files and folders following the gitignore rules: files
starting with a slash are only ignored in the root folder, while files
not starting with it are ignored everywhere.

IMHO it makes sense to ignore all folders named `tmp`, `.bundle`, `log`,
`.DS_Store` or `.ruby-gemset` everywhere in the source code and not only
in the root folder.

We're also adding a trailing slash to all folders for consistency.
2022-04-06 14:19:55 +02:00
Javi Martín
f5152179e1 Remove references to IDEA files in gitignore
We can't cover the files for every editor out there, so we're removing
it in the name of neutrality. Developers using this editor to work with
CONSUL can add the `.idea` to their global gitignore configuration (on
GNU/Linux systems, for instance, the `~/.config/git/ignore` file).
2022-04-06 14:19:55 +02:00
Javi Martín
e98dc0923c Remove reference to beta testers file in gitignore
This feature was removed in commit 1e0ac137bb.
2022-04-06 14:19:55 +02:00
Javi Martín
1a880815dc Remove references to SQLite files in gitignore
We don't use SQLite and we don't support it, so these files shouldn't
exist in the first place.
2022-04-06 14:19:55 +02:00
Sebastia
fbc74e8d46 Merge pull request #4800 from consul/checkbox_label_styles
Fix checkbox label styles
2022-04-04 20:09:15 +02:00
taitus
923c2a7ee2 Check labels styles
We are use a display: block style for labels containing check boxes inside
them, and the label has a width of 100%.

This means that clicking on the blank space on the right of the label text
will check/uncheck the checkbox. To avoid this behaviour we modify the
"display" attribute of the labels.

In order to prevent unexpected behaviour in terms_of_service form labels,
we add specific css for this case when define a checkbox within the
.actions class.
2022-04-04 18:55:56 +02:00
Sebastia
e2728f6eb6 Merge pull request #4769 from consul/assigned_heading
Show assigned heading on investment show
2022-03-31 17:20:50 +02:00
Julian Herrero
0c9a46221e Show assigned heading on investment show 2022-03-31 17:00:24 +02:00
taitus
78ab37db09 Reduce duplicated lines on :investments method
This way we also create a new method :investments_with_filters that
we can call to retrieve the investments when we have not a @current_order.
2022-03-31 17:00:23 +02:00
taitus
8945058a65 Extract the load_map logic from the :load_heading callback
Create a new callback for load_map. In this way we simplify a bit the logic of
:load_heading callback and unify the logic of the map loading.
2022-03-31 17:00:23 +02:00
Javi Martín
5675997a7e Merge pull request #4799 from consul/dependabot/bundler/puma-4.3.12
Bump puma from 4.3.11 to 4.3.12
2022-03-31 13:52:38 +02:00
dependabot[bot]
b2294460c4 Bump puma from 4.3.11 to 4.3.12
Bumps [puma](https://github.com/puma/puma) from 4.3.11 to 4.3.12.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v4.3.11...v4.3.12)

---
updated-dependencies:
- dependency-name: puma
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-31 13:10:59 +02:00
Senén Rodero
3ecf2feb2e Merge pull request #4601 from consul/budgets_hide_money
Add hide money option for approval budgets
2022-03-30 09:58:29 +02:00
decabeza
50e00a096b Update investments order when hide_money is active 2022-03-29 14:49:30 +02:00
decabeza
8c3b222c98 Manage the render of the price field on valuation investments section 2022-03-29 14:49:29 +02:00
decabeza
4c0499d53b Manage the render of the price field on budgets results section 2022-03-29 14:49:28 +02:00
decabeza
5d475e6401 Manage the render of the price field on budgets ballot section 2022-03-29 14:49:28 +02:00
decabeza
abc4e9dca1 Manage the render of the price field on public investment section 2022-03-29 14:49:27 +02:00
decabeza
40bdd1f03a Manage the render of the price field on admin investments section 2022-03-29 14:49:27 +02:00
decabeza
2c16bac5f8 Manage the render of the price field on public budget headings 2022-03-29 14:49:26 +02:00
decabeza
9fb5019f0f Manage the render of the price field on admin budget headings
Avoid displaying the price in admin budget headings section
and avoid fill the field 'price' in admin budget headings form
when the budget has been checked with hide_money field.
2022-03-29 14:49:26 +02:00
decabeza
80e64590b7 Allow enable 'hide_money' check on admin budget form
Add new 'hide_money' field to admin budget form.

Only display new field 'hide_money' when voting style is 'approval'
2022-03-29 14:49:25 +02:00
Javi Martín
f4887089bd Merge pull request #4791 from consul/label_with_interpolation
Fix crash on attributes with interpolation arguments
2022-03-28 19:09:09 +02:00
Javi Martín
1fa05b1f54 Fix crash on attributes with interpolation arguments
The application crashed when we generated hints to attributes with
interpolation arguments in their `human_attribute_name`.

When generating the hint, we used the `custom_label` method to generate
a label and get the `for` attribute and, since we weren't passing a
text, it used the default human attribute name for the field. However,
it crashes if the default attribute name requires an interpolation
argument.

So now, since we were only using the `custom_label` method in order to
get the `for` attribute, we're simply passing an arbitrary text to the
method.
2022-03-28 14:55:42 +02:00
taitus
d719b2291e Do not generate an empty hint element when there's an empty hint 2022-03-28 14:55:42 +02:00
Javi Martín
ab0572f32a Merge pull request #4792 from consul/fix_skip_validation_test
Avoid model inheritance in skip validation test
2022-03-26 19:09:03 +01:00
Javi Martín
df2b3f2ee7 Avoid model inheritance in skip validation test
One of these tests was failing sometimes on Github Actions. It looked
like the line `custom_banner.save!` was using the validations from the
Banner class sometimes, even if the callbacks had correctly been
removed in the DummyBanner class.

Se we're inheriting from ApplicationRecord instead of inheriting from
Banner. Since I couldn't reproduce the issue locally after running the
test hundreds of times and with the same seed and tests that were
running on Github Actions, there's a change this won't work. I've tested
a few times on Github Actions and it seems to be working, but we'll have
to keep an eye on it.
2022-03-25 20:25:34 +01:00
Javi Martín
4102a4ad6c Merge pull request #4790 from consul/custom_validations
Make it easier to customize validations
2022-03-24 19:49:40 +01:00
Javi Martín
b5a4609b56 Make it easier to customize validations
There are CONSUL installations where the validations CONSUL offers by
default don't make sense because they're using a different business
logic. Removing these validations in a custom model was hard, and that's
why in many cases modifying the original CONSUL models was an easier
solution.

Since modifying the original CONSUL models makes the code harder to
maintain, we're now providing a way to easily skip validations in a
custom model. For example, in order to skip the price presence
validation in the Budget::Heading model, we could write a model in
`app/models/custom/budget/heading.rb`:

```
require_dependency Rails.root.join("app", "models", "budget", "heading").to_s

class Budget::Heading
  skip_validation :price, :presence
end
```

In order to skip validation on translatable attributes (defined with
`validates_translation`), we have to use the
`skip_translation_validation` method; for example, to skip the proposal
title presence validation:

```
require_dependency Rails.root.join("app", "models", "proposal").to_s

class Proposal
  skip_translation_validation :title, :presence
end

```

Co-Authored-By: taitus <sebastia.roig@gmail.com>
2022-03-24 17:05:35 +01:00
Javi Martín
12460c2000 Merge pull request #4789 from consul/rails_6.0_compatibility
Add Rails 6.0 compatibility
2022-03-23 14:14:11 +01:00
Javi Martín
f6c4d70d78 Merge pull request #4775 from jorgebg/call_verify_ballots_after_create
Add offline ballot sheet votes to the total vote count
2022-03-22 19:17:36 +01:00
Sebastia
c861a1c44b Merge pull request #4787 from consul/custom_constants
Make it easier to customise model constants
2022-03-22 17:47:25 +01:00
taitus
ecde8c6439 Add lambda to the validations that use model constants
In this way when we need modify the constants model value in the
model/custom folder, adding lambda it will be possible load the new
values.
2022-03-22 15:52:36 +01:00
Javi Martín
3f84ab0758 Add test case for adding budget poll results
While writing the test, we noticed it didn't work because the labels
weren't correctly generated, so we're fixing them as well.
2022-03-21 21:33:07 +01:00
Javi Martín
dba68c2c04 Fix deprecation warning in Tagging monkey patch
We were getting a warning in Rails 6.0:

DEPRECATION WARNING: Class level methods will no longer inherit scoping
from `public_for_api` in Rails 6.1. To continue using the scoped
relation, pass it into the block directly. To instead access the full
set of models, as Rails 6.1 will, use
`ActsAsTaggableOn::Tag.default_scoped`.
2022-03-21 20:43:50 +01:00
Javi Martín
2e863fdc51 Fix OR condition in public taggings
In SQL, conditions like:

```
tag_id IN (x) AND taggable_type='Debate' OR taggable_type='Proposal'
```

Don't work as intended; we need to write:

```
tag_id IN (x) AND (taggable_type='Debate' OR taggable_type='Proposal')
```

Due to this bug, we were returning taggings for proposals without
intending to do so.

Since the code was very hard to read, we're also simplifying it.
2022-03-21 20:43:50 +01:00
Javi Martín
effd646e54 Update the way we create form builders in tests
We were getting a warning in Rails 6:

DEPRECATION WARNING: ActionView::Base instances should be constructed
with a lookup context, assignments, and a controller.
2022-03-21 20:43:50 +01:00
Javi Martín
94d4e1db1e Use render template: instead of render file:
We did a similar change in commit 47925fbab, and we were getting a
warning in Rails 6.0:

DEPRECATION WARNING: render file: should be given the absolute path to a
file

Since using `render file:` would ignore views in custom folders, we're
using `render template:` instead.
2022-03-21 20:43:50 +01:00
Javi Martín
9c95735534 Remove invalid key in before_destroy
The `only:` key does not apply to model callbacks. It was added in commit 1077e25b2, probably by accident.

Using this key raises an error in Rails 6.0.
2022-03-21 20:43:50 +01:00
Jorge Barata
b507acb38b Add ballot sheet votes to the total count 2022-03-21 20:33:13 +01:00
Javi Martín
5928f467f3 Merge pull request #4788 from consul/custom_javascript
Make it easier to customize JavaScript functions
2022-03-21 16:37:06 +01:00
Javi Martín
ea026dbe5e Require custom JavaScript after everything else
This way we make sure the custom JavaScript will overwrite anything in
the original code.
2022-03-18 17:20:33 +01:00
Javi Martín
95c1999cca Make it easier to customize JavaScript functions
When there was a custom JavaScript file, we weren't loading the original
one, meaning that, in order to customize it, it was necessary to copy
the whole original file and then changing it.

Now we're loading both the original and the custom file, so the custom
file can simply add more functions or overwrite the ones we'd like to
customize, without copying the whole file.

Existing copies of original files will still overwrite the whole file
and won't be affected.
2022-03-18 16:43:14 +01:00
Javi Martín
9b76a5a19e Merge pull request #4784 from consul/bump_active_storage_to_5.2.6.3
Bump rails from 5.2.6 to 5.2.7
2022-03-16 20:52:30 +01:00
Javi Martín
7ce263efd6 Bump rails from 5.2.6 to 5.2.7
This version solves a security issue in Active Storage; we're including
it even if most probably no CONSUL applications are affected:

https://discuss.rubyonrails.org/t/cve-2022-21831-possible-code-injection-vulnerability-in-rails-active-storage/80199
2022-03-16 20:34:13 +01:00
Javi Martín
8c7091612e Merge pull request #4783 from consul/dependabot/bundler/view_component-2.49.1
Bump view_component from 2.37.0 to 2.49.1
2022-03-04 13:10:34 +01:00
Javi Martín
15d9b88978 Use with_request_url with query params in specs
Support for query params in component specs was added in ViewComponent
2.41.0.
2022-03-04 12:54:47 +01:00
dependabot[bot]
dc0c5c1da0 Bump view_component from 2.37.0 to 2.49.1
Note we don't require the "view_component/engine" in the Gemfile
anymore, since it's been deprecated since ViewComponent 2.46.0.

Bumps [view_component](https://github.com/github/view_component) from 2.37.0 to 2.49.1.
- [Release notes](https://github.com/github/view_component/releases)
- [Changelog](https://github.com/github/view_component/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/github/view_component/compare/v2.37.0...v2.49.1)

---
updated-dependencies:
- dependency-name: view_component
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-04 12:53:58 +01:00
Javi Martín
999ae6fb16 Merge pull request #4782 from trendspotter/sdg_cs
Add cs icon of SDGs
2022-03-01 23:00:29 +01:00