Skip to content

Commit

Permalink
Save parentCojo on childCog
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadsw committed Oct 25, 2024
1 parent 58c03c3 commit 6c220a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 7 additions & 2 deletions specifyweb/businessrules/rules/cojo_rules.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from specifyweb.businessrules.exceptions import BusinessRuleException
from specifyweb.businessrules.orm_signal_handler import orm_signal_handler
from specifyweb.specify.models import Collectionobjectgroupjoin
from specifyweb.specify.models import Collectionobjectgroupjoin, Collectionobjectgroup

@orm_signal_handler('pre_save', 'Collectionobjectgroupjoin')
def cojo_pre_save(cojo):
Expand All @@ -24,4 +24,9 @@ def cojo_pre_save(cojo):
(Collectionobjectgroupjoin.objects
.filter(parentcog=cojo.parentcog)
.update(issubstrate=False))


@orm_signal_handler('post_save', 'Collectionobjectgroupjoin')
def cojo_post_save(cojo):
if cojo.childcog is not None:
cojo.childcog.parentcojo = cojo
cojo.childcog.save()
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ export function COJODialog({

newCOJO.set(field, resourceUrl as never);
newCOJO.set('parentCog', parentResourceUrl as never);

if (resourceToUse.specifyTable.name === 'CollectionObjectGroup') {
(resourceToUse as SpecifyResource<CollectionObjectGroup>).set(
'parentCojo',
newCOJO
);
}

collection?.add(newCOJO);
};

Expand Down

0 comments on commit 6c220a4

Please sign in to comment.