Commit Graph

18014 Commits

Author SHA1 Message Date
Julian Herrero
855fedc025 Allow only creation of polls with dates that are not in the past 2022-09-20 13:37:56 +02:00
Javi Martín
05dbae5a3c Merge pull request #4989 from consul/add_time_to_polls
Allow selecting the time when a poll starts/ends
2022-09-14 15:31:39 +02:00
taitus
d0359d584e Remove trait :current for poll on factories
When we create a poll with "create(:poll)" it is already a current poll.
2022-09-14 15:14:23 +02:00
Javi Martín
5a0fde4048 Allow selecting the time when a poll starts/ends
We were already saving it as a time, but we didn't offer an interface to
select the time due to lack of decent browser support for this field
back when this feature was added.

However, nowadays all major browsers support this field type and, at the
time of writing, at least 86.5% of the browsers support it [1]. This
percentage could be much higher, since support in 11.25% of the browsers
is unknown.

Note we still need to support the case where this field isn't supported,
and so we offer a fallback and on the server side we don't assume we're
always getting a time. We're doing a strange hack so we set the field
type to text before changing its value; otherwise old Firefox browsers
crashed.

Also note that, until now, we were storing end dates in the database as
a date with 00:00 as its time, but we were considering the poll to be
open until 23:59 that day. So, in order to keep backwards compatibility,
we're adding a task to update the dates of existing polls so we get the
same behavior we had until now.

This also means budget polls are now created so they end at the
beginning of the day when the balloting phase ends. This is consistent
with the dates we display in the budget phases table.

Finally, there's one test where we're using `beginning_of_minute` when
creating a poll. That's because Chrome provides an interface to enter a
time in a `%H:%M` format when the "seconds" value of the provided time
is zero. However, when the "seconds" value isn't zero, Chrome provides
an interface to enter a time in a `%H:%M:%S` format. Since Capybara
doesn't enter the seconds when using `fill_in` with a time, the test
failed when Capybara tried to enter a time in the `%H:%M` format when
Chrome expected a time in the `%H:%M:%S` format.

To solve this last point, an alternative would be to manually provide
the format when using `fill_in` so it includes the seconds.

[1] https://caniuse.com/mdn-html_elements_input_type_datetime-local
2022-09-14 15:14:23 +02:00
Javi Martín
f5a524d503 Make poll scope more readable
This was the only place where we used the `? <= field` format; we use
the `field >= ?` format everywhere else.

We're also adding a variable to make it easier to understand that the
value is the same in both cases and to make the line shorter ;).
2022-09-14 15:14:23 +02:00
Javi Martín
3543767951 Don't include current polls in recounting polls
On the day when a poll ends, it was considered both current and
recounting.
2022-09-14 15:14:23 +02:00
Javi Martín
2153bd9e98 Add tests for current/expired/recounting polls
We didn't have model tests for some of these scopes, and neither scope
tests nor instance method tests covered edge cases like the current
date.
2022-09-14 15:14:23 +02:00
Javi Martín
bd85a09d32 Group poll scopes tests together
We're also using the convention of using a `.` to describe class
methods.
2022-09-14 15:14:23 +02:00
Javi Martín
90d5759c23 Show the precise ending time unless it's midnight
The reason why we were displaying the ending date as "one second before
the actual ending" was that, when seeing that a phase ends at a date
like "2000-12-31 00:00", we might end up thinking that the phase will
finished at the midnight between December 31st and January the 1st,
while it actually ends at the midnight between December the 30th and
December the 31st.

This is particularly important because we use a date field to select the
date of a phase and if select December the 31st, it will be stored in
the database as "2000-12-31 00:00". So, instead, in this case we display
"2000-12-30 23:59", which is less confusing.

But now we're going to add support for setting a time on polls, which
means a certain poll might end at 15:30. In this case, displaying that
it ends at 15:29 doesn't make much sense.
2022-09-14 15:14:23 +02:00
Javi Martín
7227815a16 Split duration component in two
We were displaying dates in two different formats in the same component,
leading to strange hacks like manually calling the `call` method or not
being able to use `render_inline` in the tests.

Since we're going to reuse one of these formats outside the budgets
section, we're splitting the component. We're also removing the
mentioned hacks.
2022-09-14 15:14:23 +02:00
Javi Martín
67d13d2899 Show the time when a poll starts and ends
This is consistent with the way we show the duration of a budget and its
phases. Since budgets are the section with the most recent changes in
the admin area, we're using it as a reference.

Note that, unlike budgets (which are shown to finish at the beginning of
their ending day), a poll has always been considered to finish at the
end of their ending day, so we're showing it this way.

We're also solving a minor usability issue. While it's pretty intuitive
that a poll starting on a certain date will start at the beginning of
the day, a poll ending on a certain date isn't clear about when it
finishes exactly: is it at the beginning of the day, or at the end of
the day?

So now we're making this point clear.
2022-09-14 15:14:23 +02:00
Sebastia
eaafc7a438 Merge pull request #4990 from consul/improve-polls
Refactor admin poll section
2022-09-14 15:13:33 +02:00
taitus
86ff4eeff9 Add consistency to back_links
In some cases (e.g. after editing or creating a resource
with errors) the default back_link did not redirect to the
expected page.

Now we force the back_links to the index pages, so we
always get the desired redirect.
2022-09-14 14:56:27 +02:00
taitus
2d353ba893 Remove unused routes related to documents
These routes aren't used since commits (2993ef8707, 88a7a29d27)
In parallel while these routes were being removed, the route file
was being split into different files, and they were included again
in the commit 1cd47da9d4.
2022-09-14 14:45:37 +02:00
taitus
83e0d4c6b7 Add load_and_authorize_resource to images controller 2022-09-14 14:45:37 +02:00
taitus
99495a21d2 Add load_and_authorize_resource to videos controller 2022-09-14 14:45:36 +02:00
taitus
b17b03099c Load videos through answer in all actions 2022-09-14 14:45:36 +02:00
taitus
919534fbc5 Unify with the rest of application destroy method in videos controller 2022-09-14 14:45:36 +02:00
taitus
1ec793863b Add missing system specs for poll question answer videos
Minor change for replace @video.answer_id to @video.answer.
2022-09-14 14:45:35 +02:00
taitus
3d1a9501aa Remove unused resource controller methods
These methods aren't necessary since commit 71601bd3f.
2022-09-14 14:45:35 +02:00
Julian Herrero
24276a201e Remove useless answers show view
Until now, in order to edit an answer, we had to click on its title on
the table and then on the "Edit answer" link.

That was tedious and different from what we usually do in the admin
section. Furthermore, the code for the answers table was written twice
and when we modified it we forgot to update the one in the `show`
action, meaning the table here provided less information than the
information present in the answers tables.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2022-09-14 14:45:35 +02:00
Javi Martín
78ed5a8bfc Use caption instead of tr to label the answers table
We might change the style of this caption or remove it completely in the
future. In the meantime, we use the right HTML tag for the task to give
information regarding what the table is about, and that tag is
`<caption>`.
2022-09-14 14:45:35 +02:00
taitus
ec861ca8e6 Extract documents action from Answer controller
This way we have a controller just to manage
Poll::Question::Answer related documents in the
same way we have for videos and images.
2022-09-14 14:45:34 +02:00
taitus
cb2958e1b0 Add load_and_authorize_resource to answers controller 2022-09-14 14:45:34 +02:00
taitus
405b37f605 Load answer through question in answers controller
We are simplifying the load answer and we can remove the ambiguous
hidden field from answer form.
2022-09-14 14:45:33 +02:00
taitus
01005b50cb Load question from load_and_authorize_resource in answers controller 2022-09-14 14:45:33 +02:00
taitus
8b4cd13675 Unify with the rest of application destroy method in questions controller
We also add a missing translation.
2022-09-14 11:37:21 +02:00
taitus
ad9362399e After destroy question redirect to his poll show page
After removing a question from a poll it makes more sense to redirect to
your own poll show page in order to manage their questions.

Currently it is redirecting to the questions index page where all the
questions from all the polls are displayed and takes you completely out
of the context of the poll you are in.

In the future we will remove this index question page.
2022-09-14 11:37:20 +02:00
taitus
cc4b22ee37 Use resource from load_and_authorize_resource in admin polls controller 2022-09-09 11:01:55 +02:00
taitus
38b6cf36a2 Remove unused add_question action from admin polls controller
Since commit adf18ee756  this action no longer makes sense.
2022-09-07 14:25:15 +02:00
taitus
5011d4745b Remove related code for unused actions from admin polls controller
Actions :search_booths and :search_officers in admin polls controller
are moved to other controllers since commit 20e31133a for
:search_booths and commit 19ec7f93b for :search_officers.

This then allows us to remove the code that references these actions in
the controller and in the administrator abilities.
2022-09-07 13:41:26 +02:00
Alex
40886704bb Update kanban.yml
Signed-off-by: sashashura <93376818+sashashura@users.noreply.github.com>
2022-08-29 20:07:04 +01:00
Javi Martín
b9d63bc2ab Merge pull request #4971 from consul/dependabot/bundler/master/ahoy_matey-4.1.0
Bump ahoy_matey from 3.2.0 to 4.1.0
2022-08-27 00:35:47 +02:00
dependabot[bot]
0502c55b77 Bump ahoy_matey from 3.2.0 to 4.1.0
Bumps [ahoy_matey](https://github.com/ankane/ahoy) from 3.2.0 to 4.1.0.
- [Release notes](https://github.com/ankane/ahoy/releases)
- [Changelog](https://github.com/ankane/ahoy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ankane/ahoy/compare/v3.2.0...v4.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-27 00:19:04 +02:00
Javi Martín
0ab11f73f7 Merge pull request #4968 from consul/dependabot/bundler/master/uuidtools-2.2.0
Bump uuidtools from 2.1.5 to 2.2.0
2022-08-27 00:16:52 +02:00
dependabot[bot]
827d32ae9e Bump uuidtools from 2.1.5 to 2.2.0
Bumps [uuidtools](https://github.com/sporkmonger/uuidtools) from 2.1.5 to 2.2.0.
- [Release notes](https://github.com/sporkmonger/uuidtools/releases)
- [Changelog](https://github.com/sporkmonger/uuidtools/blob/main/CHANGELOG)
- [Commits](https://github.com/sporkmonger/uuidtools/commits)

---
updated-dependencies:
- dependency-name: uuidtools
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-27 00:01:35 +02:00
Javi Martín
5c986097c6 Merge pull request #4966 from consul/dependabot/bundler/master/devise-4.8.1
Bump devise from 4.8.0 to 4.8.1
2022-08-26 23:54:34 +02:00
dependabot[bot]
1a37b7b905 Bump devise from 4.8.0 to 4.8.1
Bumps [devise](https://github.com/heartcombo/devise) from 4.8.0 to 4.8.1.
- [Release notes](https://github.com/heartcombo/devise/releases)
- [Changelog](https://github.com/heartcombo/devise/blob/main/CHANGELOG.md)
- [Commits](https://github.com/heartcombo/devise/compare/v4.8.0...v4.8.1)

---
updated-dependencies:
- dependency-name: devise
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-26 23:39:03 +02:00
Javi Martín
899b0db904 Merge pull request #4972 from consul/dependabot/bundler/master/pronto-rubocop-0.11.2
Bump pronto-rubocop from 0.11.1 to 0.11.2
2022-08-26 23:38:24 +02:00
dependabot[bot]
9bd9a94f39 Bump pronto-rubocop from 0.11.1 to 0.11.2
Bumps [pronto-rubocop](https://github.com/mmozuras/pronto-rubocop) from 0.11.1 to 0.11.2.
- [Release notes](https://github.com/mmozuras/pronto-rubocop/releases)
- [Commits](https://github.com/mmozuras/pronto-rubocop/compare/v0.11.1...v0.11.2)

---
updated-dependencies:
- dependency-name: pronto-rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-26 23:19:10 +02:00
Javi Martín
40d1395f1b Merge pull request #4973 from consul/dependabot/bundler/master/savon-2.13.0
Bump savon from 2.12.1 to 2.13.0
2022-08-26 23:18:15 +02:00
dependabot[bot]
385e1136b3 Bump savon from 2.12.1 to 2.13.0
Bumps [savon](https://github.com/savonrb/savon) from 2.12.1 to 2.13.0.
- [Release notes](https://github.com/savonrb/savon/releases)
- [Changelog](https://github.com/savonrb/savon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/savonrb/savon/compare/v2.12.1...v2.13.0)

---
updated-dependencies:
- dependency-name: savon
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-26 22:48:17 +02:00
Javi Martín
1663eb9892 Merge pull request #4975 from consul/dependabot/bundler/master/cancancan-3.4.0
Bump cancancan from 3.3.0 to 3.4.0
2022-08-26 22:46:08 +02:00
dependabot[bot]
3f7b3ae319 Bump cancancan from 3.3.0 to 3.4.0
Bumps [cancancan](https://github.com/CanCanCommunity/cancancan) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/CanCanCommunity/cancancan/releases)
- [Changelog](https://github.com/CanCanCommunity/cancancan/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/CanCanCommunity/cancancan/compare/3.3.0...3.4.0)

---
updated-dependencies:
- dependency-name: cancancan
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-26 22:31:39 +02:00
Javi Martín
7a85953ae0 Merge pull request #4929 from consul/dependabot/bundler/master/omniauth-2.1.0
Bump omniauth from 2.0.4 to 2.1.0
2022-08-26 20:10:53 +02:00
Javi Martín
3790aaa4e4 Merge pull request #4954 from consul/dependabot/bundler/master/omniauth-rails_csrf_protection-1.0.1
Bump omniauth-rails_csrf_protection from 1.0.0 to 1.0.1
2022-08-26 20:10:07 +02:00
Javi Martín
a49ddf2628 Merge pull request #4957 from consul/dependabot/bundler/master/graphiql-rails-1.8.0
Bump graphiql-rails from 1.7.0 to 1.8.0
2022-08-26 20:02:57 +02:00
dependabot[bot]
1cb44fc17c Bump omniauth from 2.0.4 to 2.1.0
Bumps [omniauth](https://github.com/omniauth/omniauth) from 2.0.4 to 2.1.0.
- [Release notes](https://github.com/omniauth/omniauth/releases)
- [Commits](https://github.com/omniauth/omniauth/compare/v2.0.4...v2.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-26 19:54:46 +02:00
dependabot[bot]
4675cabe9a Bump omniauth-rails_csrf_protection from 1.0.0 to 1.0.1
Bumps [omniauth-rails_csrf_protection](https://github.com/cookpad/omniauth-rails_csrf_protection) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/cookpad/omniauth-rails_csrf_protection/releases)
- [Commits](https://github.com/cookpad/omniauth-rails_csrf_protection/compare/v1.0.0...v1.0.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-26 19:52:31 +02:00
dependabot[bot]
7734b29257 Bump graphiql-rails from 1.7.0 to 1.8.0
Bumps [graphiql-rails](https://github.com/rmosolgo/graphiql-rails) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/rmosolgo/graphiql-rails/releases)
- [Changelog](https://github.com/rmosolgo/graphiql-rails/blob/master/changelog.md)
- [Commits](https://github.com/rmosolgo/graphiql-rails/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: graphiql-rails
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-26 19:16:46 +02:00