Skip to content

Fix initiatives signatures issues#8448

Merged
andreslucena merged 9 commits intodevelopfrom
fix/initiatives_offline_supports
Feb 25, 2022
Merged

Fix initiatives signatures issues#8448
andreslucena merged 9 commits intodevelopfrom
fix/initiatives_offline_supports

Conversation

@leio10
Copy link
Copy Markdown
Contributor

@leio10 leio10 commented Oct 27, 2021

🎩 What? Why?

As described in #6862, initiatives offline signatures were not being shown and it was not possible to accept initiatives even when the goal was reached. It turns that the second issue is not related to the offline signatures, but to another bug related to the way iniative types are used. This PR fixes both.

📌 Related Issues

Testing

  1. Create and publish an in-person or mixed initiative.
  2. Update the number of in-person signatures (and set a past date as the "End of signature period".
  3. Check that the admin page shows the "Accept initiative" button.
  4. Visit the initiative page and check that the number of in-person signatures is included in the total count of signatures received by the initiative.

📋 Checklist

🚨 Please review the guidelines for contributing to this repository.

  • CONSIDER adding a unit test if your PR resolves an issue.
  • ✔️ DO check open PR's to avoid duplicates.
  • ✔️ DO keep pull requests small so they can be easily reviewed.
  • ✔️ DO build locally before pushing.
  • ✔️ DO make sure tests pass.
  • ✔️ DO make sure any new changes are documented in docs/.
  • ✔️ DO add and modify seeds if necessary.
  • ✔️ DO add CHANGELOG upgrade notes if required.
  • ✔️ DO add to GraphQL API if there are new public fields.
  • ✔️ DO add link to MetaDecidim if it's a new feature.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

📷 Screenshots

Please add screenshots of the changes you're proposing
Description

♥️ Thank you!

@leio10 leio10 added module: initiatives type: fix PRs that implement a fix for a bug labels Oct 27, 2021
@leio10 leio10 requested a review from andreslucena October 28, 2021 10:35
@andreslucena
Copy link
Copy Markdown
Member

Ok, I can confirm that this works as expected (or at least that's consistent with the bugs that show in different types of initiatives 😅).

Just a minor detail, it seems like the signature counter isn't updated when seeing the card in navigation:

image

This is the initiative page (it shows the correct counter):

image

Could you please review that @leio10 🙏🏽?

@leio10
Copy link
Copy Markdown
Contributor Author

leio10 commented Nov 2, 2021

@andreslucena I'm checking the bug you are reporting, but I'm not able to reproduce it. The code seems to be ok, and in my local instance works properly.

imagen
imagen

In my instance, the value for offline_votes field for the initiative is {"1"=>1200, "total"=>1200}. The code difference between the two scenarios is that the initiative page is showing the value for the scope 1 and the initiative cell is showing the "total" value.

Can you check in the console if the value for that field in your app also has a value for the "total" key?

@andreslucena
Copy link
Copy Markdown
Member

Can you check in the console if the value for that field in your app also has a value for the "total" key?

@leio10 there's no total key:

irb(main):014:0> Decidim::Initiative.last.offline_votes
  Decidim::Initiative Load (0.4ms)  SELECT "decidim_initiatives".* FROM "decidim_initiatives" ORDER BY "decidim_initiatives"."id" DESC LIMIT $1  [["LIMIT", 1]]
=> {"global"=>88}
irb(main):015:0> Decidim::Initiative.last
  Decidim::Initiative Load (0.4ms)  SELECT "decidim_initiatives".* FROM "decidim_initiatives" ORDER BY "decidim_initiatives"."id" DESC LIMIT $1  [["LIMIT", 1]]
=> #<Decidim::Initiative id: 9, title: {"ca"=>"", "en"=>"Presential", "es"=>""}, description: {"ca"=>"", "en"=>"<p>Presential</p>", "es"=>""}, decidim_organization_id: 1, decidim_author_id: 1, published_at: "2021-11-05 08:49:28", state: "published", signature_type: "offline", signature_start_date: "2021-11-05", signature_end_date: "2022-03-05", answer: nil, answered_at: nil, answer_url: nil, created_at: "2021-11-05 08:49:11", updated_at: "2021-11-05 08:49:42", decidim_user_group_id: nil, hashtag: "", scoped_type_id: 11, first_progress_notification_at: nil, second_progress_notification_at: nil, decidim_author_type: "Decidim::UserBaseEntity", reference: "MD-INIT-2021-11-9", online_votes: {}, offline_votes: {"global"=>88}, decidim_area_id: nil, comments_count: 0, follows_count: 1>

Steps to reproduce:

  1. Create a new initiative type with title, description, banner image, Signature type = In-person
  2. Create a new Scope for the initiative type, with Global scope, Signatures required = 50
  3. Create a new initiative
  4. Send it to technical validation
  5. Publish it
  6. Fill in "In-person signatures for Global scope" 88
  7. Go to initiative page, it has 88/50 signatures
  8. Go to initiatives list page, it has 0/50 signatures
irb(main):018:0> Decidim::InitiativesType.last
  Decidim::InitiativesType Load (0.3ms)  SELECT "decidim_initiatives_types".* FROM "decidim_initiatives_types" ORDER BY "decidim_initiatives_types"."id" DESC LIMIT $1  [["LIMIT", 1]]
=> #<Decidim::InitiativesType id: 5, title: {"ca"=>"", "en"=>"A new initiative type", "es"=>""}, description: {"ca"=>"", "en"=>"<p>with a description</p>", "es"=>""}, decidim_organization_id: 1, created_at: "2021-11-05 08:46:35", updated_at: "2021-11-05 08:46:35", banner_image: nil, collect_user_extra_fields: false, extra_fields_legal_information: {"ca"=>"", "en"=>"", "es"=>""}, minimum_committee_members: 0, validate_sms_code_on_votes: false, document_number_authorization_handler: "", undo_online_signatures_enabled: false, promoting_committee_enabled: false, signature_type: "offline", child_scope_threshold_enabled: false, only_global_scope_enabled: false, custom_signature_end_date_enabled: false, attachments_enabled: false, area_enabled: false>

@andreslucena
Copy link
Copy Markdown
Member

I'm retaking this issue.

With 85ecef6 we've solved the bug of my last comment #8448 (comment). The problem was that when it was setting the "total" key for a global scope in-person (aka offline) initiative, it was expecting to have a scope, so it wasn't set.

I also merged against develop. The thing is that it CI should fail, as at least locally I saw that the offline_votes attribute in Decidim::Initiatives::Admin::InitiativeForm have a valid Virtus type. But, after #8514, we're not so permissive, so as I said I hope that this fails (as that'd mean that we have a good test suite 😄 )

@andreslucena andreslucena merged commit 09d639f into develop Feb 25, 2022
@andreslucena andreslucena deleted the fix/initiatives_offline_supports branch February 25, 2022 15:17
entantoencuanto added a commit that referenced this pull request Mar 2, 2022
* develop: (57 commits)
  Add a subtitle to assemblies and processes pages (#8918)
  Add a subtitle to votings page (#8919)
  Fix profile notifications (#8943)
  Fix email for verification conflict with managed users (#8926)
  Move VAPID keys generators to core (#8923)
  Fix officialized user event missing translations (#8927)
  Fix verification report with multitenants: notify it only to admins of that organization (#8929)
  Fix processes creation form with stats, metrics and announcements (#8925)
  Fix flaky spec in meetings multi-date selectors (#8924)
  Local HTML validator for the CI (#8937)
  Fix translatable presence validator for hyphenated locales (#8795)
  Fix link to docs in initiatives admin (#8921)
  Fix initiatives signatures issues (#8448)
  Fix the meetings export to also include unpublished meetings (#8874)
  Fix heading order in the consultation question page (#8920)
  Fix diff mode selector roles and tabindexes (#8912)
  Fix budget hard dependency and caching flag issues in comments (#8899)
  Fix emoji picker hiding Foundation Abide form errors (#8886)
  Fix logical heading order for the endorsers list (#8892)
  Fix Foundation Abide errors for Rails remote (AJAX) forms (#8889)
  ...
andreslucena added a commit that referenced this pull request Mar 7, 2022
Co-authored-by: Andrés Pereira de Lucena <andreslucena@gmail.com>
@alecslupu alecslupu added this to the 0.27.0 milestone Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: initiatives type: fix PRs that implement a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offline signatures do not work

3 participants