Commit Graph

18014 Commits

Author SHA1 Message Date
Javi Martín
5a654d2984 Remove obsolete CSS for the dashboard clipboard
This code isn't used since we removed the copy link feature in commit
5bbf325c1.
2022-10-13 16:03:40 +02:00
Javi Martín
72f9aeb313 Remove obsolete CSS for the verification letter
This code has never been used; it was introduced in commit da86c5d6e,
maybe by accident.
2022-10-13 16:02:31 +02:00
Javi Martín
9b642a0a88 Remove obsolete CSS for the annotator editor
We don't use this editor but our own custom editor, meaning this code
isn't used since commits 54e59a8a5 and bf20c93e9.
2022-10-13 16:02:18 +02:00
Javi Martín
e66aab7d04 Remove obsolete CSS for the help page
This code isn't used since commit d679c1eb7.
2022-10-13 16:00:11 +02:00
Javi Martín
ae218090f4 Remove obsolete CSS for questions geozones
This code isn't used since commit ab63c18d0.
2022-10-13 16:00:07 +02:00
Javi Martín
b8cbdbb2fe Merge pull request #5008 from consul/google_verified
Fix verified check when signing in with Google
2022-10-10 16:42:09 +02:00
Javi Martín
9ba72044e2 Merge pull request #5009 from consul/check_schema
Verify the schema.rb integrity when running our CI
2022-10-10 16:15:56 +02:00
Javi Martín
67b917db13 Fix verified check when signing in with Google
The Google response contains an `email_verified` field instead of a
`verified_email` field, and so we weren't treating verified Google
accounts as verified.
2022-10-10 16:13:10 +02:00
Javi Martín
a86792c9fa Remove unneeded provider key when mocking OmniAuth
OmniAuth already adds the provider to the mock because it's passed as
the first parameter of the `add_mock` method.
2022-10-10 16:13:07 +02:00
Javi Martín
9da44a4538 Verify the schema.rb integrity when running our CI
In the past, we've run into situations where we commited a version of
the schema.rb to version control which wasn't in sync with what you get
when you create the database and run the migrations. This is something
that might happen if you're working on different branches at the same
time, run the migrations in all those branches, and then commit the
current status of your database to your current branch. That will result
in a schema file which contains the database changes done in all these
branches instead of just the current one.

Although this hasn't happened to us for years, we see it happening
sometimes in other COSUL installations, and there's always a chance that
we make a mistake and do it again.

Until now, it wasn't a big deal because the installer sets up the
database by running `db:create db:migrate`, which runs the migrations
instead of using the `schema.rb` file.

However, we're going to add multitenancy using the Aparment gem, and
this gem uses the `schema.rb` file when creating a new schema for a new
tenant [1]. If the `schema.rb` file contains changes that shouldn't be
there, this will lead to different database schemas having different
tables and/or columns and future migrations might crash on production
when applied to some of these schemas. In other words, this mistake
could now result in a disastrous situation.

To help preventing that, we're adding a CI workflow that checks the
current `schema.rb` file is in sync with the database migrations.

[1] https://medium.com/infinite-monkeys/our-multi-tenancy-journey-with-postgres-schemas-and-apartment-6ecda151a21f#7e97
2022-10-08 23:25:55 +02:00
Javi Martín
12e41ae0f3 Merge pull request #4948 from consul/dependabot/bundler/master/omniauth-facebook-9.0.0
Bump omniauth-facebook from 8.0.0 to 9.0.0
2022-10-07 15:33:32 +02:00
dependabot[bot]
d71394e0a4 Bump omniauth-facebook from 8.0.0 to 9.0.0
Bumps [omniauth-facebook](https://github.com/simi/omniauth-facebook) from 8.0.0 to 9.0.0.
- [Release notes](https://github.com/simi/omniauth-facebook/releases)
- [Changelog](https://github.com/simi/omniauth-facebook/blob/master/CHANGELOG.md)
- [Commits](https://github.com/simi/omniauth-facebook/compare/v8.0.0...v9.0.0)

---
updated-dependencies:
- dependency-name: omniauth-facebook
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-07 13:17:25 +02:00
Senén Rodero
9e0c09ebe1 Merge pull request #5004 from consul/omniauth-log
Configure OmniAuth to send log to Rails logger
2022-10-07 12:54:50 +02:00
Javi Martín
7514caad7a Merge pull request #4976 from consul/dependabot/bundler/master/omniauth-google-oauth2-1.0.1
Bump omniauth-google-oauth2 from 1.0.0 to 1.0.1
2022-10-06 17:10:16 +02:00
dependabot[bot]
327bbe055a Bump omniauth-google-oauth2 from 1.0.0 to 1.0.1
Bumps [omniauth-google-oauth2](https://github.com/zquestz/omniauth-google-oauth2) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/zquestz/omniauth-google-oauth2/releases)
- [Changelog](https://github.com/zquestz/omniauth-google-oauth2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zquestz/omniauth-google-oauth2/compare/v1.0.0...v1.0.1)

---
updated-dependencies:
- dependency-name: omniauth-google-oauth2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-06 16:34:06 +02:00
Javi Martín
3244c8df66 Merge pull request #5005 from consul/asset_host
Simplify setting the asset host in mailers
2022-10-06 15:48:05 +02:00
Javi Martín
9812757332 Set the asset host based on default_url_options
We were duplicating the asset host and the URL host in all environments,
but we can make it so the asset host uses the URL host unless we
specifically set it.

Note that, inside the `ApplicationMailer`, the `root_url` method already
uses `default_url_options` to generate the URL.

In the rare case of CONSUL installations who have changed the asset
host, this change has no effect since they'll get a conflict in the
environment files when upgrading and they'll choose to use their own
asset host.
2022-10-06 15:28:29 +02:00
Javi Martín
a729967e8a Make Devise::Mailer inherit from ApplicationMailer
This way we remove duplication in the `from:` proc, the helpers, and the
methods we're about to write.
2022-10-06 13:18:05 +02:00
Javi Martín
e5933ce6bb Merge pull request #5002 from consul/custom_environments
Allow adding per-environment custom settings
2022-10-05 18:00:46 +02:00
Javi Martín
b7e116b53f Allow adding per-environment custom settings
Until now, when editing a specific environment, other CONSUL
installations had to edit the original file, which made it harder to
upgrade.

Now it's possible to change the default CONSUL settings using custom
files, making it easier to upgrade to versions of CONSUL which change
the original environment files (which is very common when upgrading
versions of Rails).
2022-10-05 17:25:47 +02:00
Senén Rodero Rodríguez
ddc7b626f5 Configure OmniAuth to send log to Rails logger
Before this change log generated by OmniAuth was sent to the STDOUT. Now
developers will find those gems log within the `app/log` directory as expected.
2022-10-05 12:48:13 +02:00
Javi Martín
3e726357eb Merge pull request #5000 from consul/remove_setting_url
Remove URL setting
2022-10-04 16:16:50 +02:00
Javi Martín
28cff52da6 Merge pull request #4999 from consul/unused_tasks
Remove obsolete rake tasks
2022-10-04 14:36:39 +02:00
Javi Martín
f871658510 Use default_url_options to generate absolute URLs
In the dev seeds, we were using `Setting["url"]/proposals`, but we can
use `proposals_url` instead, similar to what we do in the rest of the
application.

We can do a similar thing in the sitemap. This way the sitemap will also
work on installations who haven't manually set the "url" setting.

Since we aren't using `Setting["url"]` anywhere anymore, we're removing
it.

This setting was mainly redundant, since we already had the
`server_name` in the secrets. Furthermore, `server_name` is
automatically configured when running the installer, while
`Setting["url"]` had to be manually set in the admin section the
application was installed.

Note we're using `ActionMailer::Base` setting to generate URLs. Sounds a
bit strange, but it's a standard way Rails provides to generate URLs
outside the context of a request.
2022-10-02 16:54:06 +02:00
Javi Martín
17ff1ac74c Simplify article publisher URL
We've been using the `url` Setting for a long time, but since then we've
added a few references to `root_url` to this file, so we're now adding
consistency. We're also removing a now unnecessary condition.
2022-10-02 16:54:06 +02:00
Javi Martín
adfb141d1b Simplify URL validation in related content
We were using `Setting["url"]` to verify the content belonged to the
application URL, but we can use `root_url` instead.

Note that means we need to include the port when filling in forms in the
tests, since in tests URL helpers like `polymorphic_url` don't include
the port, but a port is automatically added when actually making the
request.
2022-10-02 16:54:06 +02:00
Javi Martín
f15f250150 Remove unused task to reset the vote counters
This task was added in commit 2b9b78e38. According to the notes in the
pull request introducing the change:

> If you have had [map validations] in production, you might want to run
> the rake task votes:reset_vote_counter to reset the cached votes
> counter. Otherwise, until there is another vote for a proposal, the
> counter will not be updated, and there might be some votes which are
> not yet displayed

In short, this was a task that was introduced for a specific release and
had to be run manually. So we can remove it now.
2022-10-02 16:52:59 +02:00
Javi Martín
e221c3cd1a Remove unused task to send dashboard notifications
This task was "temporarily" removed in commit 7b6619528. Since that was
done three and a half years ago, right after the dashboard was
introduced, I think it's time to make this "temporary" measure a bit
more permanent ;).
2022-10-02 16:52:59 +02:00
Javi Martín
5719f32758 Remove tasks to upgrade to version 1.5.0
These tasks are not needed for new installations, and in existing
installations they've already been executed when upgrading to version
1.5.0.
2022-10-02 16:52:59 +02:00
Senén Rodero Rodríguez
527d5691f7 Make poll feature work in browsers with javascript disabled
By using the Rails `button_to` helper (which generates a form), and adapting the
response to `html` and `js` formats, the feature works with or without javascript
enabled.
2022-09-22 17:39:57 +02:00
Senén Rodero Rodríguez
64676be246 Remove token column from poll_voters table
As it is no longer used as originally pretended [1][2].

[1] Check consul/consul pull request 1994
[2] Check consul/consul pull request 3539
2022-09-22 10:34:07 +02:00
Alex
bb52adec37 Update kanban.yml
repository-projects: write is not needed because secrets.KANBAN_TOKEN is used
2022-09-20 19:39:46 +01:00
Sebastia
dd04765af3 Merge pull request #4904 from consul/poll_restrictions
Don't allow modifying already started polls
2022-09-20 19:32:43 +02:00
Javi Martín
24099e880b Fix crash when adding invalid documents to answers
We were rendering the `new` action, but that action doesn't exist.
Before commit ec861ca8e, we were rendering the `edit` action of an
answer, which was confusing as well.

Note that, when adding an invalid document, `@answer.documents` contains
that invalid document (which is not present in the database). Since
we're rendering the index, this new document would appear in the list of
the documents that can be deleted; to avoid that, we're kind of
"reloading" the answer object in the component by finding the record in
the database. We aren't using `@answer.reload` because doing so would
remove the validation errors.
2022-09-20 17:50:49 +02:00
Javi Martín
518af3eb97 Remove duplication in poll actions tables
We were using the same logic in four different places, so we're creating
a new class to handle that logic.

Note that I didn't find a way to delegate the `content` method to a
`Admin::TableActionsComponent`, so we're delegating the `action` method
instead. That means we need to create a method returning an
`Admin::TableActionsComponent`. We also need to cache this object;
otherwise we were getting an error when calling `actions.action` from
the `Admin::Poll::Questions::TableActionsComponent`.
2022-09-20 17:50:49 +02:00
Julian Herrero
4c8f247de7 Don't allow to modify answer's documents for started polls 2022-09-20 17:50:49 +02:00
Julian Herrero
245594f32b Don't allow to modify answer's images for started polls
Note that the `create` action doesn't create an image but updates an
answer instead. We're removing the references to `:create` in the
abilities since it isn't used.

In the future we might change the form to add an image to an answer
because it's been broken for ages since it shows all the attached
images.
2022-09-20 17:50:49 +02:00
Julian Herrero
5fe86264ca Don't allow to modify answer's videos for started polls
Same rules that will apply for the answer itself should apply for the
attachments like videos, images, and/or documents.
2022-09-20 17:50:49 +02:00
Julian Herrero
14542df0de Allow to delete answers if the poll has not started yet
Deleting answers was not even possible. But it was possible to delete
questions. So we implemented the same behavior.
2022-09-20 17:50:49 +02:00
Julian Herrero
3a6e99cb8c Don't allow changing answers if the poll has started
Just like we did with questions.
2022-09-20 17:50:49 +02:00
taitus
7a812a82e2 Remove redundant expectations in questions test 2022-09-20 17:50:49 +02:00
Julian Herrero
8a26954bc5 Don't allow to modify questions for started polls
Adding, modifiying, and/or deleting questions for an already started
poll is far away from being democratic and can lead to unwanted side
effects like missing votes in the results or stats.

So, from now on, only modifiying questions will be possible only if
the poll has not started yet.
2022-09-20 17:50:35 +02:00
taitus
d499a6944e Fix typos in success messages 2022-09-20 17:29:04 +02:00
Javi Martín
4c8be42ea1 Simplify new question form
In this form, the only case where `poll` might be present without
`question.poll` being present to is going to be the `new` action. We can
assign the poll in the `new` action and get rid of the `poll` variable
in the form.
2022-09-20 17:29:04 +02:00
Javi Martín
d561a295e7 Move question form view to component 2022-09-20 17:29:04 +02:00
Julian Herrero
ecd22131f1 Disallow to modify the end date for an ended poll 2022-09-20 17:29:01 +02:00
Julian Herrero
8b5c315eb0 Allow to modify the end date as long as it is not to the past 2022-09-20 17:21:39 +02:00
Julian Herrero
471096c698 Disallow to modify the start date for an already started poll
We need to update a couple of tests because a poll is created in the
tests with a timestamp that includes nanoseconds and in the form to edit
the time of the poll the nanoseconds are not sent, meaning it was
detected as a change.
2022-09-20 17:21:36 +02:00
Javi Martín
a774456b51 Simplify test to edit a poll
Instead of having to add `beginning_of_minute` to deal with an issue
with Capybara filling datetime fields as mentioned in commit 5a0fde4048,
we can travel to the beginning of the minute so we don't have to take
the seconds into account.
2022-09-20 13:38:00 +02:00
taitus
b41fbfa52d Avoid updating ddbb after visiting a page in tests
The extra check to see the voter count has increased was redundant; we
already check the request has finished inside the
`vote_for_poll_via_web` method and we check all three voters are created
in the results table.

Updating the poll so it's in the past after starting the browser might
result in database inconsistencies while running the tests, so we're
using `travel_to` instead.
2022-09-20 13:38:00 +02:00