Commit Graph

236 Commits

Author SHA1 Message Date
Max Stevens
13bf866c95 Disable the create booths button when the polls function is disabled 2023-06-23 14:33:19 +02:00
Matheus Miranda
de13e789dd Add polygon geographies to Budgets' map
Note that in the budgets wizard test we now create district with no
associated geozone, so the text "all city" will appear in the districts
table too, meaning we can't use `within "section", text: "All city" do`
anymore since it would result in an ambiguous match.

Co-Authored-By: Julian Herrero <microweb10@gmail.com>
Co-Authored-By: Javi Martín <javim@elretirao.net>
2023-05-31 16:56:15 +02:00
Javi Martín
106dee0040 Remove redundant HTML map classes
The `map` class is applied to the map element by LeafletJS; using it in
the container led to hacks like adding an `inline` class to fix the fact
that the container was using the `height` rule of the `.map` elements.

Even though we don't add styles for them, I'm adding the `budgets-map`
and `budget-investments-map` HTML classes so these elements can still be
easily selected with CSS and JavaScript.
2023-05-31 16:56:12 +02:00
taitus
306e7356c3 Allow translate locales that need to be mapping
It has been detected that for the :pt-BR, :zh-CN and :zh-TW locales,
the translate button was being displayed, but when requesting the
translation, the remote translation validation failed due to:

'''
validates :locale, inclusion: { in: ->(_) {
     RemoteTranslations::Microsoft::AvailableLocales.available_locales }}
'''

That available_locales method did not contemplate these 3 languages
in the format used by the application.

To solve this problem the api response is mapped to return all
locales in the format expected by the application.

Add remote translation model test to ensure that a remote translation
is valid when its locale is pt-BR.

Co-Authored-By: Javi Martín <35156+javierm@users.noreply.github.com>
2023-03-15 15:52:51 +01:00
Sebastia
8f01a25ced Merge pull request #4900 from consul/ballot_hidden_money
Do not show money with hidden money
2023-02-23 15:22:24 +01:00
decabeza
9ef90b1e49 Do not show money with hidden money 2023-02-22 19:27:28 +01:00
Javi Martín
45b9eccfd8 Show valuator group investments to their valuators
When accessing the valuation area, we were only displaying the
investments directly assigned to the current valuator, but we weren't
displaying the investments assigned to that valuator's group.

Using the `assigned_investments_ids` method, which takes the valuator
group into account, solves the issue.

We've also found an issue on our development machines: since we don't
have a unique index per `investment_id` and `valuator_id` in the
`budget_valuator_assignments` table, we've found duplicate records on
this table. When that happened, we were displaying the same investment
several times.

Since now we no longer join this table in the query returning the
investment, this issue is also solved, and we're adding a test for it.
We can now remove the call to the `distinct` method when calculating the
number of investments per heading.
2023-02-20 14:59:31 +01:00
Javi Martín
f7dfe30675 Merge pull request #5078 from consul/link_to_evaluate
Show link to evaluate investments with valuation finished
2023-02-20 14:42:58 +01:00
Javi Martín
b536a7cb77 Extract component for supporting budget admin stats
This is consistent with the component for balloting stats. We're about
to change both components, and the changes are easier to follow if
they're similar.

We're also using consistent names in methods.
2023-02-20 14:21:22 +01:00
Javi Martín
dd28163be7 Show admin heading stats for the current budget
To get the heading where a user voted, we were relying on the
`balloted_heading_id` field.

Our guess is this was done so the total number of users is the same as
the sum of users who voted on a heading. That is, if 2000 people voted
just on the "All city" heading, 1000 voted just on the "North district"
heading, and 500 people voted on both, instead of showing "3500 people
voted in total, 2500 voted in all city, 1500 voted in north district",
we show something like "3500 people voted in total, 2250 voted in all
city, and 1250 voted in north district".

However, this approach has some disadvantages.

The first disadvantage is, the stats aren't correct. In the case above,
2500 voted on the "All city heading", so the statistics for this heading
don't show reality.

The second one is we weren't considering the last heading where users
voted inside the budget being displayed, but the last heading where
users voted, period. That means that, if all the people above voted on a
later budget, the stats for the budget above would become "3500 people
voted in total, 0 voted in all city, and 0 voted in north district".
That also means we were including headings from previous budgets in the
statistics for more recent budgets when people hadn't voted on the
recent ones.

So we're removing the `balloted_heading_id` since its data is lost once
people vote on a new budget. And, in order to show the right stats and
simplify the code, we're no longer trying to add votes just to one
heading when users vote on several headings.

Co-Authored-By: Julian Nicolas Herrero <microweb10@gmail.com>
2023-02-20 14:21:03 +01:00
Javi Martín
76b08398cf Extract component for balloting budget admin stats
We're also moving the tests, but we're keeping one system test in order
to test the controller and the navigation to get to this page.

Note we're slightly changing the order of the methods in the component;
the order of the instance variables was `user_`, `vote_`, `vote_`,
`user_`, which was hard to follow.
2023-02-20 14:20:50 +01:00
Javi Martín
ed4b03c3ed Show link to evaluate after evaluation has finished
This way it's still possible to access the "evaluation finished" filter
in the valuation investments index.
2023-02-17 15:26:49 +01:00
Javi Martín
d5cb01bf98 Split test in budget valuation component
We're going to add more cases and the test for the link to the evaluate
would become too big, so we're splitting it.
2023-02-17 15:25:25 +01:00
decabeza
1ff2144830 Show always poll officer menu to officers
Since the change on commit cbbe188d6 we added a Poll.current.any?
condition to show the officing link on admin menu to officers.

That condition doesn't have much sense since Poll results only can be
added after a poll has ended, and there may be only one active poll.
2023-02-17 14:07:02 +01:00
Javi Martín
465d2d604d Move login items tests to the component
This way we reduce the number of system tests or, in some cases,
requests during system tests, making the tests faster.

We're still testing the interaction with the menu when users have the
right permissions.
2023-02-17 14:07:02 +01:00
Javi Martín
2f0327acf8 Use remote translations objects instead of hashes
This way we can simplify the code dealing with the translatable
association.
2023-02-16 17:52:17 +01:00
Javi Martín
efc69e8663 Extract component for remote translations button
So we're consistent with the rest of the code in the header, which
renders components and not partials.
2023-02-16 17:24:34 +01:00
Senén Rodero
8c2db5cc27 Merge pull request #5061 from consul/managment_concurrent_budgets
Show published budgets in the valuation panel
2023-02-03 14:56:57 +01:00
Senén Rodero Rodríguez
0c09fd22af Do not show the Evaluate link when there are no projects to evaluate for current valuator 2023-02-03 11:01:41 +01:00
Senén Rodero Rodríguez
615b249144 Count only the investments visible and assigned to current valuator
It has more sense to show the count of the investments the
valuator is going to find in the investments valuation page.
2023-02-03 11:01:41 +01:00
Javi Martín
119f64ac44 Fix dates in custom pages admin index
We weren't showing the year when a page was created/updated, and we
were displaying the created date instead of the updated one.

Co-Authored-By: Diego Calvo <diego.calvo@enreda.coop>
2023-01-22 17:15:12 +01:00
Javi Martín
e000bd9a61 Hide menu button to managers on small screens
This menu isn't rendered in this case, so the "menu" button to toggle it
did nothing.
2023-01-16 14:44:01 +01:00
Javi Martín
cb2aebe2c8 Fix current_user usage in management section
In the management section, `current_user` is the user impersonated by
the manager. We were deciding whether to show the admin menu depending
on the privileges of the current user, but this menu should be shown
according to the privileges of the manager who is impersonating the
user.

We're doing a similar (very subtle) change in the login items. We were
rendering the `login_items` partial passing `current_user: user`.
However, inside this method, we were using `user_signed_in`, which
ignored the `current_user` we were passing. The result was always the
same expect in tests where we manually sign in users, but we're changing
it anyway in order to reduce confusion.
2023-01-16 14:22:23 +01:00
Javi Martín
86fd14f8f0 Move admin header partial to a component
This way it's easier to refactor it.

Note we're using `with_request_url` in the tests because the component
renders the locale switcher, which needs a URL in order to work. This
doesn't affect whether we're in the management section or not.
2023-01-16 14:22:13 +01:00
decabeza
d59d02ba83 Show verification info only if verification is enabled 2023-01-04 16:06:29 +01:00
Javi Martín
3f664e4ccd Don't ask verified users to verify their account
It was strange to tell users they need to verify their account in order
to perform all available actions when they've already verified their
account.
2023-01-04 16:06:29 +01:00
Javi Martín
1ecd422f7f Extract component to render verification info
We're also adding tests showing the current behavior, which we're about
to change.
2023-01-04 16:06:29 +01:00
Javi Martín
2bac80215f Add permissions hint for visually impaired people
We were displaying an icon showing that certain actions can't be
performed. However, people who can't see the icons were hearing that
they _can_ perform certain actions while the opposite is true.

We've considered other options to solve this problem. One was to split
the list in two: actions that can be performed and actions that can't be
performed. It was tricky because in some cases we're listing that
actions that can be performed now and in other cases we're displaying
the actions that people will be able to perform once they verify their
account.

Another option was to include the word "Cannot" as a prefix instead of
"Additional verification needed". We haven't done so because, while in
English we say "cannot do this thing", in other languages they say
"this thing cannot do".

So we've gone with a solution where people hearing what's on the screen
know what's going on and we don't have to make big changes in the code.
2022-11-29 18:48:24 +01:00
Javi Martín
66c2583557 Render icons using CSS in user permissions
As mentioned in commit 925f04e3f, icon classes make screen readers
announce strange symbols and aren't properly displayed for people who
have changed their preferred font family.
2022-11-29 18:48:24 +01:00
Javi Martín
236796406a Fix crash voting on a heading with a content block
When voting investment projects, the sidebar was rendered without the
`@heading_content_blocks` being set. That resulted in a 500 error when
the heading had content blocks.

By extracting the logic to a component, we make sure the heading content
blocks are properly set every time this code is rendered, no matter
which controller is rendering the view.
2022-11-28 13:28:22 +01:00
Javi Martín
5c61b72d21 Identify the current tenant in the <html> tag
This way it will be possible to write CSS and JavaScript code that will
only apply to specific tenants.

Note that CSS customization is still limited because it isn't possible
to use different SCSS variables per tenant.
2022-11-11 01:39:29 +01:00
Javi Martín
2c0ede3aaa Use the dir attribute in dashboard and mailer layouts
We forgot to do so in commit d827768c0. In order to avoid the same
mistake in the future, we're extracting a method to get these
attributes. We're also adding tests, since we didn't have any tests to
check that the `dir` attribute was properly set.
2022-11-11 01:39:29 +01:00
decabeza
1eb52fb045 Add read more links to poll question component 2022-10-18 11:04:40 +02:00
decabeza
36e452437e Add questions with mutiple answers to polls public interface
The `reload` method added to max_votes validation is needed because the
author gets here with some changes because of the around_action
`switch_locale`, which adds some changes to the current user record and
therefore, the lock method raises an exception when trying to lock it
requiring us to save or discard those record changes.
2022-10-18 11:04:40 +02:00
Senén Rodero Rodríguez
7df0e9a961 Allow to remove poll answers 2022-10-18 11:04:40 +02:00
Senén Rodero Rodríguez
f90d0d9c4d Show poll user answers in subsequent sessions 2022-10-18 10:39:00 +02:00
Senén Rodero Rodríguez
4eb4851aba Rename component as now it renders all question answers additional information 2022-10-18 10:38:59 +02:00
decabeza
4fba76f64f Do not show answers without additional information 2022-10-18 10:38:59 +02:00
decabeza
b92b38f48f Show question title before answers additional information 2022-10-18 10:38:59 +02:00
Senén Rodero Rodríguez
8311e7e6b8 Extract component to render answers additional information 2022-10-18 10:38:08 +02:00
Senén Rodero Rodríguez
bd58023a8a Extract polls questions answers partial into a component 2022-10-17 18:03:36 +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
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
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
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
92941d3304 Keep filters in admin search
While this bug was already present in the general admin search, the
combination of both search and filters was very uncommon. I've only
found this combinations in the users section, where you've got the
"erased" filter, but in this case searching for erased users doesn't
really make sense since their username and email have been deleted and
so there's nothing to find.

So the hidden content seemed to be the only affected section. However,
we're adding the field to every section so we don't have to make sure we
add it when we need it (like we did in the SDGManagement section).
2022-08-23 14:33:55 +02:00