diff --git a/CHANGELOG b/CHANGELOG index 54338ca..6be1ebf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +tag-0.18-20210905e JP + - Use defaults={} correctly in update_or_create + tag-0.18-20210905d JP - Switch to .objects.update_or_create for Drupal 3.0 diff --git a/bin/route_globus_v3.py b/bin/route_globus_v3.py index 66e8737..b559dea 100755 --- a/bin/route_globus_v3.py +++ b/bin/route_globus_v3.py @@ -439,9 +439,9 @@ def Update_REL(self, myURN, newRELATIONS): relation, created = ResourceV3Relation.objects.update_or_create( ID = relationID, defaults={ - FirstResourceID = myURN, - SecondResourceID = relatedID, - RelationType = relationType + 'FirstResourceID': myURN, + 'SecondResourceID': relatedID, + 'RelationType': relationType }, ) relation.save() @@ -485,15 +485,14 @@ def Write_Globus_Collections(self, content, contype, config): local, created = ResourceV3Local.objects.update_or_create( ID = myGLOBALURN, defaults={ - CreationTime = datetime.now(timezone.utc), - Validity = self.DefaultValidity, - Affiliation = self.Affiliation, - LocalID = item['id'], - LocalType = config['LOCALTYPE'], - #LocalURL = item.get('DrupalUrl', config.get('SOURCEDEFAULTURL', None)), - LocalURL = "https://app.globus.org/file-manager?origin_id="+item['id'], - CatalogMetaURL = self.CATALOGURN_to_URL(config['CATALOGURN']), - EntityJSON = item.data + 'CreationTime': datetime.now(timezone.utc), + 'Validity': self.DefaultValidity, + 'Affiliation': self.Affiliation, + 'LocalID': item['id'], + 'LocalType': config['LOCALTYPE'], + 'LocalURL': "https://app.globus.org/file-manager?origin_id="+item['id'], + 'CatalogMetaURL': self.CATALOGURN_to_URL(config['CATALOGURN']), + 'EntityJSON': item.data }, ) local.save() @@ -541,17 +540,17 @@ def Write_Globus_Collections(self, content, contype, config): resource, created = ResourceV3.objects.update_or_create( ID = myGLOBALURN, defaults={ - Affiliation = self.Affiliation, - LocalID = item['id'], - QualityLevel = 'Production', - Name = resname, - ResourceGroup = myRESGROUP, - Type = myRESTYPE, - ShortDescription = item.get('description',resname), - ProviderID = None, - Description = Description.html(ID=myGLOBALURN), - Keywords = keywords, - Audience = self.Affiliation + 'Affiliation': self.Affiliation, + 'LocalID': item['id'], + 'QualityLevel': 'Production', + 'Name': resname, + 'ResourceGroup': myRESGROUP, + 'Type': myRESTYPE, + 'ShortDescription': item.get('description',resname), + 'ProviderID': None, + 'Description': Description.html(ID=myGLOBALURN), + 'Keywords': keywords, + 'Audience': self.Affiliation }, ) resource.save()