Commit Graph

44 Commits

Author SHA1 Message Date
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
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
ff93f5a591 Use "resolve" for polymorphic hierarchy paths
In the past, we couldn't use `polymorphic_path` in many places. For
instance, `polymorphic_path(budget, investment)` would return
`budget_budget_investment_path`, while in our routes we had defined
`budget_investment_path`.

With the `resolve` method, introduced in Rails 5.1, we can use symbols
to define we want it to use `investment` instead of `budget_investment`.
It also works with nested resources, so now we can write
`polymorphic_path(investment)`.

This makes the code for `resource_hierarchy_for` almost impossible to
understand. I reached this result after having a look at the internals
of the `resolve` method in order to get its results and then remove the
symbols we include.

Note using this method will not make admin routes compatible with
`polymorphic_path`. Quoting from the Rails documentation:

> This custom behavior only applies to simple polymorphic URLs where a
> single model instance is passed and not more complicated forms, e.g:
> [example showing admin routes won't work]

Also note that now the `admin_polymorphic_path` method will not work for
every model due to inconsistencies in our admin routes. For instance, we
define `groups` and `budget_investments`; we should either use the
`budget_` prefix in all places or remove it everywhere. Right now the
code only works for items with the prefix; it isn't a big deal because
we never call it with an item without the prefix.

Finally, for unknown reasons some routing tests fail if we use
`polymorphic_path`, so we need to redefine that method in those tests
and force the `only_path: true` option.
2020-06-15 11:54:05 +02:00
Javi Martín
15c49e0c10 Remove obsolete URL helpers
We now use `polymorphic_hierarchy_path` instead.
2019-10-20 17:23:59 +02:00
Javi Martín
9fe8c47528 Apply Rails/SafeNavigation rubocop rule 2019-09-10 21:43:39 +02:00
lalo
8061bfa5e8 Send email to users related with an investment when valuation comment is created 2019-06-05 17:02:59 +02:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
rgarcia
09c44ee583 Extend notifications to be marked as read and unread 2018-03-23 11:47:06 +01:00
Bertocq
bca150bcd5 Prevent non-authors from viewing valuation comments 2018-01-31 18:38:44 +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
5e583d2015 Increase notifiable access security on add notification method 2018-01-26 11:24:13 +01:00
Bertocq
f4ad0b2979 Improve add_notification logic to add notificable author 2018-01-26 00:33:07 +01:00
Bertocq
070c94494e Fix linelenght over 100 on multiple files 2018-01-26 00:27:03 +01:00
Amaia Castro
3009706b0d Don’t allow comments on questions for unverified users and when the phase is closed 2017-02-08 18:19:10 +01:00
rgarcia
bb3c4c6399 adds consistency to ruby code style
Keep a blank line before and after private
Keep a blank line before and after protected
Remove extra empty line at class body end
Remove extra blank line
Add final newline
Use 2 (not 3) spaces for indentation
Use 2 (not 4) spaces for indentation
Remove space before comma
Add space after comma
Remove trailing whitespaces
Remove unnecessary spacing
Use snake_case for variable names
Do not use then for multi-line if
Remove unused block argument - i
Use the new Ruby 1.9 hash syntax
Remove unused assignment to variable
Indent when as deep as case
Align attributes
Align end with def
2016-11-15 11:18:43 +01:00
Juanjo Bazán
307b29736d Merge branch 'master' into notifications 2016-01-08 15:07:16 +01:00
Juanjo Bazán
704a038795 groups notifications 2016-01-08 14:32:16 +01:00
Juanjo Bazán
ab74bd58fa avoids queries when creating a notification 2016-01-08 13:06:00 +01:00
rgarcia
816a95b7b7 adds comment show view 2016-01-07 15:18:28 +01:00
rgarcia
b5e9113718 merges activities into notifications 2016-01-06 12:33:37 +01:00
Julian Herrero
ba0ce4e14b añadir track_activity para mostrar futuras notificaciones a los usuarios 2016-01-05 17:42:10 +01:00
Juanjo Bazán
65d86d8b5f makes comments controller commentable agnostic 2015-09-12 14:12:37 +02:00
David Gil
3f652262e7 makes the controller send the emails instead of Comment model 2015-09-10 18:47:45 +02:00
David Gil
d9300f1c10 prevents users to receive email notifications about own comments and replies 2015-09-10 18:46:00 +02:00
rgarcia
d0d33cc517 sends custom emails with delayed jobs 2015-09-03 22:48:29 +02:00
Juanjo Bazán
dee2d0196b ancestries
moves to ancestry from acts_as_commentable_with_threading
2015-09-02 19:23:09 +02:00
kikito
99fd0a917d Uses @comment_flags in everything comment-related 2015-09-01 13:10:19 +02:00
kikito
27ece220f6 Transform Flag.flag! & unflag! into non-raising methods
They now return false and do nothing instead
2015-08-31 19:02:50 +02:00
kikito
909dfb4ce3 Several renamings
InappropiateFlag -> Flag
x.flag_as_inappropiate -> x.flag
x.undo_flag_as_inappropiate -> x.unflag
X.flagged_as_inappropiate -> x.flagged
flag-as-inappropiate-actions views & css -> flag-actions views & css
2015-08-27 10:48:49 +02:00
Juanjo Bazán
82fb56e4c0 refactors comments controller ugly method 2015-08-24 18:59:53 +02:00
Juanjo Bazán
030fd49120 allows comment as moderator/administrator
Ref: #170
2015-08-24 18:17:04 +02:00
kikito
01eb89f5f4 DRYes comment views related with flagging as inappropiate 2015-08-20 22:54:05 +02:00
kikito
e7effbf77c Allows flagging comments as inappropriate 2015-08-20 18:47:16 +02:00
rgarcia
f31ed2940d adds moderation to comments and debates [#136] 2015-08-17 13:39:31 +02:00
rgarcia
efa0cf16d9 uses comment strong parameters 2015-08-16 23:05:01 +02:00
rgarcia
bea38226fe fixes spacing 2015-08-16 22:45:43 +02:00
rgarcia
a81612b226 improves consistency of error messages [#110] 2015-08-16 15:57:09 +02:00
kikito
51323fa891 Adds back missing authenticate_user! calls 2015-08-10 16:05:58 +02:00
kikito
84d848df7e Adapts the CommentsController to the new permissions system 2015-08-10 15:40:23 +02:00
rgarcia
beb1a796f5 adds email sending preferences [#23] 2015-08-07 20:56:27 +02:00
rgarcia
3752054aab sends emails [#23] 2015-08-07 20:52:53 +02:00
rgarcia
91b52ad8d2 refactors voting implementation [#25] 2015-08-05 12:24:22 +02:00
rgarcia
3247180dfa responds with ajax to comment creation [#47] 2015-07-28 20:32:53 +02:00
rgarcia
98463e4930 adds comments to debates [#7] 2015-07-18 17:38:57 +02:00