Commit Graph

15065 Commits

Author SHA1 Message Date
Javier Martín
056ce1d79b Merge pull request #3746 from consul/active_record_labels
Use active record translations for labels
2019-10-07 02:40:19 +02:00
Javi Martín
bbbd0820c1 Use active record translations in votation types
We need to build a votation type object in the form so translations are
applied automatically.
2019-10-07 01:56:24 +02:00
Javi Martín
9ddbd01f91 Use active model translations for labels
The same way we did for Active Record, but this time we do it for models
not inheriting fom Active Record.
2019-10-07 01:56:24 +02:00
Javi Martín
6fa67b5e53 Use active record translations for labels
This way we can simplify the way we generate form fields. In some cases,
we also use the human attribute in table headers, which IMHO makes
sense.

I haven't moved all of them: for example, sometimes a label is
different depending on whether it's shown to administrators, valuators,
or users. And I haven't touched the ones related to devise, since I
wasn't sure about possible side effects.

Note I've also removed placeholders when they had the same text as their
labels, since they weren't helpful. On the contrary, the added redundant
text to the form, potentially distracting users.
2019-10-07 01:56:23 +02:00
Javi Martín
1bc66925ab Remove redundant labels
We already had translations for these attributes.
2019-10-07 01:55:56 +02:00
Javi Martín
7aae842b38 Fix missing proposal translations 2019-10-06 20:33:55 +02:00
Javier Martín
24ccee0df4 Merge pull request #3745 from consul/auto_labels
Simplify generating form fields with labels
2019-10-06 20:32:50 +02:00
Javi Martín
4f1131d2e5 Add labels to radio buttons automatically 2019-10-06 20:06:00 +02:00
Javi Martín
aec84f6522 Generate labels for attribute automatically
I'm not sure why it isn't already done by foundation's form builder. It
doesn't make any sense to change an ID of a form field without changing
the `for` attribute of its label.
2019-10-06 19:32:04 +02:00
Javi Martín
8d9cb4d8e3 Simplify generating checkboxes in forms
Using the block syntax to generate the label with a <span> tag inside
isn't necessary after upgrading foundation_rails_helpers. Before the
upgrade, we couldn't do so because the <span> tag was escaped.
2019-10-06 19:32:04 +02:00
Javi Martín
5fe56a62f1 Remove useless label false parameter in select_tag
`select_tag` creates just a select with no label, so there's no need to
specify `label: false`.
2019-10-06 19:32:04 +02:00
Javi Martín
4f5de5be3b Add aria-describedby attribute automatically
We were manually adding the attribute in many places, but not
everywhere. I'm assuming adding it where we didn't have it is doing no
harm.
2019-10-06 19:32:03 +02:00
Javi Martín
4a19bb6b77 Simplify generating fields with hints
We were already using this code in translatable forms. Using it on every
form means we can reduce the code we need to generate a field with a
hint.
2019-10-06 18:03:38 +02:00
Javi Martín
ae6fab9f5e Inherit from builder instead of monkey patching it
We were monkey-patching FoundationRailsHelper::Formbuilder, which made
form customization difficult. We can inherit from it, which is the
standard way of extending what an existing class does, and make our form
the default one.
2019-10-05 16:01:58 +02:00
Javi Martín
3ea9f3cecf Simplify generating form fields with labels
Instead of generating the label and then a field without a label, we can
directly generate a field with a label.
2019-10-05 16:01:58 +02:00
Javier Martín
42dbbf5507 Merge pull request #3735 from consul/rubocop_lint
Add rubocop lint rules
2019-10-05 15:50:01 +02:00
Javier Martín
fb2476a651 Merge pull request #3738 from consul/rubocop_fixes
Add rubocop rule for multiline blocks
2019-10-05 15:40:19 +02:00
Javi Martín
871fa020a5 Add and apply ParenthesesAsGroupedExpression rule 2019-10-05 15:03:26 +02:00
Javi Martín
447c970eb3 Remove unused block arguments
There are more cases where we have unused block arguments, but I'm only
changing the obvious ones.
2019-10-05 15:03:26 +02:00
Javi Martín
93a2ebd46f Add and apply DuplicateMethods rubocop rule
These methods were defined with `attr_reader` (or accessor in some
cases) and then they were redefined.
2019-10-05 15:03:26 +02:00
Javi Martín
6ffe563264 Add an apply StringConversionInInterpolation rule 2019-10-05 15:03:26 +02:00
Javi Martín
9c3686a6d8 Remove unused block parameters
We're using `yield` in the method body.
2019-10-05 15:03:25 +02:00
Javier Martín
deba0b1a75 Merge pull request #3741 from consul/extract_vote_message
Extract partials to show "sign in to vote" message
2019-10-05 14:58:54 +02:00
Javi Martín
2fed7b9db3 Add and apply AmbiguousRegexpLiteral rule
This is a very subtle behaviour: `match /attachment/i` could represent a
regular expression, but it could also represent a division like
`match / attachment / i`. So we need to make an exception to the usual
way we omit parenthesis in RSpec expectations.
2019-10-05 14:47:19 +02:00
Javi Martín
d6eb9f8fb6 Add and apply ShadowingOuterLocalVariable rule
Naming two variables the same way is confusing at the very least, and
can lead to hard to debug errors. That's why the Ruby interpreter issues
a warning when we do so.
2019-10-05 14:47:19 +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
d42b9ff4a5 Extract method to get valid answers to a question
This way we remove duplication and we avoid a multi-line block in a
validation rule, which made the code hard to read.
2019-10-05 14:34:52 +02:00
Javi Martín
657f8d129c Use class methods for multi-line scopes
Some of our team members don't like using `do...end` for scopes, and
some other team members don't like using `{ ... }` for multi-line
blocks, so we've agreed to use class methods instead.
2019-10-05 14:34:52 +02:00
Javi Martín
21f9d8e1b4 Fix missing double quotes
It could be argued that the following lines use single quotes to escape
double quotes, but on the other hand, using a single quote isn't a
great benefit.
2019-10-05 14:32:46 +02:00
Javi Martín
86a205c8fc Extract link to verify account to a mehtod
We were using the same text and the same route in many places.
2019-10-05 14:20:03 +02:00
Javi Martín
f8bd3d4f39 Extract links to signin and signup to methods 2019-10-05 14:07:24 +02:00
Javi Martín
9289a051c3 Extract partial to show "sign in to vote" message 2019-10-05 14:07:24 +02:00
Javi Martín
f5d8badeb6 Extract partial to show "login to comment" message 2019-10-05 14:07:24 +02:00
Javi Martín
2ccc283bb7 Use the same I18n key for "verify account" text
We were using several different keys, all of them having the same text.
2019-10-05 14:07:24 +02:00
Javi Martín
78c6f6f7e9 Use the same key for "signin" and "signup" texts
We were using the same texts in several places
2019-10-05 14:07:23 +02:00
Javi Martín
ae64458fce Use the same I18n key for "login to comment" text
We were using several different keys, all of them having the same
translations.
2019-10-05 14:07:23 +02:00
Javier Martín
f018706e6b Merge pull request #3740 from consul/remove_obsolete_code
Remove leftover code
2019-10-05 04:11:58 +02:00
cyrillefr
44b2a07878 Moderate legislation proposals (#3602)
Moderate legislation proposals

- added a controller for moderation/legislation
- updated view to appropriate link + added route
- added a spec
- Feature test
- test for faded
- javascripts for visual effects
2019-10-05 04:02:39 +02:00
Javi Martín
27522f60e7 Remove unneeded GET method
Links already use GET by default, so there's no need to specify it.
Furthermore, using `method: :get` makes a link incompatible with
turbolinks.
2019-10-05 03:38:44 +02:00
Javi Martín
ad14636255 Use Tag instead of ActsAsTaggableOn::Tag
It's shorter, it's easier to extend its behaviour, and it's easier to
integrate with other parts of our application, like translations.
2019-10-05 03:38:44 +02:00
Javi Martín
f444533956 Remove legacy reference to flash[:html_safe]
This code doesn't work since commit a5338a44.
2019-10-05 03:38:44 +02:00
Javi Martín
c6c3ff5423 Remove leftover sandbox code
The rest of the sandbox code was removed in commit d679c1eb.
2019-10-05 03:38:44 +02:00
Javi Martín
21fcdba8c8 Remove obsolete method
This method wasn't used since commit 24dde9c3.
2019-10-05 03:38:44 +02:00
Javier Martín
d193fd9740 Merge pull request #3666 from consul/dependabot/bundler/foundation_rails_helper-3.0.0
Bump foundation_rails_helper from 2.0.0 to 3.0.0
2019-10-05 03:02:51 +02:00
Javi Martín
e524374293 Use new foundation helper classes in tests 2019-10-03 17:30:12 +02:00
dependabot-preview[bot]
26201d4fc2 Bump foundation_rails_helper from 2.0.0 to 3.0.0
Bumps [foundation_rails_helper](https://github.com/sgruhier/foundation_rails_helper) from 2.0.0 to 3.0.0.
- [Release notes](https://github.com/sgruhier/foundation_rails_helper/releases)
- [Changelog](https://github.com/sgruhier/foundation_rails_helper/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sgruhier/foundation_rails_helper/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-03 03:22:21 +00:00
Javi Martín
74500db173 Update indentation consistency rubocop rule
The indentation mode has been renamed.
2019-10-01 18:01:08 +02:00
dependabot-preview[bot]
d827946a10 Bump rubocop from 0.60.0 to 0.75.0
Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.60.0 to 0.75.0.
- [Release notes](https://github.com/rubocop-hq/rubocop/releases)
- [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.60.0...v0.75.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-01 14:32:18 +00:00
Javier Martín
460d3271b3 Merge pull request #3737 from consul/dependabot/bundler/rubyzip-1.3.0
[Security] Bump rubyzip from 1.2.2 to 1.3.0
2019-10-01 16:30:16 +02:00
dependabot-preview[bot]
235ee0fb83 [Security] Bump rubyzip from 1.2.2 to 1.3.0
Bumps [rubyzip](https://github.com/rubyzip/rubyzip) from 1.2.2 to 1.3.0. **This update includes a security fix.**
- [Release notes](https://github.com/rubyzip/rubyzip/releases)
- [Changelog](https://github.com/rubyzip/rubyzip/blob/master/Changelog.md)
- [Commits](https://github.com/rubyzip/rubyzip/compare/v1.2.2...v1.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-01 13:06:28 +00:00