Commit Graph

50 Commits

Author SHA1 Message Date
Javi Martín
f7e2d724dd Replace ahoy events with real data
We were tracking some events with Ahoy, but in an inconsistent way. For
example, we were tracking when a debate was created, but (probably
accidentally) we were only tracking proposals when they were created
from the management section. For budget investments and their supports,
we weren't using Ahoy events but checking their database tables instead.
And we were only using ahoy events for the charts; for the other stats,
we were using the real data.

While we could actually fix these issues and start tracking events
correctly, existing production data would remain broken because we
didn't track a certain event when it happened. And, besides, why should
we bother, for instance, to track when a debate is created, when we can
instead access that information in the debates table?

There are probably some features related to tracking an event and their
visits, but we weren't using them, and we were storing more user data
than we needed to.

So we're removing the track events, allowing us to simplify the code and
make it more consistent. We aren't removing the `ahoy_events` table in
case existing Consul Democracy installations use it, but we'll remove it
after releasing version 2.2.0 and adding a warning in the release notes.

This change fixes the proposal created chart, since we were only
tracking proposals created in the management section, and opens the
possibility to add more charts in the future using data we didn't track
with Ahoy.

Also note the "Level 2 user Graph" test wasn't testing the graph, so
we're changing it in order to test it. We're also moving it next to the
other graphs test and, since we were tracking the event when we were
confirming the phone, we're renaming to "Level 3 users".

Finally, note that, since we were tracking events when something was
created, we're including the `with_hidden` scope. This is also
consistent with the other stats shown in the admin section as well as
the public stats.
2024-05-09 14:28:32 +02:00
Javi Martín
a1439d0790 Apply Layout/LineLength rubocop rule
Note we're excluding a few files:

* Configuration files that weren't generated by us
* Migration files that weren't generated by us
* The Gemfile, since it includes an important comment that must be on
  the same line as the gem declaration
* The Budget::Stats class, since the heading statistics are a mess and
  having shorter lines would require a lot of refactoring
2023-08-30 14:46:35 +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
Javi Martín
b98244afd9 Remove votes query optimizations
Just like we did in commit 0214184b2d for investments, we're removing
some possible optimizations (we don't have any benchmarks proving they
affect performance at all) in order to simplify the code.

The investement votes component `delegate` code was accidentally left
but isn't used since commit 0214184b2, so we're removing it now that
we're removing the `voted_for?` helper method.
2022-02-21 18:47:13 +01:00
Javi Martín
c8d8fae98d Move related list partial to a component
This way the code is easier to follow; the code checking whether the
list has contents is in the partial rendering the list.

We also remove some duplication setting up related content in the
controllers.

For some reason, we have to manually ignore i18n keys which were
automatically ignored when the code was in the view.
2021-08-16 16:30:13 +02:00
Javi Martín
4150d7f1be Move proposals form partial to a component
Since now categories are loaded in both the investment form component
and proposal form component, and their controllers are the only
"commentable" controllers using the `@categories` instance variable, we
can remove the `load_categories` call in `CommentableActions` affecting
the create and update actions.
2021-07-13 15:25:29 +02:00
Melvin Lammerts
c34aa54122 Remove skip map checkbox 2021-06-03 11:13:52 +02:00
taitus
c173568404 Move map_location attributes to concern 2021-04-09 16:20:59 +02:00
Andy Sims
74fbde09f1 Support creates follow (Merge pull request #3895)
* Supporting a proposal will create a follow relationship
* Only followers receive notifications
2020-04-06 15:26:47 +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
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
Senén Rodero Rodríguez
bd3bb72370 Add proposals translation interface
* Convert proposal form into translatable one.
 * Adapt translatable shared spec to define an owner when running at
   frontend feature specs.
 * Remove old attributes from strong parameters.
2019-06-27 09:19:37 +02:00
decabeza
0995480b73 Remove question and external_url fields from proposals 2019-04-30 11:35:47 +02:00
decabeza
f47ec9d7dc Fix hound warnings 2019-03-26 18:21:19 +01:00
decabeza
eda6ea7f12 Merge branch 'master' into dashboard 2019-03-26 16:45:48 +01:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
Juan Salvador Pérez García
77dd60427d Implements story #136
Adds draft state for proposals
2018-07-17 17:46:54 +02:00
rgarcia
ebb3c075b0 fixes proposal's management specs 2017-12-15 09:58:12 +01:00
Bertocq
69f4e1c683 Fix all rubocop Metrics/LineLength issues (140+) 2017-07-10 13:22:49 +02: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
rgarcia
18dd9c95f3 fixes specs 2016-06-16 12:06:26 +02:00
Juanjo Bazán
2d4ac24465 adds missing param 2016-04-28 18:36:22 +02:00
Raimond Garcia
712e42ca9d Merge pull request #1104 from consul/admin-access-to-management
Admin access to management
2016-04-28 16:55:10 +02:00
Juanjo Bazán
585f3dd6c7 removes use of current_user in management
favors managed_user
to avoid conflicts with logged admin users
2016-04-27 17:26:19 +02:00
kikito
dea1a28a69 purges simple_captcha 2016-04-27 16:07:47 +02:00
Juanjo Bazán
991b189610 refactors triplicated code 2016-04-08 12:16:09 +02:00
Raimond Garcia
2a4adc2e60 Merge pull request #817 from microweb10/friendly_urls
Friendly urls
2016-03-02 17:51:00 +01:00
rgarcia
dbc19090ed cleans up 2016-01-26 12:13:29 +01:00
Julian Herrero
7c65b8555c redirect to frendly url for debates and proposals if needed 2016-01-10 13:38:22 +01:00
kikito
cf31e89204 Fixes issues in moderation spex related with comment sort 2015-11-02 15:54:15 +01:00
kikito
d6396b38b6 Adds missing comments order in management controller 2015-10-28 17:34:51 +01:00
Juanjo Bazán
0ff9429b52 adds for_render to preload tags 2015-10-20 15:02:41 +02:00
rgarcia
8acd119b19 displays only the first 5 proposals to print 2015-10-20 14:45:59 +02:00
Juanjo Bazán
2a4495fd36 defaults proposal print list to confidence_score 2015-10-17 13:44:15 +02:00
rgarcia
db67eb5b23 redirects to managed user sign in path unless verified 2015-10-14 17:53:49 +02:00
rgarcia
dc93ea6dba displays proposal created within management layout 2015-10-13 15:00:23 +02:00
rgarcia
bca26b2b50 changes current_user for managed_user 2015-10-13 13:58:01 +02:00
rgarcia
5feef066dc adds managed user to session 2015-10-11 16:56:16 +02:00
rgarcia
96633327b5 adds missing translation 2015-10-08 18:35:04 +02:00
rgarcia
33ee1a159f cleans up 2015-10-08 18:27:26 +02:00
rgarcia
36875f8211 brings back manager verification check 2015-10-08 18:25:21 +02:00
rgarcia
c21a78e164 checks for verified users when creating and voting proposals 2015-10-08 15:37:59 +02:00
rgarcia
5560c84b66 adds spec for manager print proposals 2015-10-08 14:56:27 +02:00
rgarcia
a3503c7eb3 refactors manager proposal votes 2015-10-08 14:40:47 +02:00
rgarcia
18e66160fe adds manager creating proposals spec 2015-10-08 13:56:51 +02:00
rgarcia
015e57ddad adds print of new proposals 2015-10-08 12:43:33 +02:00
rgarcia
0acdf5722b adds creation of proposals by managers 2015-10-08 12:43:33 +02:00
rgarcia
33a3ece1c2 adds search for proposals 2015-10-08 12:43:32 +02:00
rgarcia
4881f5bd1e basic proposal voting my managers 2015-10-08 12:43:32 +02:00
rgarcia
74b92ca317 tmp commit manager vote 2015-10-08 12:43:32 +02:00