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 SpdatasetAttachment #6269

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

Add SpdatasetAttachment #6269

wants to merge 11 commits into from

Conversation

alesan99
Copy link
Contributor

@alesan99 alesan99 commented Feb 24, 2025

Fixes #6074

Warning

This PR affects database migrations. See migration testing instructions.

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
  • Add relevant documentation (Tester - Dev)
  • Add a reverse migration if a migration is present in the PR

Testing instructions

This table will be used for uploading attachments through the workbench in a future PR. For now, it can be tested by creating a data entry form for workbench data sets and adding an attachment there. The user won't do this, but its important to check the table works correctly.

  • Go to App Resources
  • Add this form to Spdataset:
<viewdef name="Spdataset" class="edu.ku.brc.specify.datamodel.Spdataset" type="form" gettable="edu.ku.brc.af.ui.forms.DataGetterForObj" settable="edu.ku.brc.af.ui.forms.DataSetterForObj">
	<desc>The Spdataset Table</desc>
	<enableRules/>
	<columnDef>p,2px,p,2px,p,2px,p,2px,p,2px,p,p:g</columnDef>
	<rowDef auto="true" cell="p" sep="2px"/>
	<rows>
		<row>
			<cell type="label" labelfor="1"/>
			<cell type="field" id="1" name="columns" uitype="text"/>
			<cell type="label" labelfor="2"/>
			<cell type="field" id="2" name="name" uitype="text"/>
		</row>
		<row>
			<cell type="label" labelfor="5"/>
			<cell type="field" id="5" name="data" uitype="text"/>
			<cell type="label" labelfor="6"/>
			<cell type="field" id="6" name="Importedfilename" uitype="text"/>
		</row>
		<row>
			<cell type="label" labelfor="3"/>
			<cell type="field" id="3" name="specifyuser" uitype="querycbx" initialize="name=SpecifyUser;title=specifyuser" isrequired="true"/>
			<cell type="label" labelfor="33"/>
			<cell type="field" id="33" name="collection" uitype="querycbx" initialize="name=Collection;title=collection" isrequired="true"/>
		</row>
		<row>
			<cell type="subview" id="attachments" viewname="ObjectAttachment" name="spDataSetAttachments" colspan="7" initialize="icon=SpDataSetAttachment" defaulttype="icon"/>
		</row>
	</rows>
</viewdef>
  • Go to specify/view/spdataset/new/
  • Fill in all the fields for the data set
  • Add an attachment
  • Make sure you can save it
  • Make sure you can delete the attachment by deleting the Spdataset
  • Go to Schema config
  • Make sure the SpDataSetAttachment table looks correct
  • Make sure you can configure it like any other table
  • Note: You cannot add uniqueness rules due to an existing bug with system tables

DEV TESTING:

  • Make sure the new workbench app migration 0006_spdatasetattachment is applied correctly
  • Make sure it can be reverted

@alesan99 alesan99 added this to the 7.11 milestone Feb 24, 2025
@alesan99
Copy link
Contributor Author

alesan99 commented Feb 26, 2025

TODO:

  • Regenerate types.ts
  • Verify its possible to create an attachment (It works through a custom Spdataset form, except for a missing CollectionMemberID (Apparently an issue with other new attachments Adding attachments to Age tables causes error #6084 )). Decided to use PreparationAttachment as a base instead of RelativeAgeAttachment since that one has been proven to work.
  • Fix uniqueness rules. I think this needs a separate migration? UPDATE: No, uniqueness rules are also broken on Spdataset and any models not in the main specify app
  • Fix failing backend test (custom_save issue, commented out like in Spdataset)
  • Fix failing frontend test (Kinda, chose not to update parentTables test because SpDataSetAttachment doesn't get returned, possibly due to capitalization not matching Spdataset)
  • Figure out models_by_table_id.py
  • Fix missing caption and description on Schema Config
  • Hide Sp Data Set Attachment Id (Its not hidden on Spdataset, so maybe not?)

@alesan99 alesan99 marked this pull request as ready for review March 5, 2025 14:02
@alesan99 alesan99 requested review from a team March 5, 2025 14:11
@CarolineDenis CarolineDenis requested a review from acwhite211 March 5, 2025 17:04
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.

  • Make sure you can save it
  • Make sure you can delete the Spdataset
  • Make sure the SpDataSetAttachment table looks correct
  • Make sure you can configure it like any other table

Looks good!
Screenshot 2025-03-05 at 11 36 39 AM

@lexiclevenger lexiclevenger requested a review from a team March 5, 2025 17:52
Copy link
Contributor

@Areyes42 Areyes42 left a comment

Choose a reason for hiding this comment

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

  • Make sure you can save it
  • Make sure you can delete the Spdataset
  • Make sure the SpDataSetAttachment table looks correct
  • Make sure you can configure it like any other table

Looks good! Nitpicky, but could the name get changed to PascalCase in the table view?
Screenshot 2025-03-05 at 1 08 08 PM

@alesan99
Copy link
Contributor Author

Looks good! Nitpicky, but could the name get changed to PascalCase in the table view?

@Areyes42 That's actually a separate table used for Bulk attachment upload.
SpDataSet-Attachment should appear (in pascal case) further down. The naming scheme is not ideal haha but it should read as attachment belonging to spdataset.

Looks good! Screenshot 2025-03-05 at 11 36 39 AM

In your screenshot I'm just now noticing that Spdataset doesn't show a relationship to SpDataSetAttachments. Since the testing checks passed I think its just a visual thing and I only need to update the schema config, but I'm going to double check to make sure.

@@ -0,0 +1,73 @@
# Generated by Django 3.2.15 on 2025-02-25 16:43
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a heads up: After #5413 is merged, this migration would have to be renamed and reordered because that PR has 0006_batch_edit.py

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

Successfully merging this pull request may close these issues.

Add SpdatasetAttachments (Attachments for workbench datasets) (WB Attachments V1)
5 participants