Commit Graph

81 Commits

Author SHA1 Message Date
Javi Martín
d18c627392 Add and apply Layout/EmptyLinesAfterModuleInclusion rule
This rule was added in rubocop 1.79. We were inconsistent about it, so
we're adding it to get more consistency.
2025-11-05 14:27:12 +01:00
Javi Martín
c1fbcb4e0f Remove obsolete resource method in controllers
This method was used by controllers using the `Translatable` concern. We
forgot to remove it in commit 71601bd3f.
2024-11-08 15:03:51 +01:00
Javi Martín
2acaa14705 Make it possible to select proposals without JavaScript
This way, when JavaScript hasn't loaded (for whatever reason),
administrators can still use this functionality.
2024-10-25 17:12:47 +02:00
Javi Martín
4a2fc50c76 Use separate actions to select/deselect proposals
This is consistent to what we usually do. Also, we're applying the same
criteria mentioned in commit 72704d776:

> We're also making these actions idempotent, so sending many requests
> to the same action will get the same result, which wasn't the case
> with the `toggle` action. Although it's a low probability case, the
> `toggle` action could result in [selecting a proposal] when trying to
> [deselect] it if someone else has [deselected it] it between the time
> the page loaded and the time the admin clicked on the "[Selected]"
> button.
2024-10-25 17:12:47 +02:00
dependabot[bot]
f4203909db Bump rubocop from 1.56.4 to 1.61.0
This version fixes false negatives for Lint/SymbolConversion when using
string interpolation, for Style/RedundantArgument when using the safe
navigation operator, for Style/RedundantParentheses when logical
operators are involved and for Style/RedundantReturn with lambda ending
with return. We're applying the new rules.

Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.56.4 to 1.61.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.56.4...v1.61.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-02 16:31:10 +02:00
Javi Martín
9d74f06d24 Simplify loading resources in DraftVersionsController
We were using `prepend: true`, but it doesn't seem to be necessary.

We were also loading the draft versions twice in the index, so we can
remove the line loading them a second time.
2023-08-30 14:46:34 +02:00
Javi Martín
5b6de96241 Add and apply MultilineMethodCallIndentation rule 2023-08-18 14:56:16 +02:00
Javi Martín
11832cc07d Make it easier to customize allowed parameters
When customizing CONSUL, one of the most common actions is adding a new
field to a form.

This requires modifying the permitted/allowed parameters. However, in
most cases, the method returning these parameters returned an instance
of `ActionController::Parameters`, so adding more parameters to it
wasn't easy.

So customizing the code required copying the method returning those
parameters and adding the new ones. For example:

```
def something_params
  params.require(:something).permit(
    :one_consul_attribute,
    :another_consul_attribute,
    :my_custom_attribute
  )
end
```

This meant that, if the `something_params` method changed in CONSUL, the
customization of this method had to be updated as well.

So we're extracting the logic returning the parameters to a method which
returns an array. Now this code can be customized without copying the
original method:

```
alias_method :consul_allowed_params, :allowed_params

def allowed_params
  consul_allowed_params + [:my_custom_attribute]
end
```
2022-04-07 19:35:40 +02:00
taitus
ac144d172d Move document attributes to concern 2021-04-09 16:21:00 +02:00
taitus
7fa594e3e3 Rename sdg_related_list to related_sdg_list
To maintain consistency with the current names in the database with fields:
:related_sdg_type and :related_sdg_id
2021-01-26 19:18:11 +01:00
taitus
7d2b940ad9 Add SDG::RelatedListSelectorComponent to Legislation Process
Allow to relate SDG and Targets to Legislation Process
2021-01-22 16:14:50 +01:00
Javi Martín
52d71b8432 Remove unneeded namespace methods
These methods are not necessary since we changed the `namespace` helper
method in commit 13b3d9ceb.
2021-01-12 14:50:36 +01:00
Andrew Sims
5d3748d863 Bugfix: categories are shown on process update
These changes fix a bug that causes categories
of a legislation process to be wiped on update
of the process. It also adds a regression test
for this fix.
2019-11-25 18:45:53 +11:00
Javi Martín
82b0a6a92d Remove new CSV report generation
The new CSV report was more configurable and could work on proposals,
processes and comments. However, it had several issues.

In the public area, by default it generated a blank file.

In the admin section, the report was hard to configure and it generated
a file with less quality than the old system.

So until we improve this system, we're bringing back the old investment
CSV exporter.

This commit reverts most of commit 9d1ca3bf.
2019-11-06 00:04:02 +01: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
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
031b5aba63 Remove unnecessary html_safe in paths
Paths are just regular strings with no HTML, so they don't need to be
marked as safe HTML.
2019-10-08 13:20:22 +02:00
Javi Martín
70a07c095f Add and apply Style/BlockDelimiters rubocop rule
We were already using it most of the time, but there were a few places
were we used brackets for multiline blocks.
2019-10-05 14:44:14 +02:00
Javi Martín
daa86ca3fc Apply Rails/RequestReferer rubocop rule 2019-09-10 21:43:39 +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
German Galia
9ce524e1f3 Create tracker rol 2019-06-12 16:23:40 +02:00
German Galia
9d1ca3bfd4 Report generation. Download csv 2019-06-12 10:17:31 +02:00
Julian Herrero
fb81f45a73 Fix redirect_to :back deprecation warning 2019-04-17 17:40:55 +02:00
Angel Perez
37aa082943 Fix redirect_to deprecation warning on Admin::Legislation::Processes controller 2019-04-17 17:40:55 +02:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
Alberto
f9476eaa6a Merge pull request #3323 from consul/ui-fixes
[Backport] Fix UI details for a better UX and design
2019-02-20 14:37:46 +01:00
decabeza
0d834744fd Replace open to active filter on admin legislation processes index
Now active filter show open processes and the next ones, processes with a start date greather than current date.
2019-02-20 13:32:09 +01:00
Javi Martín
af9a2179eb Reuse image attributes in legislation processes
It wasn't originally added because at the time legislation processes
didn't have images.
2019-02-19 19:57:27 +01:00
decabeza
33fabe18b8 Remove admin legislation processes past filter 2019-02-08 14:30:08 +01:00
decabeza
060a4c684f Remove legislation processes next filter 2019-02-08 14:29:43 +01:00
Julian Nicolas Herrero
81b65ec821 Merge pull request #3202 from consul/sort_legislation_processes_by_start_date
Sort Legislation Processes by descending start date
2019-01-29 17:30:02 +01:00
Alberto
c297595e49 Merge branch 'master' into add_image_to_legislation_processes 2019-01-28 14:49:19 +01:00
Julian Herrero
33d6f6c18d Sort Legislation Processes by descending start date 2019-01-22 18:51:22 +01:00
Manu
bd4e12112d Add image to legislation processes and banner colors 2019-01-21 12:02:27 -05:00
Javi Martín
c5d32c5ab9 Manage progress bars in the admin area 2019-01-18 14:17:33 +01:00
dperez
bef404c443 add homepage for legislation processes 2018-12-15 18:04:24 +01:00
Javi Martín
03dc43a500 Manage legislation process milestones 2018-12-11 20:18:53 +01:00
João Lutz
34b58a5208 Adds draft phase functionality in legislation processes 2018-11-19 22:18:50 -02:00
Javi Martín
f1ccdb87b1 Fix removing an option for legislation questions
We were allowing the `_destroy` field for translations, but not for the
options themselves.
2018-10-22 16:36:17 +02:00
Javi Martín
6952c9c9db Fix legislation options not being updated
We broke this behaviour by introducing translations and not allowing the
`id` parameter anymore.
2018-10-22 16:36:17 +02:00
Javi Martín
85701bd754 Update legislation questions translatable fields 2018-10-22 15:46:24 +02:00
Javi Martín
5bfc7ca2e3 Update legislation process translatable fields 2018-10-22 15:46:16 +02:00
Javi Martín
6278175f57 Update legislation drafts translatable fields
Updating it required reorganizing the form so translatable fields are
together.

We also needed to add a `hint` option to the form label and input
methods so the hint wouldn't show up for every language.

Finally, the markdown editor needed to use the same globalize attributes
as inputs, labels and hints, which adds a bit of duplication.
2018-10-22 15:44:14 +02:00
Javi Martín
9352585e14 Ease customization in processes controller
By extracting a method just for the allowed parameters, forks can
customize this method by reopening the class.
2018-10-18 16:52:40 +02:00
Javi Martín
2fb5fb5fb2 Add missing newline characters 2018-10-04 16:31:00 +02:00
Javi Martín
ec2b4fe7ff Use %w[] instead of %w{}
As agreed when discussing our rubocop rules.
2018-10-04 16:30:59 +02:00
Javi Martín
75d1ab1e52 Use AJAX requests to select legislation proposals
Now the interface is more similar to the one in budget investments.
2018-10-04 16:29:01 +02:00
Javi Martín
667c2c82b5 Use toggle_select action for legislation proposals
The `update` action is usually expected to behave the same way it does
everywhere else, which is updating a record using the `params` hash.

The name `toggle_select` comes from the name we use in a similar
situation for budget investments.
2018-10-04 16:29:01 +02:00
Raúl Fuentes
05340e423c Add select to Legislation::Proposals
Add admin interface for mark any proposal as selected
Add filter to public interface for selected proposals
2018-10-04 16:28:56 +02:00