Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POLIO-1774: delete rounds without campaign #1906

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

quang-le
Copy link
Member

@quang-le quang-le commented Jan 8, 2025

Polio had rounds without campaign, which shouldn't be possible

Related JIRA tickets : POLIO-1774

Self proofreading checklist

  • Did I use eslint and black formatters
  • Is my code clear enough and well documented
  • Are my typescript files well typed
  • New translations have been added or updated if new strings have been introduced in the frontend
  • My migrations file are included
  • Are there enough tests
  • Documentation has been included (for new feature)

Doc

NA

Changes

  • Update polio API to delete rounds that are removed from campaign, e.g: remove round 3, keep only rounds 1 & 2.
  • Add method to make sure RoundScope and associated Group are deleted as well when a Round is deleted
  • Add migration deleting dangling rounds
  • Add tests

How to test

In the UI:

  • Add a round to a campaign
  • Save
  • check the API response and find the new round ID
  • find the new round in the django admin
  • In the UI: delete the new round and save
  • Refresh the django admin: the new round should be gone

Alternately, you can check directly on the DB

Print screen / video

N/A

Follow the Conventional Commits specification

The merge message of a pull request must follow the Conventional Commits specification.

This convention helps to automatically generate release notes.

Use lowercase for consistency.

Example:

fix: empty instance pop up

Refs: IA-3665

Note that the Jira reference is preceded by a line break.

Both the line break and the Jira reference are entered in the Add an optional extended description… field.

@beygorghor beygorghor added the release Should be released in production at next deploy label Jan 9, 2025
@quang-le quang-le requested a review from kemar January 9, 2025 11:26
Copy link
Member

@kemar kemar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost LGTM.

I have a concern with the usage of signals.

which happens when a Round is deleted.
"""
if instance.group:
instance.group.delete()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a rule of thumb with signals: use them as a last resort.

The reason is that after adding a bunch of signals, projects start to turn into knotted hairballs that can't be untangled.

Do you think it would be possible to move this either into RoundScope.delete() or in a custom model manager method?

Otherwise, let's move it into a proper signals.py file to make it obvious and easy to spot.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try it

cls.source_version,
cls.ou_type_country,
cls.ou_type_district,
"GROLAND",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this better than "Hydroponic gardens"? 🤣

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally, and this is a hill I'm ready to die on 😁

More seriously, the name field don't matter that much as long as the variable/property is correctly named , I think

@@ -26,7 +26,7 @@ def setUpTestData(cls):
cls.now = now()
cls.source_version_1 = m.SourceVersion.objects.create(data_source=cls.data_source, number=1)
cls.account = polio_account = Account.objects.create(name="polio", default_version=cls.source_version_1)
cls.yoda = cls.create_user_with_profile(username="yoda", account=polio_account, permissions=["iaso_forms"])
cls.user = cls.create_user_with_profile(username="yoda", account=polio_account, permissions=["iaso_forms"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release Should be released in production at next deploy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants