Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from acdh-oeaw/link-instance-author
Browse files Browse the repository at this point in the history
Link instance author
  • Loading branch information
gythaogg authored Feb 28, 2024
2 parents 01afb99 + 127388e commit caeb23b
Show file tree
Hide file tree
Showing 3 changed files with 397 additions and 384 deletions.
14 changes: 6 additions & 8 deletions apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,18 @@ def citation(self):
@cached_property
def work(self):
try:
WORK_REL = Property.objects.get(name="has as an instance")
work = Triple.objects.filter(prop=WORK_REL, obj=self)
return work[0].subj
work_has_as_instance = WorkHasAsAnInstanceInstance.objects.filter(obj=self)
return work_has_as_instance[0].subj
except Exception as e:
print("Error while fetching work associated with instance:", e)
return

@cached_property
def author(self):
try:
return self.work.author
return Work.objects.get(id=self.work.id).author
except Exception as e:
print(e)
print("Error while getting author info for instance", e)
return


Expand Down Expand Up @@ -168,9 +168,7 @@ class Work(TempEntityClass):
@cached_property
def author(self):
try:
# TODO: Should this be within property?
AUTHOR_REL = Property.objects.get(name="author of")
author = Triple.objects.filter(prop=AUTHOR_REL, obj=self)
author = PersonAuthorOfWork.objects.filter(obj=self)
return author[0].subj
except Exception as e:
print(e)
Expand Down
Loading

0 comments on commit caeb23b

Please sign in to comment.