Commit Graph

116 Commits

Author SHA1 Message Date
cyrillefr
5ec6337d47 Add new GraphQL types for budget investments
- added 2 new types
- modified the models to get data through graphQL
- modified the corresponding spec
- also testing that hidden comments do not show up
- modified comments specs bc now it returns comments on budget
  investments
2024-09-30 11:14:01 +02:00
Javi Martín
1a098dfcab Add and apply MultilineMethodCallBraceLayout rule
In order for this rule to work effectively when running `--autocorrect`,
we also need to enable the `ClosingParenthesisIndentation` rule.
2023-08-18 14:56:16 +02:00
Javi Martín
8b13daad95 Add and apply rules for multi-line hashes
For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
2023-08-18 14:56:16 +02:00
Javi Martín
97aca0cf95 Add and apply rules for multi-line arrays
We were already applying these rules in most cases.

Note we aren't enabling the `MultilineArrayLineBreaks` rule because
we've got places with many elements whire it isn't clear whether
having one element per line would make the code more readable.
2023-08-18 14:56:16 +02:00
Jacek Skrzypacz
2af7e32415 Add search form for hidden content
Added search for comments and proposal_notifications, added tsv column
for search and rake tasks to update/create tsv vector.
2022-08-23 14:30:38 +02:00
Javi Martín
5977f2ec3d Simplify methods to get API-public records
Just like we did to tags in commit 2e863fdc5.
2022-05-02 17:16:31 +02: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
cac24b0159 Extract component to show moderation actions
Note that in proposal notifications we're writing the call to
render the component in the same line as the <div class="reply">
definition in order to be able to use the `:empty` selector when the
component renders nothing. No browser matches whitespace with the
`:empty` selector, so we can't add newline characters inside the tag. A
more elegant solution would be extracting the proposal notification
actions to a component and only rendering it if the moderation actions
component is rendered.
2021-12-30 15:50:03 +01:00
Javi Martín
884fd2b27b Add and apply Rails/WhereEquals rubocop rule
We were already following this style in most places.
2021-08-09 23:52:47 +02:00
Javi Martín
16c16e3cdf Mark safe SQL with Arel.sql
Rails 5.2 is raising a warning in some places:

DEPRECATION WARNING: Dangerous query method (method whose arguments are
used as raw SQL) called with non-attribute argument(s). Non-attribute
arguments will be disallowed in Rails 6.0. This method should not be
called with user-provided values, such as request parameters or model
attributes. Known-safe values can be passed by wrapping them in
Arel.sql().

IMHO this warning is simply wrong, since we're using known PostgreSQL
functions like LOWER() or RANDOM(). AFAIK this code works without warnings
in Rails 6.0 [1][2]

However, since the warning is annoying, we need to take measures so our
logs are clean.

[1] https://github.com/rails/rails/commit/6c82b6c99d
[2] https://github.com/rails/rails/commit/64d8c54e16
2020-10-15 14:57:42 +02:00
Javi Martín
14df74fed7 Add collaborative legislation summary again
It was removed in commit 128a8164 because we hadn't reviewed it nor
tested it properly. We're now adding it again, fixing the issues we've
found while reviewing.
2020-09-08 13:32:08 +02: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
f3df3f4fbc Remove people proposal model
This model isn't used anywhere, since it was created as part of a
feature which couldn't be completed.

This commit reverts commit 46e5d6a9.
2019-10-30 02:26:42 +01:00
Javi Martín
42d2e5b3ad Apply Rails/InverseOf rubocop rule
Not doing so has a few gotchas when working with relations, particularly
with records which are not stored in the database.

I'm excluding the related content file because it's got a very peculiar
relationship with itself: the `has_one :opposite_related_content` has no
inverse; the relation itself is its inverse. It's a false positive since
the inverse condition is true:

```
content.opposite_related_content.opposite_related_content.object_id ==
  content.object_id
```
2019-10-25 19:29:12 +02:00
Javi Martín
38b7307450 Use respond_to? instead of try
Usually when we use `try` we actually mean `try!`, which is the same as
the safe navigation operator. However, there are a few cases where we
actually mean to execute a method if the object responds to that method.

In those cases using `try` would actually be OK, but in order to avoid
confusion as to whether we mean to check for `respond_to?` or we mean to
use safe navigation, I'm removing all usages of `try`.
2019-10-22 17:37:51 +02:00
Senén Rodero Rodríguez
158af0217d Add comments translations
Co-Authored-By: Sebastia <sebastia.roig@gmail.com>
2019-06-27 09:19:37 +02:00
German Galia
9d1ca3bfd4 Report generation. Download csv 2019-06-12 10:17:31 +02:00
lalo
46e5d6a9fa Create Legislation::PeopleProposal model 2019-06-06 17:22:49 +02:00
Juanjo Bazán
b7d9ef6377 models inherits from ApplicationRecord 2019-04-17 17:40:56 +02:00
rgarcia
7e3eb4a6fc fixes expire cache specs 2019-04-16 17:28:07 +02:00
Julian Herrero
3ba961a2d7 Use double quotes in models 2019-03-14 17:25:43 +01:00
Bertocq
26cf91c61a Create valuation comments creation ability
Why:

Only admins or valuators (for those investments they've assigned) can
create internal valuation comments on them.

How:

* Creating a new `comment_valuation` ability for admins and valuators in
the same manner the `valuate` ability works.

* Adding a validation at Comment model for those with `valuation` flag
active that checks if the author can make a valuation comment on the
commentable, as well as the respective active record error messages.
This will prevent comments from being created at a controller level as
well.

* Improving comment factory trait `valuation` to have an associated
investment, author that is a valuator and setting the valuator on the
valuators list of the investment
2018-01-31 02:03:03 +01:00
Bertocq
149c81371b Allow valuation internal comments to be created
How:

Using a local variable at partials to set a hidden true/false value for
`valuation` parameter on the comment creation form.

Allowing that new param at the comment controller and using it when
building a new Comment.
2018-01-31 02:03:02 +01:00
Bertocq
56fc5c9583 Filter internal valuation comments from public api
Why:

Internal valuation comments are only for admins and valuators,
not for the public view.

How:

Adding a `not_valuations` scope and use it at the `public_for_api` one
2018-01-30 19:22:27 +01:00
Bertocq
070c94494e Fix linelenght over 100 on multiple files 2018-01-26 00:27:03 +01:00
rgarcia
2b52d26d82 refactors notifications into concerns and shared examples 2017-12-14 16:15:30 +01:00
Juanjo Bazán
21b2a11339 adds poll comments to API 2017-11-21 14:31:03 +01:00
decabeza
f0cfe50de4 Merge branch 'master' into 1856-legislation_processes_proposals_phase 2017-10-25 11:52:31 +02:00
Manuel Lucena
63cbe2f7c1 20171003 - [WIP] Functionality and tests for polls comments 2017-10-06 10:36:26 +02:00
María Checa
57c48fe596 Legislation proposals comments working 2017-09-21 17:13:12 +02:00
taitus
bea393bcde Add comments to topics 2017-09-05 12:51:08 +02:00
Bertocq
69f4e1c683 Fix all rubocop Metrics/LineLength issues (140+) 2017-07-10 13:22:49 +02:00
Bertocq
2888c20489 Fix all Style/RedundantSelf rubocop issues 2017-07-05 11:55:52 +02:00
Bertocq
f6fe9cc7d2 Fix all Layout/SpaceAroundOperators rubocop issues and remove file list from rubocop_todo list 2017-06-26 18:04:20 +02:00
Bertocq
d7b8777395 Fix all Layout/SpaceAroundEqualsInParameterDefault rubocop issues from rubocop_todo list 2017-06-26 18:03:40 +02:00
Bertocq
8d84ed712a Fix all Rails/Validation rubocop issues and remove files from rubocop_todo list 2017-06-25 15:46:46 +02:00
kikito
0ad1ff5845 changes the way public_for_api is calculated in comment 2017-06-13 12:11:20 +02:00
kikito
1701111bf5 Merge branch 'api-dev-PRs' of https://github.com/amiedes/consul into amiedes-api-dev-PRs-2 2017-06-13 12:07:28 +02:00
Alberto Miedes Garcés
9ec8b166d7 Use scopes for better query performance 2017-06-01 20:04:51 +02:00
decabeza
5e0d5fc8c3 Merge branch 'legislation-module-stable' of https://github.com/medialab-prado/consul into medialab-legislation 2017-05-22 18:43:49 +02:00
Alberto Miedes Garcés
5d9054d284 Merge branch 'master' into api-dev-PRs
Conflicts:
	Gemfile.lock
	config/routes.rb
	db/dev_seeds.rb
	db/schema.rb
2017-05-11 21:59:42 +02:00
Alberto Miedes Garcés
6b47ce065f Fix buggy associations 2017-01-27 14:27:28 +01:00
Alberto Miedes Garcés
5b7cbccd19 Merge branch 'master' into api-dev 2017-01-26 12:39:59 +01:00
Alberto Miedes Garcés
83267330a7 Group methods related to text generation for GraphQL documentation into a module 2017-01-26 10:47:12 +01:00
Alberto Miedes Garcés
e3fca5c49f Remove functionality related to votes demographic info
Since this was giving me too much pain and nobody actually requested
this functionality, I decided to remove it.
2017-01-25 13:37:29 +01:00
Juanjo Bazán
113f9b32d7 Merge branch 'master' into polls 2017-01-19 16:51:19 +01:00
Alberto Miedes Garcés
d1f14ffb93 Simplify the way GraphQL 'resolve' is used 2017-01-12 19:51:58 +01:00
Amaia Castro
a2a61341fe Merge branch 'master' into legislation-module-stable 2017-01-11 22:54:41 +01:00
Juanjo Bazán
f102f9f753 adds Budget::Investment to valid commentable types 2017-01-10 13:30:30 +01:00
Alberto Miedes Garcés
6940b90260 Add more fields to api.yml 2017-01-09 14:11:51 +01:00