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 business rule to validate Determination taxon with COType #5127

Merged
merged 16 commits into from
Aug 1, 2024

Conversation

sharadsw
Copy link
Contributor

@sharadsw sharadsw commented Jul 22, 2024

Fixes #5111

Using business rules to check whether treeDef of a Determination Taxon is same as treeDef of the selected COType in a CO form. Save is blocked if they are not the same.

Checklist

  • Self-review the PR after opening it to make sure the changes look good
    and self-explanatory (or properly documented)
  • Add automated tests
  • Add relevant issue to release milestone

Testing instructions

Set up the COType field in the CO form

Ideally, COType would be set as a picklist. However, until #5098 is fixed, it is not possible to configure one for COType. Instead for this PR, COType can be set up as a QCBX.

  • Go to App Resources > Type Searches (found under Global Resources)
  • Add the following line in the XML editor:
<typesearch tableid="1015"  name="CollectionObjectType" searchfield="name" displaycols="name" format="%s" uifieldformatter="" dataobjformatter="" system="true"/>
  • Click on the Form Definition tab
  • Select the correct .views file for the collection you are in
  • Go the the Collection Object form definition
  • Add the following lines inside an existing <row>:
<cell type="label" labelfor="111"/>
<cell type="field" id="111" name="collectionObjectType" uitype="querycbx" />

Your CO form should look something like this
image

Testing the PR

  • Make sure to use a db with multiple trees in the same discipline and multiple COTypes in the same collection
  • Go to the CO form
  • Select a COType
  • Add a determination
  • Choose a Taxon which does not belong to the COType's treeDefiniton
  • Verify save is blocked
  • Choose a Taxon which belongs to the COType's treeDefiniton
  • Verify save is enabled

@sharadsw sharadsw changed the base branch from production to issue-4829 July 22, 2024 21:23
Triggered by bc75fd0 on branch refs/heads/issue-5111
@sharadsw sharadsw added this to the 7.9.7 milestone Jul 23, 2024
Copy link
Contributor

@melton-jason melton-jason left a comment

Choose a reason for hiding this comment

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

While there is functionally nothing wrong with this Business Rule, I don't think it addresses what the requirement initially was for #5111:

When creating a new Determination record, the system should check the objectType.taxonTreeDef field to find the tree to search for the user's entered name when searching in the taxon or preferredTaxon query combo boxes

I think the implementation of this would be to scope the results of the Taxon QueryComboBox to the correct tree depending on the objectType.
Is this functionality going to be included in another PR?

Right now from the changes in stored_queries/execution.py, I think the returned results from the QueryComboBox are from all Taxon Trees.

Is this the new requirement? To return all Taxon records when searching and instead have this businessrule to determine whether the determination is correct or not?

This is not the ideal from the user perspective, but it does eliminate a lot of complexity.
Still, if this the approach we are going with then I think we can further improve quality-of-life (such as by ordering the results of the QueryComboBox by Tree).

(Conceptually, wouldn't the ideal implementation default the filtering of results in QueryComboBoxes for Taxon records to the TaxonTreeDef on Collection -> TaxonTreeDef? On the Determination Form/SubView, we can then further filter the results based on the CollectionObject -> coType -> taxonTreeDef.
Definitely not easy, but if we go with a simpler, less complex approach I think we should still try and make it as intuitive as possible).

@sharadsw sharadsw marked this pull request as ready for review July 30, 2024 18:21
@sharadsw sharadsw requested a review from a team July 30, 2024 18:36
Copy link
Collaborator

@emenslin emenslin left a comment

Choose a reason for hiding this comment

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

Base automatically changed from issue-4829 to production August 1, 2024 17:15
@sharadsw sharadsw requested review from emenslin and a team August 1, 2024 19:11
Copy link
Collaborator

@emenslin emenslin left a comment

Choose a reason for hiding this comment

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

Testing the PR

  • Make sure to use a db with multiple trees in the same discipline and multiple COTypes in the same collection
  • Go to the CO form
  • Select a COType
  • Add a determination
  • Choose a Taxon which does not belong to the COType's treeDefiniton
  • Verify save is blocked
  • Choose a Taxon which belongs to the COType's treeDefiniton
  • Verify save is enabled

Looks good, works as expected

@emenslin emenslin requested a review from a team August 1, 2024 19:44
Copy link
Collaborator

@lexiclevenger lexiclevenger left a comment

Choose a reason for hiding this comment

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

Testing the PR

  • Make sure to use a db with multiple trees in the same discipline and multiple COTypes in the same collection
  • Go to the CO form
  • Select a COType
  • Add a determination
  • Choose a Taxon which does not belong to the COType's treeDefiniton
  • Verify save is blocked
  • Choose a Taxon which belongs to the COType's treeDefiniton
  • Verify save is enabled

Looks good!
Screenshot 2024-08-01 at 3 45 45 PM

@sharadsw sharadsw merged commit 067fd09 into production Aug 1, 2024
9 checks passed
@sharadsw sharadsw deleted the issue-5111 branch August 1, 2024 22:05
@specifysoftware
Copy link

This pull request has been mentioned on Specify Community Forum. There might be relevant details there:

https://discourse.specifysoftware.org/t/specify-7-9-7-release-announcement/1979/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

MOTs business logic: Determination subview must use same TaxonTree as COType to be valid
6 participants