Commit Graph

46 Commits

Author SHA1 Message Date
Javi Martín
5b6de96241 Add and apply MultilineMethodCallIndentation 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
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
taitus
ac144d172d Move document attributes to concern 2021-04-09 16:21:00 +02:00
Javi Martín
ea2aeab383 Apply rubocop Rails/FindBy rule everywhere
We didn't detect these cases because by default the rule only searches
for offenses in `app/models/`.
2019-11-08 19:15:04 +01:00
Javi Martín
e21565628f Apply Layout/IndentAssignment rubocop rule
There was one place where we weren't applying it.
2019-10-26 13:03:48 +02:00
Javi Martín
7ca55c44e0 Apply Rails/SaveBang rubocop rule
Having exceptions is better than having silent bugs.

There are a few methods I've kept the same way they were.

The `RelatedContentScore#score_with_opposite` method is a bit peculiar:
it creates scores for both itself and the opposite related content,
which means the opposite related content will try to create the same
scores as well.

We've already got a test to check `Budget::Ballot#add_investment` when
creating a line fails ("Edge case voting a non-elegible investment").

Finally, the method `User#send_oauth_confirmation_instructions` doesn't
update the record when the email address isn't already present, leading
to the test "Try to register with the email of an already existing user,
when an unconfirmed email was provided by oauth" fo fail if we raise an
exception for an invalid user. That's because updating a user's email
doesn't update the database automatically, but instead a confirmation
email is sent.

There are also a few false positives for classes which don't have bang
methods (like the GraphQL classes) or destroying attachments.

For these reasons, I'm adding the rule with a "Refactor" severity,
meaning it's a rule we can break if necessary.
2019-10-23 14:39:31 +02:00
Javi Martín
70a07c095f Add and apply Style/BlockDelimiters rubocop rule
We were already using it most of the time, but there were a few places
were we used brackets for multiline blocks.
2019-10-05 14:44:14 +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
488461b8ac Remove consecutive blank lines 2019-09-10 20:02:15 +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
decabeza
3855bf26ad Allow users to delete dashboard polls 2019-05-31 11:55:23 +02:00
decabeza
6b7c6a2f1f Refactor dashboard polls controller 2019-05-31 11:55:20 +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
55c8fa3297 Fix obsolete respond_with_bip usage
Since we removed the `best_in_place` gem, this method doesn't exist
anymore. We're replacing it with what the method actually does.

Note the test doesn't check the poll is correctly updated. We could add
a `visit proposal_dashboard_polls_path(proposal)` before checking the
"Show results" field, but then we would enter a race condition between
this request and the AJAX request. A proper solution would be to provide
actual feedback to the user so they know the poll has been updated, and
then checking that feedback is present in the tests.
2019-05-09 19:41:04 +02:00
voodoorai2000
dfbdc0568c Allow actions to be unexecuted
Before actions could be marked as executed. With this commit we are also allowing actions to be marked as unexecuted.
2019-04-29 15:43:53 +02:00
decabeza
91be3cf775 Fix more hound warnings 2019-03-27 15:22:14 +01:00
Raimond Garcia
f6526f4a45 Merge pull request #3271 from Platoniq/dashboard-user-communication
Dashboard user communication
2019-03-26 12:10:18 +01:00
Senén Rodero Rodríguez
9d9ad5003b Add given_order to related poll question answers forms
Since given order is no longer being generated automatically we need
to add it to related forms and to strong parameters methods
2019-03-21 14:51:17 +01:00
taitus
a1de5b2334 Display tag "new" on actions
An author will see a "new" tag on each action or resource that has appeared on his dashboard since his last login.
Too add "new" tag on dashbord menu when there are new resources.
2019-03-21 12:29:31 +01:00
Alberto
7b2258aeb0 Merge pull request #3263 from Platoniq/dashboard-recommended-actions-page
Dashboard recommended actions page
2019-03-19 16:21:28 +01:00
taitus
487c485fe0 Add new section on sidebar menu for recommended proposals
- Display recommended_proposals on new section as goals with toogle.
- Divide recommended actions into actions done and actions pending to clarify the information to the user as summary_recomended_actions.
2019-02-04 11:48:47 +01:00
taitus
a6d822cc7a Add zoom and dpi values to correct the pdf display when environment is not development. 2019-02-02 19:18:27 +01:00
decabeza
f4d9fe2417 Updates dashboard poster controller 2018-10-17 01:12:34 +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
42d448248c Routes have been refactored
Dashboard routes have been refactored. Now instead of having resources
for dashboard and routes inside a dashboard namespace the proposal
routes contain a dashboar singleton containing everything related to it.
2018-09-17 15:44:45 +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
Juan Salvador Pérez García
5b5095b37b Bugfixing and several enhancements
* Added missing specs
* Removed models that were refactored previously
* Added simplecov when executing specs locally
* Fixed bug in poll model validation that was causing an 500 error.
2018-08-01 13:26:30 +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
Juan Salvador Pérez García
8876b285ce Fixes #229
Adds email feature for proposals dashboard
2018-07-25 13:28:44 +02:00
Juan Salvador Pérez García
e5f9cf6710 Fixed #239
Proposals dashboard refactored to dashboard.
Added missing specs for the dashboard.
2018-07-24 15:52:43 +02:00
Juan Salvador Pérez García
4b8cc85c49 Fixes #234
View questions now is View results and redirects to results
in public view.

Fixed flaky spec that was making the tests fail.

Added missing specs for polls feature as well as poll model.
2018-07-19 17:15:05 +02:00
Juan Salvador Pérez García
f439fc7371 Fixes #218
Added check in poll card that allows setting the value of
results_enabled flag.

Access to stats/results now is controlled with abilities.

Polls related to proposals will be accessible to the proposal author
like they were administrators.
2018-07-17 17:59:12 +02:00
Juan Salvador Pérez García
39599e39ec Fixes #190
Shows next goal information in progress page.
Fixed missing poll feature in features section.
2018-07-17 17:59:11 +02:00
Juan Salvador Pérez García
0a790b4479 Fixes #191
Shows goals in progress graphic
2018-07-17 17:59:11 +02:00
Juan Salvador Pérez García
caffd97cc8 Implements #182
Implements 182. resources are shown as cards in dashboard progress view.
Implements #182

Implements 182. resources are shown as cards in dashboard progress view.
2018-07-17 17:59:11 +02:00
Juan Salvador Pérez García
9f0ca0cec7 Fixes #180
Help text added for  actions form.
Fixed invialid redirection in dashboard
2018-07-17 17:59:11 +02:00
Juan Salvador Pérez García
f5e5c62242 Changes in public view for porposal polls
Back to polls has dissapeared. A link 'Back to proposal' will be shown
instead.

The button that invites the user to take part in other polls has been
removed.

Stats will flagged as disabled when a poll for a proposal is created.
2018-07-17 17:59:11 +02:00
Juan Salvador Pérez García
5e71a21975 Removed fields from poll create form.
Poll form won't include geozones related attributes, resume nor image.
2018-07-17 17:58:22 +02:00
Juan Salvador Pérez García
53baf983b5 Implements #169
Community counter now shows the community members. For performance
reasons this information is refresed once per hour.
2018-07-17 17:57:30 +02:00
Juan Salvador Pérez García
59eb1a4f47 Adds progress indicator 2018-07-17 17:57:30 +02:00
Juan Salvador Pérez García
2be107f4da Specs
Added specs and fixed some issues found after executing them
2018-07-17 17:57:30 +02:00
Juan Salvador Pérez García
2ce9f95283 Polls in the dashboard
A reduced version of polls has been added to the dashboard
2018-07-17 17:57:30 +02:00