Skip to content

Commit

Permalink
Merge branch 'hotfix/23.16.8' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mfraezz committed Jan 8, 2024
2 parents 28a5cd6 + f9b2d28 commit 3fc6a9e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 4 additions & 2 deletions osf_tests/test_generate_sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ def all_included_links(self, user_admin_project_public, user_admin_project_priva
project_preprint_osf.url,
project_preprint_other.url,
registration_active.url,
'/{}/'.format(preprint_osf._id),
'/preprints/{}/{}/'.format(provider_other._id, preprint_other._id),
'/preprints/{}/{}'.format(preprint_osf.provider._id, preprint_osf._id),
'/preprints/{}/{}'.format(provider_other._id, preprint_other._id),
'/{}/download/?format=pdf'.format(preprint_osf._id),
'/{}/download/?format=pdf'.format(preprint_other._id)
])
urls_to_include = [urljoin(settings.DOMAIN, item) for item in urls_to_include]

Expand Down
20 changes: 17 additions & 3 deletions scripts/generate_sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,31 @@ def generate(self):
objs = (Preprint.objects.can_view()
.select_related('node', 'provider', 'primary_file'))
progress.start(objs.count() * 2, 'PREP: ')
osf = PreprintProvider.objects.get(_id='osf')
for obj in objs:
try:
preprint_date = obj.modified.strftime('%Y-%m-%d')
config = settings.SITEMAP_PREPRINT_CONFIG
preprint_url = obj.url
provider = obj.provider
preprint_url = os.path.join('preprints', obj.provider._id, obj._id)
config['loc'] = urljoin(settings.DOMAIN, preprint_url)
config['lastmod'] = preprint_date
self.add_url(config)

# Preprint file urls
try:
file_config = settings.SITEMAP_PREPRINT_FILE_CONFIG
file_config['loc'] = urljoin(
settings.DOMAIN,
os.path.join(
obj._id,
'download',
'?format=pdf'
)
)
file_config['lastmod'] = preprint_date
self.add_url(file_config)
except Exception as e:
self.log_errors(obj.primary_file, obj.primary_file._id, e)

except Exception as e:
self.log_errors(obj, obj._id, e)
progress.increment(2)
Expand Down

0 comments on commit 3fc6a9e

Please sign in to comment.