Commit Graph

13635 Commits

Author SHA1 Message Date
Javi Martín
234a5108a4 Use strings for class_name
As mentioned in the Rails console:

DEPRECATION WARNING: Passing a class to the `class_name` is deprecated
and will raise an ArgumentError in Rails 5.2. It eagerloads more classes
than necessary and potentially creates circular dependencies. Please
pass the class name as a string.
2019-05-28 14:26:18 +02:00
Javi Martín
e445e14d65 Use ActiveSupport::HashWithIndifferentAccess
Using `HashWithIndifferentAccess` directly will be deprecated in Rails
5.1.
2019-05-28 14:23:54 +02:00
decabeza
c2acd53a06 Change devise configuration
This change don't let the user know if the email address exists when asking to resend confirmation or password reset instructions.
2019-05-28 14:23:37 +02:00
Javier Martín
c43a1a2096 Merge pull request #3361 from consul/polls_unanswerable
Display all polls for current booth
2019-05-28 13:53:27 +02:00
voodoorai2000
e1141d1cd3 Display already voted message for budget polls
Budget polls behave slightly differently to non-budget polls.

In budget polls we use Budget::Ballot::Lines to verify if a user has already voted online. In non-budget polls we use Poll::Voter to verify this.

In this commit we are adding an extra check to make sure that the correct message is displayed if the user has already voted online for a budget poll[1]

[1] https://github.com/AyuntamientoMadrid/consul/blob/master/spec/features/budget_polls/voter_spec.rb#L122
2019-05-24 15:20:54 +02:00
voodoorai2000
5abde6da6e Simplify html tag structure 2019-05-24 15:20:54 +02:00
voodoorai2000
29f5268e42 Display polls for current booth
Polls that were not votable by a user were not being displayed in the officing interface. Creating a confusing situation for officers.

With this commit polls that are not votable by a user will be displayed, with the corresponding message explaining that that poll can only be voted by residents of a certain geozone.
2019-05-24 15:20:54 +02:00
Javier Martín
3cb6920a36 Merge pull request #3534 from consul/fix_capybara_window
Resize Capybara window back to its original size
2019-05-24 15:18:07 +02:00
Javi Martín
605da522cb Resize Capybara window back to its original size
The `maximize` method didn't work as we expected and didn't resize the
window, causing issues in tests expecting the window to be larger.
2019-05-24 13:30:49 +02:00
Julian Nicolas Herrero
2c85e293cf Merge pull request #3530 from consul/remove_rspec_deprecation_warnings
Remove Rspec deprecation warning
2019-05-23 18:33:24 +02:00
Julian Nicolas Herrero
67c6aa1a42 Merge pull request #3529 from consul/rubocop_line_long_to_110_characters
Allow lines to be 110 characters long by Rubocop
2019-05-23 16:17:59 +02:00
Julian Herrero
bb25da2572 Remove Rspec deprecation warning
DEPRECATION WARNING: Using positional arguments in functional tests
has been deprecated, in favor of keyword arguments, and will be
removed in Rails 5.1.

Deprecated style:
get :show, { id: 1 }, nil, { notice: "Flash message" }

New keyword style:
get :show, params: { id: 1 }, flash: { notice: "Flash message" }
2019-05-23 13:19:45 +02:00
Julian Herrero
7066dd50d5 Allow lines to be 110 characters long 2019-05-23 13:16:02 +02:00
Javier Martín
387488aa68 Merge pull request #3520 from consul/backport-refactor_stats_enabled
Add options to show advanced stats
2019-05-23 13:07:19 +02:00
Javier Martín
afdc7087d7 Merge pull request #3519 from consul/backport-remove_custom_poll_group_file
Simplify link to poll
2019-05-23 13:06:50 +02:00
Alberto
7abeb599c0 Merge pull request #3515 from consul/proposals-support-mobile
Proposals support on mobile
2019-05-22 18:12:31 +02:00
Javi Martín
9ae0cbb254 Add task to migrate enabled poll results and stats 2019-05-22 12:48:11 +02:00
decabeza
148ea1ede9 Prevent notice been overlapped by header 2019-05-22 12:42:03 +02:00
decabeza
f37a2bd0a8 Change js depending of window with 2019-05-22 12:42:00 +02:00
decabeza
69cada5f9b Prevent header overlaps the support button 2019-05-22 12:41:57 +02:00
decabeza
6734054330 Prevent map overlaps the support button 2019-05-22 12:41:54 +02:00
decabeza
4b3172912e Add spec to show sticky button on mobile screens
Also remove some unnecessary css lines that were causing some unrelated specs to fail.
2019-05-22 12:41:52 +02:00
decabeza
13dfaedf06 Replace load to init sticky 2019-05-22 12:41:49 +02:00
Julian Herrero
2c45f178cb Reset sticky component before clicking back button on browser 2019-05-22 12:41:44 +02:00
Julian Herrero
eca4d773a0 Reset sticky component before leaving the page using Turbolinks 2019-05-22 12:41:38 +02:00
Julian Herrero
0237565ece Set correct attributes for data-sticky component 2019-05-22 12:41:25 +02:00
decabeza
8684835857 Adds sticky on proposals supports for mobile version 2019-05-22 12:40:12 +02:00
Javi Martín
45a3d8daf0 Add option to enable advanced stats 2019-05-22 11:50:03 +02:00
Javi Martín
a34b97e843 Extract partials to show advanced stats 2019-05-22 11:50:03 +02:00
Javi Martín
4f4dc2c2af Add show results and stats form to budgets 2019-05-22 11:50:03 +02:00
Javi Martín
e3d6dbacab Simplify finished budget factory creation 2019-05-22 11:50:03 +02:00
Javi Martín
c00203f7f5 Move budget stats permission tests to the model
They're easier to test and to read in the model.
2019-05-22 11:50:03 +02:00
Javi Martín
eb13994999 Extract partial for form to show results and stats 2019-05-22 11:50:03 +02:00
Javi Martín
1c2e38ea00 Use metaprogramming for report methods
We're going to add an `advanced_stats` report, and having 3 identical
sets of methods would be too much duplication.
2019-05-22 11:50:03 +02:00
Javi Martín
354b183e17 Create reports
This table will store which reports (stats, results, ...) will be shown
for a certain process (polls, budgets, ...).

Note Rails fails to save a poll and its report when both are new records
if we add a `validate :process, presence: true` rule. Since it caused a
lot of trouble when creating records for tests during factories rule
completely. Instead, I've created the `results_enabled=` and
`stats_enabled=` methods, so tests are easier to set up, while also
automatically creating a report if it doesn't already exist. This also
decouples form structure and database implemenation.

Originally I named this table `enabled_reports` and instead of having
`stats` and `results` columns, it had an `enabled` column and a `kind`
column, which would be set to "stats" or "results". However, although
that table would allow us to add arbitrary reports easily, I found the
way we had to handle the `has_many` relationship was a bit too complex.
2019-05-22 11:50:03 +02:00
Javi Martín
2d29243a9e Simplify code to link to a poll with one question 2019-05-22 11:49:35 +02:00
Alberto
ac1d8195f2 Merge pull request #3488 from consul/basic-yml
Admin basic customization texts
2019-05-21 21:43:07 +02:00
Javi Martín
5ca528d2ce Extract method to link to a poll 2019-05-21 17:30:46 +02:00
Javier Martín
82e3c41aa9 Merge pull request #3512 from consul/backport-stats
Change stats layout
2019-05-21 17:18:47 +02:00
Javier Martín
f4891819db Merge pull request #3511 from consul/backport-gender_participants
Refactor gender and age stats methods
2019-05-21 17:17:53 +02:00
Javier Martín
07d55116ef Merge pull request #3510 from consul/backport-refactor_stats_module
Simplify stats caching
2019-05-21 17:16:37 +02:00
Raimond Garcia
7846a4f8bd Merge pull request #3516 from consul/deploy_secrets
Add deploy-secrets.yml.example file
2019-05-21 14:33:17 +02:00
Javier Martín
d57025696f Merge pull request #3503 from consul/backport-blank_votes
Improve poll stats
2019-05-21 14:23:13 +02:00
decabeza
a2cb7501f7 Create new basic tab for admin information texts 2019-05-21 14:06:58 +02:00
Javi Martín
1135441cbd Simplify getting I18nContent translations
This code might be slightly slower because it performs one query per
field in the form, but I didn't notice any differences on my development
machine, and the code is now much easier to understand.
2019-05-21 13:53:39 +02:00
Javi Martín
dc8c4a998f Fix budget stats social meta tags
We had forgotten to update these tags for stats after updating them for
budget results in commit 153b46b4 and commit a6baaa93.
2019-05-21 13:50:19 +02:00
Javi Martín
42a25ded3f Fix booth recounts poll stats discrepancies
Due to technical issues, sometimes users voted in booths and their vote
couldn't be added to the database. So we're including them in the users
with no demographic data.
2019-05-21 13:50:19 +02:00
Javi Martín
483ebffb47 Fix statisticable concern definition
Methods defined inside "included" cannot be called using `super` from
a class including the module.
2019-05-21 13:50:19 +02:00
Javi Martín
e2a3398ec0 Increase poll stats performance
Using SQL's `select` instead of converting the records to a ruby array
increases performance dramatically when there are thousands of records.
For a poll with 200000 voters, calculating stats took more than 7
minutes, and now it takes less than 2 minutes.
2019-05-21 13:50:19 +02:00
Javi Martín
13dd77dd1b Add tasks to generate and expire stats cache
We're generating stats every 2 hours because it's less than the time it
will take to generate stats for every process. Once stats are generated,
this task should take less than a second.

The regenerate task has been added so we can manually execute it.
2019-05-21 13:50:19 +02:00