Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
# Don't purge on fixture loads
if kwargs.get('raw', False):
return
# Only purge on published instances
if instance.is_published:
# Purge our common pages
purge_url('/downloads/')
purge_url('/downloads/latest/python2/')
purge_url('/downloads/latest/python3/')
purge_url('/downloads/mac-osx/')
purge_url('/downloads/source/')
purge_url('/downloads/windows/')
if instance.get_version() is not None:
purge_url('/ftp/python/{}/'.format(instance.get_version()))
# See issue #584 for details
purge_url('/box/supernav-python-downloads/')
purge_url('/box/homepage-downloads/')
purge_url('/box/download-sources/')
# Purge the release page itself
purge_url(instance.get_absolute_url())
if instance.is_published and instance.featured:
content = render_to_string('successstories/supernav.html', {
'story': instance,
})
box, _ = Box.objects.update_or_create(
label='supernav-python-success-stories',
defaults={
'content': content,
'content_markup_type': 'html',
}
)
# Purge Fastly cache
purge_url('/box/supernav-python-success-stories/')
if instance.is_published:
# Purge the page itself
purge_url(instance.get_absolute_url())
if kwargs.get('raw', False):
return
# Only purge on published instances
if instance.is_published:
# Purge our common pages
purge_url('/downloads/')
purge_url('/downloads/latest/python2/')
purge_url('/downloads/latest/python3/')
purge_url('/downloads/mac-osx/')
purge_url('/downloads/source/')
purge_url('/downloads/windows/')
if instance.get_version() is not None:
purge_url('/ftp/python/{}/'.format(instance.get_version()))
# See issue #584 for details
purge_url('/box/supernav-python-downloads/')
purge_url('/box/homepage-downloads/')
purge_url('/box/download-sources/')
# Purge the release page itself
purge_url(instance.get_absolute_url())
def purge_fastly_download_pages(sender, instance, **kwargs):
"""
Purge Fastly caches so new Downloads show up more quickly
"""
# Don't purge on fixture loads
if kwargs.get('raw', False):
return
# Only purge on published instances
if instance.is_published:
# Purge our common pages
purge_url('/downloads/')
purge_url('/downloads/latest/python2/')
purge_url('/downloads/latest/python3/')
purge_url('/downloads/mac-osx/')
purge_url('/downloads/source/')
purge_url('/downloads/windows/')
if instance.get_version() is not None:
purge_url('/ftp/python/{}/'.format(instance.get_version()))
# See issue #584 for details
purge_url('/box/supernav-python-downloads/')
purge_url('/box/homepage-downloads/')
purge_url('/box/download-sources/')
# Purge the release page itself
purge_url(instance.get_absolute_url())
def purge_fastly_download_pages(sender, instance, **kwargs):
"""
Purge Fastly caches so new Downloads show up more quickly
"""
# Don't purge on fixture loads
if kwargs.get('raw', False):
return
# Only purge on published instances
if instance.is_published:
# Purge our common pages
purge_url('/downloads/')
purge_url('/downloads/latest/python2/')
purge_url('/downloads/latest/python3/')
purge_url('/downloads/mac-osx/')
purge_url('/downloads/source/')
purge_url('/downloads/windows/')
if instance.get_version() is not None:
purge_url('/ftp/python/{}/'.format(instance.get_version()))
# See issue #584 for details
purge_url('/box/supernav-python-downloads/')
purge_url('/box/homepage-downloads/')
purge_url('/box/download-sources/')
# Purge the release page itself
purge_url(instance.get_absolute_url())
def purge_fastly_download_pages(sender, instance, **kwargs):
"""
Purge Fastly caches so new Downloads show up more quickly
"""
# Don't purge on fixture loads
if kwargs.get('raw', False):
return
# Only purge on published instances
if instance.is_published:
# Purge our common pages
purge_url('/downloads/')
purge_url('/downloads/latest/python2/')
purge_url('/downloads/latest/python3/')
purge_url('/downloads/mac-osx/')
purge_url('/downloads/source/')
purge_url('/downloads/windows/')
if instance.get_version() is not None:
purge_url('/ftp/python/{}/'.format(instance.get_version()))
# See issue #584 for details
purge_url('/box/supernav-python-downloads/')
purge_url('/box/homepage-downloads/')
purge_url('/box/download-sources/')
# Purge the release page itself
purge_url(instance.get_absolute_url())
def purge_fastly_download_pages(sender, instance, **kwargs):
"""
Purge Fastly caches so new Downloads show up more quickly
"""
# Don't purge on fixture loads
if kwargs.get('raw', False):
return
# Only purge on published instances
if instance.is_published:
# Purge our common pages
purge_url('/downloads/')
purge_url('/downloads/latest/python2/')
purge_url('/downloads/latest/python3/')
purge_url('/downloads/mac-osx/')
purge_url('/downloads/source/')
purge_url('/downloads/windows/')
if instance.get_version() is not None:
purge_url('/ftp/python/{}/'.format(instance.get_version()))
# See issue #584 for details
purge_url('/box/supernav-python-downloads/')
purge_url('/box/homepage-downloads/')
purge_url('/box/download-sources/')
# Purge the release page itself
purge_url(instance.get_absolute_url())
def purge_fastly_cache(sender, instance, **kwargs):
"""
Purge fastly.com cache on new jobs
Requires settings.FASTLY_API_KEY being set
"""
# Skip in fixtures
if kwargs.get('raw', False):
return
if instance.status == Job.STATUS_APPROVED:
purge_url(reverse('jobs:job_detail', kwargs={'pk': instance.pk}))
purge_url(reverse('jobs:job_list'))
purge_url(reverse('jobs:job_rss'))
return
# Only purge on published instances
if instance.is_published:
# Purge our common pages
purge_url('/downloads/')
purge_url('/downloads/latest/python2/')
purge_url('/downloads/latest/python3/')
purge_url('/downloads/mac-osx/')
purge_url('/downloads/source/')
purge_url('/downloads/windows/')
if instance.get_version() is not None:
purge_url('/ftp/python/{}/'.format(instance.get_version()))
# See issue #584 for details
purge_url('/box/supernav-python-downloads/')
purge_url('/box/homepage-downloads/')
purge_url('/box/download-sources/')
# Purge the release page itself
purge_url(instance.get_absolute_url())
if instance.is_published:
# Purge our common pages
purge_url('/downloads/')
purge_url('/downloads/latest/python2/')
purge_url('/downloads/latest/python3/')
purge_url('/downloads/mac-osx/')
purge_url('/downloads/source/')
purge_url('/downloads/windows/')
if instance.get_version() is not None:
purge_url('/ftp/python/{}/'.format(instance.get_version()))
# See issue #584 for details
purge_url('/box/supernav-python-downloads/')
purge_url('/box/homepage-downloads/')
purge_url('/box/download-sources/')
# Purge the release page itself
purge_url(instance.get_absolute_url())