Commit Graph

20684 Commits

Author SHA1 Message Date
taitus
62e1c13e7e Use option instead of answer text to find multiple answers 2025-10-16 11:09:36 +02:00
taitus
b4b00487cc Add validations for changing votation type 2025-10-16 11:09:34 +02:00
taitus
9ff167d040 Use option instead of answer when sampling question options
We were still assigning answer: question.question_options.sample.title,
which made sense before we introduced the option association.
2025-10-15 15:52:14 +02:00
taitus
b3f8ba819b Adapt 'show' view for open questions without options
- Prevent creating options for open questions
- Skip rendering the options table when none exist
2025-10-15 15:52:14 +02:00
taitus
d3f32978c8 Hide "Maximum number of votes" message for unique and open-ended questions
The "Maximum number of votes" text in poll question show was unnecessary.
It appeared for both unique and open-ended questions, but it only makes
sense for questions that allow multiple answers.
2025-10-15 15:52:14 +02:00
taitus
69eaf66b93 Remove redundant max_votes validation from Poll::Answer
Since commit 8deb1964b, the `WebVote` class enforces the maximum vote
validation, making the `max_votes` method in `Poll::Answer` redundant.
2025-10-15 15:52:14 +02:00
taitus
4e57e311dc Add support for open-ended questions in admin section
Introduce a new "open" votation type for poll questions in the admin
interface. This type allows open answers provided by the user.
2025-10-15 15:52:12 +02:00
Javi Martín
4698d9a703 Merge pull request #6110 from consuldemocracy/dependabot/bundler/rack-2.2.20
Bump rack from 2.2.19 to 2.2.20
2025-10-11 16:20:10 +02:00
dependabot[bot]
3e51f0f2ac Bump rack from 2.2.19 to 2.2.20
Bumps [rack](https://github.com/rack/rack) from 2.2.19 to 2.2.20.
- [Release notes](https://github.com/rack/rack/releases)
- [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rack/rack/compare/v2.2.19...v2.2.20)

---
updated-dependencies:
- dependency-name: rack
  dependency-version: 2.2.20
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-10 19:08:55 +00:00
taitus
eb10a3135b Refactor vote type descriptions to use data attributes
This makes it easier to extend support for new types (e.g., 'open')
without adding more conditional logic to the JavaScript.
2025-10-10 13:20:49 +02:00
Javi Martín
088837720a Merge pull request #6076 from johanndev1208/adds-notifications-managment
Add setting to require consent for notifications
2025-10-09 15:36:27 +02:00
Javi Martín
80d6f9c9dc Merge pull request #6109 from consuldemocracy/dependabot/bundler/rack-2.2.19
Bump rack from 2.2.18 to 2.2.19
2025-10-09 12:05:30 +02:00
Javi Martín
6d30e2d34e Don't display public activity by default when requiring consent
Just as we mentioned in the previous commit, there are places where we
aren't sure whether explicit consent is strictly required. So, when the
"require consent" setting is enabled, we're taking the safe approach.
This means that, in this case, we're only displaying a user's activity
if they've given explicit consent.
2025-10-09 10:56:21 +02:00
Johann
92a76dd46e Disable recommendations by default when requiring consent
The GDPR is open for interpretation, and it isn't clear whether showing
users recommended proposals and debates while browsing the site is
considered a notification that needs to be explicitly accepted.

Since we aren't sure whether this is necessary, we're taking the safe
approach and disabling recommendations by default.
2025-10-09 10:54:36 +02:00
Javi Martín
a1714fea58 Use the "#" convention in user preferences methods tests
This is a convention we follow most of the time, particularly in the
last few years.
2025-10-09 10:53:04 +02:00
Johann
e7f2210380 Add setting to require consent for notifications
Ensure GDPR compliance by default (Article 25 GDPR – privacy by design
and by default). Under GDPR, consent must be freely given, specific,
informed and unambiguous [1]. We were subscribing users without
explicity consent, which goes against the "No pre-ticked boxes"
principle.

For compatibility with existing installations, we're using a setting,
disabled by default. Once we release version 2.4.0 we will enable it by
default, which won't affect existing installations but only new ones.

[1] https://gdprinfo.eu/best-gdpr-newsletter-consent-examples-a-complete-guide-to-compliant-email-marketing
2025-10-09 10:53:00 +02:00
Johann
208dc01d3b Add tests for newsletter and email digest scopes
These methods didn't have proper model tests.
2025-10-08 15:33:25 +02:00
dependabot[bot]
720e450954 Bump rack from 2.2.18 to 2.2.19
Bumps [rack](https://github.com/rack/rack) from 2.2.18 to 2.2.19.
- [Release notes](https://github.com/rack/rack/releases)
- [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rack/rack/compare/v2.2.18...v2.2.19)

---
updated-dependencies:
- dependency-name: rack
  dependency-version: 2.2.19
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-07 19:53:35 +00:00
dependabot[bot]
affb43f5b6 Bump actions/setup-node from 4 to 5
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4 to 5.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-01 22:25:45 +00:00
dependabot[bot]
1cafc82bc7 Bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-01 22:25:41 +00:00
Sebastia
f7f3ae3c33 Merge pull request #6079 from consuldemocracy/add-publiccode
Create publiccode.yml
2025-10-01 10:07:17 +02:00
Lucía Luzuriaga
1152cf48d6 Create publiccode.yml 2025-10-01 09:38:56 +02:00
Javi Martín
bb9a849324 Merge pull request #6071 from KhanhVanCong/fix-bug/6047-the-legislation-title-text-box-does-not-fix-size-of-text
Adjust legislation title height to prevent a layout break
2025-09-30 13:18:29 +02:00
khanhvancong
1d437eab03 Adjust legislation title height to prevent a layout break
The long question legislation process title will overflow the text box contain,
block the description and make the layout so bad.

The question title box should fit the size of the text, no matter how long it is.

Increase the min-height of the quiz title container in legislation_process.scss to ensure
long titles remain visually contained and do not overflow the header area.
This change improves UI consistency for legislation process pages.

Issue: #6047
2025-09-29 22:19:58 +07:00
taitus
2a5985f6ef Update tests for votation type form behavior
Ensure the form toggles descriptions and fields correctly depending on the selected
votation type.
2025-09-26 15:41:09 +02:00
Sebastia
d8f03c3b6e Merge pull request #6070 from consuldemocracy/total_votes_by_option_id
Count answers by option_id
2025-09-26 15:40:15 +02:00
taitus
3a9f761476 Count total_votes by option_id instead of answer title
This makes Option#total_votes independent of translations
and resilient to title changes.
2025-09-26 15:25:20 +02:00
Sebastia
3b827e3e95 Merge pull request #6072 from consuldemocracy/add_option_id_to_partial_results
Avoid duplicate records in partial results
2025-09-26 15:18:45 +02:00
taitus
24239c98e3 Delete duplicate records in different languages
Also logs a message when duplicates have different amounts, keeping the
first partial result and deleting the others.
2025-09-26 15:05:40 +02:00
taitus
c9fb47aa3d Add PollPartialResultOptionFinder to extend PollOptionFinder
Introduce a dedicated finder for partial results, reusing the logic
of PollOptionFinder. This will be used in rake tasks to avoid code
duplication and make the intent clearer.
2025-09-26 15:05:40 +02:00
taitus
ed2a25663b Add task to add option_id to existing partial results 2025-09-26 15:05:40 +02:00
taitus
e286ee6943 Add task to delete duplicate poll partial results
Adds rake task "polls:remove_duplicate_partial_results" to delete duplicated
rows in "poll_partial_results" made before the DB was strict about duplicates.

Duplicates are considered only for records without "option_id", grouping by:
(question_id, booth_assignment_id, date, answer). We keep the first one and
delete the rest, per tenant.

The controller use:
  Poll::PartialResult.find_or_initialize_by(booth_assignment_id, date, question_id, answer)
which is not a strong protection against race conditions. Without a unique
index at the DB level, duplicates could be created. This task cleans up any
existing duplicates.
2025-09-26 15:05:40 +02:00
taitus
a29eeaf2e2 Add option_id to partial results and unique index
Similar to what we did in PR "Avoid duplicate records in poll answers" 5539,
specifically in commit 503369166, we want to stop relying on the plain text
"answer" and start using "option_id" to avoid issues with counts across
translations and to add consistency to the poll_partial_results table.

Note that we also moved the `possible_answers` method from Poll::Question to
Poll::Question::Option, since the list of valid answers really comes from the
options of a question and not from the question itself. Tests were updated
to validate answers against the translations of the assigned option.

Additionally, we renamed lambda parameters in validations to improve clarity.
2025-09-26 15:05:34 +02:00
taitus
f2153f2b4d Extract officing results index to component 2025-09-26 09:59:10 +02:00
taitus
e3e475b4df Add votes_for(option) method and simplify results template
Move the summing logic from the template into the component. Introduce
a votes_for(option) method that looks up grouped partial results and
returns the total amount or 0.
2025-09-26 09:59:10 +02:00
taitus
7565fc5fc2 Remove redundant by_question grouping in Admin::Poll::Results::QuestionComponent
Stop grouping partial results by question_id inside the component.

Note that group_by on an empty collection already returns
an empty hash, so the previous "|| {}" is not needed.
2025-09-26 09:59:08 +02:00
taitus
5945bfe9ed Replace poll result partial with Admin::Poll::Results::QuestionComponent 2025-09-26 09:58:20 +02:00
taitus
7996933fc2 Extract by_answer variable to component method 2025-09-26 09:58:20 +02:00
taitus
7f376c3005 Extract admin poll results to component
Note that we have the same code in the officing section.
Then we can use the same component.

Note also that we are removing the parts of the system specs that are now
covered by the component itself, and taking the chance to unify tests.
In these removals and unifications we take into account that there are
other specs which already cover user interaction in this section.
2025-09-26 09:58:17 +02:00
Sebastia
cac5e64a84 Merge pull request #6078 from consuldemocracy/dependabot/bundler/rack-2.2.18
Bump rack from 2.2.17 to 2.2.18
2025-09-26 09:32:00 +02:00
dependabot[bot]
66c50a3964 Bump rack from 2.2.17 to 2.2.18
Bumps [rack](https://github.com/rack/rack) from 2.2.17 to 2.2.18.
- [Release notes](https://github.com/rack/rack/releases)
- [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rack/rack/compare/v2.2.17...v2.2.18)

---
updated-dependencies:
- dependency-name: rack
  dependency-version: 2.2.18
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-25 17:35:03 +00:00
taitus
bc6506da5a Unify Officing and Admin results views
Unify the code from app/views/officing/results/index.html.erb with
app/views/admin/poll/results/_result.html.erb. This prepares the ground
to extract a component in the next commit and avoid duplication.
2025-09-22 14:28:25 +02:00
Javi Martín
3ad2d770e5 Merge pull request #6075 from consuldemocracy/dependabot/bundler/rexml-3.4.2
Bump rexml from 3.4.1 to 3.4.2
2025-09-18 09:20:46 +02:00
dependabot[bot]
f5372f6267 Bump rexml from 3.4.1 to 3.4.2
Bumps [rexml](https://github.com/ruby/rexml) from 3.4.1 to 3.4.2.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.4.1...v3.4.2)

---
updated-dependencies:
- dependency-name: rexml
  dependency-version: 3.4.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-17 19:21:51 +00:00
taitus
896ebc82fd Remove unused go_back_to_new calls and unused error_create key
- Remove two redundant go_back_to_new calls in build_results, since
  @poll.questions.find already raises RecordNotFound if a question
  does not exist.
- Drop the fallback flash translation error_create, which is no longer
  used since commit 592fdffe4e and only remained as a default in
  go_back_to_new.
- Move check_officer_assignment from Officing::BaseController to
  Officing::ResultsController, its only place of use.
2025-09-15 09:49:12 +02:00
Sebastia
086c79993f Merge pull request #6067 from consuldemocracy/update-contribution-docs
Update CONTRIBUTING and README with latest links and suggestions
2025-09-03 14:21:13 +02:00
Lucía Luzuriaga
9120b20d41 Delete .codeclimate.yml 2025-09-02 15:26:12 +00:00
Javi Martín
3cf6e9b1ca Merge pull request #6046 from Anamika1608/oidc_auth
Add support for OIDC authentication
2025-09-01 19:55:10 +02:00
Anamika Aggarwal
5e263baed2 Add OIDC section for sign in and sign up page
- name: :oidc → Identifier for this login provider in the app.
- scope: [:openid, :email, :profile] → Tells the provider we want the user’s ID (openid), their email, and basic profile info (name, picture, etc.).
- response_type: :code → Uses Authorization Code Flow, which is more secure because tokens are not exposed in the URL.
- issuer: Rails.application.secrets.oidc_issuer → The base URL of the OIDC provider (e.g., Auth0). Used to find its config.
- discovery: true → Automatically fetches the provider’s endpoints from its discovery document instead of manually setting them.
- client_auth_method: :basic → Sends client ID and secret using HTTP Basic Auth when exchanging the code for tokens.

Add system tests for OIDC Auth

Edit the oauth docs to support OIDC auth
2025-08-29 12:20:16 +02:00
Javi Martín
bde25273bc Merge pull request #5762 from consuldemocracy/unique_index_on_poll_voters
Add unique index to poll voters table
2025-08-28 15:20:02 +02:00