Commit Graph

139 Commits

Author SHA1 Message Date
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
Juan Salvador Pérez García
e8e01b184f Fixed issue accumulating supports 2018-09-17 19:49:33 +02:00
Juan Salvador Pérez García
a658536142 Fixed issue when filling holes in grouped supports query 2018-09-17 19:37:29 +02:00
Juan Salvador Pérez García
0bd381aa5e Enhancements and bugfixing
FIxed issue in last commit: supports controller were not correctly
filling the holes without data.

Fixed duplication in supports and successful supports controller using a
concer.

Successfull supports controller will fill the holes without data in the
same way that supports controller does.
2018-09-14 11:30:59 +02:00
Juan Salvador Pérez García
3590657777 Enhancements on supports controller
Supports controller now fill the holes in the results: When there are no
supports collected for one interval it takes the accumulated value from the
previous one.

Data starts in the publication date.
2018-09-14 10:49:29 +02:00
Marko Lovic
96b798865a Refactor Translatable#translation_params to improve readability
Code by Javier Martín
2018-09-10 17:34:28 +02:00
Marko Lovic
3c4f221e04 Change Translatable interface 2018-09-10 17:32:49 +02:00
Marko Lovic
4603a30f95 Change Translatable impl to keep track of enabled locales 2018-09-10 17:18:01 +02:00
Marko Lovic
3aa53449c8 Fix Translatable when field values are changed to blank
If we ignore all params that are blank, there is no way to
"remove" an attribute (i.e. change its value to blank)

On the other hand, we don't want to create new translations
where all fields are empty, so the new code keeps only the
blank fields which belong to existing translations.
2018-09-10 17:16:42 +02:00
Juan Salvador Pérez García
6cc1ddb9af Fixes #231
Implements a poster feature for the proposals dashboard
2018-07-31 12:50:25 +02:00
Juan Salvador Pérez García
50f73abb0c Fixes #voodoorai2000 comments
Fixes some comments from #voodoorai2000 for the PR to consul
2018-07-27 16:30:03 +02:00
Angel Perez
1990092fdf Allow moderators to hide inappropriate investments 2018-07-20 18:42:33 -04:00
Angel Perez
7bb1da1804 Adapt backend to enable flagging/unflagging investments 2018-07-20 18:42:33 -04:00
iagirre
0d9da5398b Fix banners in user pages
Banners were not been shown in certain pages; now
they are.

Spec to check if the banner is been shown correctly
added. Before it was in admins specs, now it has it's
own spec out of admins folder.
2018-07-12 10:17:25 -04:00
Raimond Garcia
3e4d095e6f Merge pull request #2719 from javierv/2718-fix_flaky_milestone_spec
Fix flaky spec: Budget Investments Show milestones
2018-07-12 16:07:48 +02:00
Javier Martín
f2ef27d3ae Always set Globalize.locale after I18n.locale.
The test "Budget Investments Show milestones" was failing in certain
cases where `Globalize.locale` had been changed in a previous test.

Since having different values in `Globalize.locale` and `I18n.locale`
has proven to be an issue on the test enviroment, this commit also
changes application code in order to avoid similar situations on
production.

See issue #2718.
2018-07-03 00:52:20 +02:00
iagirre
21b1d00205 Add backend for the moderators
Add new routes for the proposal notifications edition and
abilities to let moderators edit it (mark as ignored, hide, etc.).

The notifications are not flaggable because they doesn't work like that,
but in a similar way. The moderator/administrator is in charge of hidding
them through the UI, so the normal users don't flag it as inappropriate.

New controller Moderation::ProposalNotification to manage the moderators
work.
2018-07-02 18:17:45 +02:00
iagirre
471c9730cc Refactorings
- Cleanup Translatable module (`translation_params` method too large)
- Move globalize_helpers partial to admin folder
- Use any class for method translation_params
- Helpers in `GlobalizeHelpers` make sure all are in use and see if they can be more legible
- Review js name clases and methods see if they can be more legible
- Refactor milestone views into partials with nice spacing between attributes
2018-05-09 16:58:47 +02:00
iagirre
b318c2be46 Add feature to delete a translation
To delete a translation, a link has been added. This
link works for the selected language. It hides all the
things related to a language (the tab and the text_area)
and empties the text area, so that the value is blank
in the param hash. A variable called `delete_translations[]`
is changed.

e.g. If admin wants to remove English language,
delete_translations[:en] will be 1; if not, it will be 0.

When the milestone is updated, there is a before_action
callback that cleans the selected languages for deletion
(looking the delete_translations[] variable).
Because of the deleted translations are blank in param hash,
them won't be saved in DB.
2018-05-09 16:07:12 +02:00
rgarcia
f7486b9238 Add Globalize to Milestones 2018-05-09 16:05:44 +02:00
Senén Rodero Rodríguez
92c774cdeb Merge with master 2017-09-28 13:36:20 +02:00
Senén Rodero Rodríguez
93e5c9656c Remove unnedded code 2017-09-26 13:57:13 +02:00