Commit Graph

210 Commits

Author SHA1 Message Date
Javi Martín
efd8f47596 Add and apply ArrayCoercion rubocop rule
This rule was added in Rubocop 0.88.0.
2020-10-23 12:01:39 +02:00
Javi Martín
a5f1245b7e Extract partial to refresh flag actions
Now that we're rendering `shared/flag_actions` everywhere, we can use
the same code in all cases.
2020-07-08 11:58:03 +02:00
volcov
09fd3ab44a Fix legislation proposals flag actions
We were treating legislation proposals as if they were proposals,
omitting the "legislation" namespace, and so we were flagging/unflagging
proposals when we wanted to flag/unflag a legislation proposal.
2020-07-07 23:39:21 +02:00
Javi Martín
0d7c2c7a7c Simplify rendering flag actions
The `respond_with` method is no longer part of Rails (it's now part of
the responders gem) and we barely use it. Using a template forced us to
use different criteria for different controllers.

This change will also make it easier to fix the flag/unflag actions for
legislation proposals. With the old code, we would have to add another
condition for the legislation/proposals controller.
2020-07-07 23:39:19 +02:00
Javi Martín
b483d50d30 Remove unused tag filter
This filter was added in commit 4285ba4b, it was changed in commit
002d8688, and most of the code from the original commit has disappeared
without a trace (maybe due to a merge conflict?).

This filter could actually be useful if we started using it when users
click on a tag. Since we don't, I'm removing it. We might add it back if
we decide to actually use it.
2020-04-08 13:49:48 +02:00
taitus
2f500a6b56 Fix detect_remote_translations for Legislation::Proposal
Legislation::Proposal is not Globalize model but use CommentableActions and try
detect remote translations. Add new condition to discard Non Globalize models.
This fix is necessary since the following commit was included: c1f3a4ad.
2020-02-26 16:47:13 +01:00
taitus
086e38c969 Improve display remote translation button
- Do not display remote translations button when API key is not configured
2020-02-26 12:30:17 +01:00
Javi Martín
667797161b Extract method to redirect keeping query params 2019-11-12 19:27:58 +01:00
Javi Martín
bd03e249ce Reduce number of records in pagination tests
Creating more than 25 records isn't necessary to test pagination; we can
stub the number of records per page in a test.

On my machine we save about one second per test with these changes.
2019-11-10 14:12:21 +01:00
Javi Martín
3eda2de2d5 Remove unused helper methods
They aren't used since commits a6585361, 3752f3a5, 88a7a29d, eef8ad1b,
f67f058b, 04910fea and 9181610d. The method `image_bytes_to_megabytes`
was never used and is a duplicate of the method `bytes_to_megabytes`.
2019-11-10 00:34:45 +01:00
Javi Martín
23d132c3d3 Remove obsolete controller concern
It isn't used since commit 18f0697e.
2019-11-10 00:34:40 +01: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
eafb4018bf Apply Style/CollectionMethods rubocop rule
We were already using `map` and `reduce` almost everywhere.
2019-10-26 13:03:49 +02:00
Javi Martín
d938077813 Remove empty lines around if and when body
Unfortunately, there doesn't seem to be a Rubocop rule for this one.
I've found these empty lines thanks to Rufo.
2019-10-24 17:56:03 +02: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
27468b0b7b Use relative URLs where possible
In general, we always use relative URLs (using `_path`), but sometimes
we were accidentally using absolute URLs (using `_url`). It's been
reported i might cause some isuses if accepting both HTTP and HTTPS
connections, although we've never seen the case.

In any case, this change makes the code more consistent and makes the
generated HTML cleaner.
2019-10-20 17:26:14 +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
Javier Martín
f018706e6b Merge pull request #3740 from consul/remove_obsolete_code
Remove leftover code
2019-10-05 04:11:58 +02:00
cyrillefr
44b2a07878 Moderate legislation proposals (#3602)
Moderate legislation proposals

- added a controller for moderation/legislation
- updated view to appropriate link + added route
- added a spec
- Feature test
- test for faded
- javascripts for visual effects
2019-10-05 04:02:39 +02:00
Javi Martín
ad14636255 Use Tag instead of ActsAsTaggableOn::Tag
It's shorter, it's easier to extend its behaviour, and it's easier to
integrate with other parts of our application, like translations.
2019-10-05 03:38:44 +02:00
Javi Martín
d639cd587a Remove unnecessary uniq calls
The code `where(id: ids)` is equivalent to `where(id: ids.uniq)`.

Since Rails 5 uses `distinct` instead of `uniq` and in most cases where
we use `uniq` with `pluck` we should simply remove the `uniq` call (as
done in this commit), we're also removing the `Rails/UniqBeforePluck`
rubocop rule.
2019-09-10 22:27:33 +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
a21240b230 Use Date.current and Time.current
Using Date.today and Time.now might lead to inconsistencies if the time
zone the application uses is not the same as the system time zone.
2019-08-28 20:32:40 +02:00
Javi Martín
7c252750c9 Remove duplicated call to index customization
The statement executed the method twice if the `present?` condition was
true. If the condition was false, it executed it once anyway.

It's probably a typo and originally we probably meant we wanted to
execute the method if the method existed.
2019-08-27 17:22:22 +02:00
taitus
c1f3a4ad3b Add remote translations to debates and proposals
Include RemotelyTranslatable concern on commentable actions to detect
remote translations on index and show controllers actions.
2019-06-27 09:21:19 +02:00
taitus
d2506358ef Fix found Hound violations 2019-06-27 09:21:18 +02:00
taitus
25e9c358ad Create RemotelyTranslatable concern controller
- Create concern to reuse the logic of detection of non-existent
  translations in Controllers.
- Add detect_remote_translation method:
  * This method will be called from controllers to recover resources
    without translation.
  * Receive arrays of resources.
  * Return an array with hashes of remote_translations values for
    every resources that have not translations.
  * This array will be the param that will be sent from view to
    RemoteTranslationController for create remote translations instances.
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
8c2f1b894d Add controller concern to initialize Globalize fallbacks
Ensure to initialize all requests including this concern into all
application base controllers.
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
5dc0f7f054 Add :except and :only options to translatable_params method
Allow to choose among resource model translatable attributes.
2019-06-27 09:19:37 +02:00
German Galia
9d1ca3bfd4 Report generation. Download csv 2019-06-12 10:17:31 +02:00
Javi Martín
4f4dc2c2af Add show results and stats form to budgets 2019-05-22 11:50:03 +02:00
decabeza
51ced318e0 Merge branch 'master' into proposal-dashboard 2019-04-29 13:48:23 +02:00
Javi Martín
286e0ca878 Handle AccessDenied in management sessions
We were raising a `CanCan::AcessDenied` and were getting a 500 Internal
Server Error.

I've chosen to do the same thing we do in the ApplicationController.
There are other options to handle this request, like redirecting to the
login page or returning a 401 Unauthorized HTTP status.
2019-04-25 20:36:50 +02:00
decabeza
2af154d539 Merge branch 'master' into proposal-dashboard 2019-03-28 01:26:04 +01:00
decabeza
91be3cf775 Fix more hound warnings 2019-03-27 15:22:14 +01:00
decabeza
eda6ea7f12 Merge branch 'master' into dashboard 2019-03-26 16:45:48 +01:00
Javi Martín
2b4e1cf358 Add missing double quotes
We overlooked a few single quotes while we changed thousands of them.
2019-03-25 13:22:35 +01:00
Julian Herrero
c82b2a975a Add new settings tab for participation processes
- Rename setting keys
- New tab por participation processes
- Hide these settings from features tab
2019-03-19 19:45:32 +01:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
Javi Martín
e3ca700e17 Add concerns to set and order by a random seed 2019-02-20 11:51:32 +01:00
taitus
7d910ed502 Fix wrong iteration.
Explained on Notes from PR
2019-02-02 17:19:46 +01:00
taitus
ead765a9c1 The value of cweek did not manage well the last week of the year
grouping_key_for method when params[:group] == "week" always returned "#{date.cweek}/#{date.year}" but that not always is true.
When a date belongs to the first_week/last_week of the year we have exceptions for example "31/12/2018".  His cweek is equal to "1", old code returned "1/2018" value but correct result would be "1/2019".
2019-02-02 17:18:02 +01:00
rogelio-o
f1bb1ff8de Moves attributes to a concern. 2019-01-14 20:26:47 +01:00
Javi Martín
00983200d4 Update information texts translatable fields
This part used the code we deleted in order to make it easier to
refactor the rest of the translatable models. Now we add the code back.
2018-10-22 16:36:12 +02:00
Javi Martín
71601bd3f8 Validate translations in banners
This change forces us to use nested attributes for translations, instead
of using the more convenient `:"title_#{locale}"` methods.

On the other hand, we can use Rails' native `_destroy` attribute to
remove existing translations, so we don't have to use our custom
`delete_translations`, which was a bit buggy since it didn't consider
failed updates.
2018-10-22 15:43:28 +02:00
decabeza
546105d989 Merge branch 'master' into dashboard-master 2018-10-19 01:48:37 +02:00
Raimond Garcia
4086220ebf Merge pull request #2914 from microweb10/make_polls_translatable
Make polls translatable
2018-09-26 13:19:17 +02:00
Julian Herrero
9495208518 Make polls translatable 2018-09-20 17:07:43 +02:00
Javi Martín
4d238c5d07 Fix crash updating legislation process categories
We were expecting translation parameters in legislation processes
`update` action. However, those parameters aren't sent when we get to
that action through the "proposals" tab.
2018-09-19 14:54:52 +02:00