Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
do not populate all vocabularies
  • Loading branch information
mortenwh committed Jun 28, 2023
commit fd4c33b306259dc5e5627dce633548ec5c59b732
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ def handle(self, *args, **options):
models = [
Parameter,
DataCenter,
HorizontalDataResolution,
#HorizontalDataResolution,
Instrument,
ISOTopicCategory,
Location,
Platform,
Project,
#Project,
ScienceKeyword,
TemporalDataResolution,
VerticalDataResolution]
#TemporalDataResolution,
#VerticalDataResolution,
]

for model in models:
model.objects.create_from_vocabularies(**options)
6 changes: 4 additions & 2 deletions geospaas/vocabularies/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ def create_instances(self, pti_list):
"""
num = 0
for entry in pti_list:
pp, created = self.get_or_create(entry)
if bool(entry):
pp, created = self.get_or_create(entry)
else:
created = False
if created: num+=1
print("Successfully added %d new entries" % num)

def get_or_create(self, entry, *args, **kwargs):
""" Get or create database instance from input pythesint entry """

params = {key : entry[self.mapping[key]] for key in self.mapping}
return super(VocabularyManager, self).get_or_create(**params)

Expand Down