Commit Graph

21 Commits

Author SHA1 Message Date
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
taitus
2425d0ecfc Remove unused code
In the commit: 315c57929a this code was added, but at that time this field
was no longer in use, even though it existed in the database.

I don't know why this line was added, but there seems to be no point in
keeping it.
2023-05-29 15:11:38 +02:00
Javi Martín
9b908d7264 Extract component to render account permissions
We were using similar code in four different places; six, if we count
the welcome pages seeds. Reducing duplication in the pages seeds is a
bit tricky because administrators are supposed to edit their content and
might remove the HTML class we use to define styles. However, we can
share the code everywhere else.

Note that there's a bug in the application since we show that level 2
users cannot vote for budget projects but we give them permission to do
so in the abilities model. We're keeping the same behavior after this
refactoring but we might change it in the future.
2022-11-29 18:48:24 +01: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
ac5c9459c7 Add and apply Style/StringChars rubocop rule
This rule was added in Rubocop 1.12.0.
2021-09-03 11:49:53 +02:00
Javi Martín
aef1e4660f Add and apply Style/RedundantArgument rubocop rule
This rule was added in rubocop 1.4.0.
2021-09-03 11:49:53 +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
27468b0b7b Use relative URLs where possible
In general, we always use relative URLs (using `_path`), but sometimes
we were accidentally using absolute URLs (using `_url`). It's been
reported i might cause some isuses if accepting both HTTP and HTTPS
connections, although we've never seen the case.

In any case, this change makes the code more consistent and makes the
generated HTML cleaner.
2019-10-20 17:26:14 +02:00
rgarcia
a4f0161aa8 fixes specs related to ActionController params 2019-04-17 17:40:55 +02:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
iagirre
e8b91356b3 Backend functionality to let managers update users password
The back button when the user changes the password
(in the print password page) redirects to the
edit manually page.

The routes to access password edit pages has been added,
along with the ones to send reset password email and
reset password manually.
2018-04-02 09:43:24 +02:00
Juanjo Bazán
315c57929a allows managers to create users without email
allows managers to create users without email

hides email preferences from account page for email-less users

prevents email delivery to users with no email

adds spec for user creation from management

adds specs for user's email requirement

adds spec for no deliveries if no email
2017-06-19 13:02:48 +02:00
Alberto Garcia Cabeza
dadfdba1b1 adds date of birth form when manager creates new user 2017-03-20 11:59:22 +01:00
kikito
f0b8cfd4a2 Time.now -> Time.current 2016-11-23 19:19:19 +01:00
Juanjo Bazán
ce477273da adds managers option to delete a level 2 account 2016-04-08 11:03:30 +02:00
Juanjo Bazán
510d85cf97 unifies session key 2015-10-23 14:05:23 +02:00
rgarcia
b2bd3d455b differentiates between manager session and managed user session 2015-10-12 14:05:51 +02:00
rgarcia
f55c3974aa refactors managed user info into management layout 2015-10-12 14:05:06 +02:00
rgarcia
5feef066dc adds managed user to session 2015-10-11 16:56:16 +02:00
rgarcia
3fe8b6e603 adds consistency to spacing 2015-10-11 16:50:27 +02:00
kikito
5f74528f12 Modifies devise so that unconfirmed users w/o password can set it when confirming their account 2015-10-07 20:18:54 +02:00