Skip to content

Commit

Permalink
Merge pull request #7221 from caseyrollins/feature/fix-populate-prepr…
Browse files Browse the repository at this point in the history
…ints-script

[feature] Fix populate_preprint_providers Script [No Ticket]
  • Loading branch information
sloria committed May 15, 2017
2 parents 9c3f999 + 01acb35 commit c6624df
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scripts/populate_preprint_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ def get_license(name):
def update_or_create(provider_data):
provider = PreprintProvider.load(provider_data['_id'])
licenses = [get_license(name) for name in provider_data.pop('licenses_acceptable', [])]
default_license = provider_data.pop('default_license', False)
if provider:
provider_data['subjects_acceptable'] = map(
lambda rule: (map(get_subject_id, rule[0]), rule[1]),
provider_data['subjects_acceptable']
)
if licenses:
provider.licenses_acceptable.add(*licenses)
default_license = provider_data.pop('default_license', False)
if default_license:
provider.default_license = get_license(default_license)
for key, val in provider_data.iteritems():
Expand All @@ -69,6 +69,9 @@ def update_or_create(provider_data):
new_provider.save()
if licenses:
new_provider.licenses_acceptable.add(*licenses)
if default_license:
new_provider.default_license = get_license(default_license)
new_provider.save()
provider = PreprintProvider.load(new_provider._id)
print('Added new preprint provider: {}'.format(provider._id))
return new_provider, True
Expand Down

0 comments on commit c6624df

Please sign in to comment.