Skip to content

Commit

Permalink
fix: do not rely on APIS_BASE_URI
Browse files Browse the repository at this point in the history
base uri falls back to base domain for RDF serializer if
APIS_BASE_DOMAIN is not set
  • Loading branch information
sennierer committed Dec 5, 2024
1 parent 9ebcde2 commit 1bd9cdb
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions apis_ontology/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ class PersonCidocSerializer(serializers.BaseSerializer):
def to_representation(self, instance):
g = Graph()
instance = normalize_empty_attributes(instance)
base_uri = getattr(
settings, "APIS_BASE_URI", self.context["request"].build_absolute_uri("/")
)

# Define namespaces
crm = Namespace("http://www.cidoc-crm.org/cidoc-crm/")
oebl_person = Namespace(
f"{getattr(settings, 'APIS_BASE_URI')}apis_ontology.person/"
)
oebl_appellation = Namespace(
f"{getattr(settings, 'APIS_BASE_URI')}appellation/"
)
oebl_person = Namespace(f"{base_uri}apis_ontology.person/")
oebl_appellation = Namespace(f"{base_uri}appellation/")
oebl_attr = Namespace(f"{getattr(settings, 'APIS_BASE_URI')}attributes/")

g.namespace_manager.bind("crm", crm, replace=True)
Expand Down Expand Up @@ -150,18 +149,15 @@ class PersonInstitutionCidocBaseSerializer(serializers.BaseSerializer):
def to_representation(self, instance):
instance = normalize_empty_attributes(instance)
g = Graph()
base_uri = getattr(
settings, "APIS_BASE_URI", self.context["request"].build_absolute_uri("/")
)

# Define namespaces
crm = Namespace("http://www.cidoc-crm.org/cidoc-crm/")
oebl_person = Namespace(
f"{getattr(settings, 'APIS_BASE_URI')}apis_ontology.person/"
)
oebl_inst = Namespace(
f"{getattr(settings, 'APIS_BASE_URI')}apis_ontology.institution/"
)
oebl_appellation = Namespace(
f"{getattr(settings, 'APIS_BASE_URI')}appellation/"
)
oebl_person = Namespace(f"{base_uri}apis_ontology.person/")
oebl_inst = Namespace(f"{base_uri}apis_ontology.institution/")
oebl_appellation = Namespace(f"{base_uri}appellation/")
oebl_attr = Namespace(f"{getattr(settings, 'APIS_BASE_URI')}attributes/")

g.namespace_manager.bind("crm", crm, replace=True)
Expand Down

0 comments on commit 1bd9cdb

Please sign in to comment.