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

Infer scoping for attachments #3315

Open
wants to merge 8 commits into
base: production
Choose a base branch
from
Open

Infer scoping for attachments #3315

wants to merge 8 commits into from

Conversation

melton-jason
Copy link
Contributor

@melton-jason melton-jason commented Apr 7, 2023

Fixes #3289

Every attachment must have a scope type and scope id. The way the backend handles assigning scope type and scope id for attachments is to get the scoping of the 'attachee' record. Previously, this scoping was hard-coded in a scoping python file.

This pull request is an extension of the changes made in #2744

Here are a list of all attachment tables in Specify

Accession Attachment
Agent Attachment
Attachment
Attachment Metadata
Borrow Attachment
Collecting Event Attachment
Collecting Trip Attachment
Collection Object Attachment
Conservator Description Attachment
Conservator Event Attachment
DNA Sequence Attachment
DNA Sequencing Run Attachment
Deaccession Attachment
Disposal Attachment
Exchange In Attachment
Exchange Out Attachment
Field Notebook Attachment
Field Notebook Page Attachment
Field Notebook Page Set Attachment
Gift Attachment
Loan Attachment
Locality Attachment
Permit Attachment
Preparation Attachment
Reference Work Attachment
Repository Agreement Attachment
Storage Attachment
Taxon Attachment
Treatment Event Attachment

Previously, only the following attachment tables were supported

Accession
Agent
Borrow 
Collecting Event
Collection Object
Conserv Description
Conserv Event
DNA Sequence
DNA Sequencing
Exchange In
Exchange Out
Field Notebook
Field Notebook Page
Field Notebook Page Set
Gift
Loan
Locality
Permit
Preparation
Referencework
Repository Agreement
Taxon

With these changes, the backend should try and infer the scoping of tables based on if they have any of the relationships commonly used for scoping (division_id, discipline_id, collectionmemberid, collection_id).
If the table contains more than one of the scoping relationships, it will assign scoping based in the following priorities:

  • division_id
  • discipline_id
  • collectionmemberid
  • collection_id
  • institution

Here is how the following tables should be scoped:

Table Scope
Accession Institution/Division (based on institution.isAccessionsGlobal)
Agent Division
Collector Division
Conserv Description Division
Discipline Division
Conserv Description Division
Exchange In Division
Exchange Out Division
Funding Agent Division
Group Persion Division
Repository Agreement Division
Treatment Event Division
---- ----
Attribute Definition Discipline
Collecting Event Discipline
Collecting Event Attribute Discipline
Collecting Trip Discipline
Collecting Trip Attribute Discipline
Collection Discipline
Exchange In Prep Discipline
Exchange Out Prep Discipline
Field Notebook Discipline
Field Notebook Page Discipline
Field Notebook Page Set Discipline
Gift Discipline
Loan Discipline
Locality Discipline
Locality Citation Discipline
Locality Name Alias Discipline
Paleo Context Discipline
Shipment Discipline
App Resource Default Discipline
Sp Export Schema Discipline
Locale Container Discipline
Sp Task Semaphore Discipline
Taxon Tree Definition Discipline
---- ----
Borrow Collection
Borrow Material Collection
Borrow Return Material Collection
Collection Object Collection
Collection Object Attribute Collection
Collection Object Citation Collection
Collection Object Property Collection
Container Collection
DNA Sequence Collection
DNA Sequencing Run Collection
Determination Collection
Determination Citation Collection
Information Request Collection
Material Sample Collection
Other Identifier Collection
Preparation Collection
Preparation Attribute Collection
Preparation Property Collection
Project Collection
Record Set Collection
Sp Export Schema Mapping Collection
Sp Field Value Default Collection
Sp Symbiota Instance Collection
Voucher Relationships Collection

specifyweb/specify/scoping.py Outdated Show resolved Hide resolved
@grantfitzsimmons grantfitzsimmons self-requested a review April 13, 2023 13:11
Copy link
Member

@grantfitzsimmons grantfitzsimmons left a comment

Choose a reason for hiding this comment

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

https://coldfish-issue-3289.test.specifysystems.org/specify/view/treatmentevent/new/

I uploaded a single attachment to this treatment event and received the following error:

TypeError at /api/specify/treatmentevent/ cannot unpack non-iterable method object Request Method: POST Request URL: http://coldfish-issue-3289.test.specifysystems.org/api/specify/treatmentevent/ 

image

Specify 7 Crash Report - 2023-04-13T13_12_08.319Z.txt

@grantfitzsimmons
Copy link
Member

TypeError at /api/specify/permit/ cannot unpack non-iterable method object Request Method: POST Request URL: http://coldfish-issue-3289.test.specifysystems.org/api/specify/permit/ 

Same issue on permit

@grantfitzsimmons
Copy link
Member

@melton-jason Can you see if this can be investigated over the next couple of weeks?

@melton-jason
Copy link
Contributor Author

I have made significant changes to how backend scoping is handled in #4215.
As a result, I'm hoping to get back to this Pull Request soon to make the required changes or see whether the changes in #4215 have inadvertently fixed #3289

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.

Cannot save Collecting Trip or Storage with an attachment
4 participants