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

Add support for entities #2504

Merged
merged 150 commits into from
May 7, 2024
Merged

Add support for entities #2504

merged 150 commits into from
May 7, 2024

Conversation

kelvin-muchiri
Copy link
Contributor

@kelvin-muchiri kelvin-muchiri commented Nov 9, 2023

Changes / Features implemented

  • Add EntityList, RegistrationForm, FollowUpForm models
  • Automatically create Entity when a RegistrationForm receives a submission
  • Upgrade pyxform to a version that supports entities definition
  • Add endpoints to fetch Entities releated data
  • Replace all occurrences of xml.dom.minidom.parseString with defusedxml.minidom.parseString to avoid threats of XML attacks https://pypi.org/project/defusedxml
  • Add new model GenericExport for storing export related data for EntityList datasets and any other objects in future that may need to have exports

Steps taken to verify this change does what is intended

  • QA

Side effects of implementing this change

Before submitting this PR for review, please make sure you have:

  • Included tests
  • Updated documentation

Closes #2500

version="2022110901",
xml=data_dict.xml,
json=json.dumps(data_dict.json),
)
Copy link
Member

Choose a reason for hiding this comment

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

Could we have used onadata.libs.utils.logger_tools.create_xform_version(xform: Xform, user: User)?

Perhaps, could we consider adding publish_md_form() similar to the publish_xls_form() and publish_xml_form() functions under onadata.libs.utils.logger_tools that have the same signature and all create the XFormVersion object of the form they publish? This will mean we update self._publish_markdown() to use the new publish_md/markdown_form() function and an XFormVersion object will always be created when publishing the form.

Copy link
Contributor Author

@kelvin-muchiri kelvin-muchiri Apr 12, 2024

Choose a reason for hiding this comment

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

Could we have used onadata.libs.utils.logger_tools.create_xform_version(xform: Xform, user: User)?

@ukanga Since this is a test we should assume onadata.libs.utils.logger_tools.create_xform_version does not exist in order to avoid coupling the tests with actual implementations. Also, using TDD, we wouldn't expect onadata.libs.utils.logger_tools.create_xform_version to exist

Copy link
Member

Choose a reason for hiding this comment

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

@kelvin-muchiri There are several places where the XFormVersion is directly created. So, if we apply this change only in self._publish_markdown(), the repetition can be avoided.

Copy link
Member

Choose a reason for hiding this comment

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

I agree we may not need to create publish_md/markdown_form() unless we see future potential for it. The main reason to consider it is to ensure we do not repeat or forget some steps, like, in this case, the function self._publish_markdown() forgot to create this object that should always be present when publishing a form.

Copy link
Contributor Author

@kelvin-muchiri kelvin-muchiri Apr 16, 2024

Choose a reason for hiding this comment

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

@ukanga I resolved this by removing the redundant _publish_markdown in TestAbstractViewSet and inheriting TestBase

onadata/apps/viewer/models/data_dictionary.py Show resolved Hide resolved
onadata/libs/models/abstract_base.py Outdated Show resolved Hide resolved
KipSigei
KipSigei previously approved these changes Apr 17, 2024
KipSigei
KipSigei previously approved these changes Apr 17, 2024
ukanga
ukanga previously approved these changes Apr 19, 2024
KipSigei
KipSigei previously approved these changes Apr 23, 2024
@kelvin-muchiri kelvin-muchiri merged commit cc67ff9 into main May 7, 2024
9 checks passed
@kelvin-muchiri kelvin-muchiri deleted the 2500-entities branch May 7, 2024 13:24
@KipSigei KipSigei mentioned this pull request Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for entities
3 participants