@@ -45,13 +45,30 @@ def get_redirect_url(self, **kwargs):
4545 return reverse ('download' )
4646
4747
48+ class DownloadLatestPyManager (RedirectView ):
49+ """ Redirect to latest Python install manager release """
50+ permanent = False
51+
52+ def get_redirect_url (self , ** kwargs ):
53+ try :
54+ latest_pymanager = Release .objects .latest_pymanager ()
55+ except Release .DoesNotExist :
56+ latest_pymanager = None
57+
58+ if latest_pymanager :
59+ return latest_pymanager .get_absolute_url ()
60+ else :
61+ return reverse ('downloads' )
62+
63+
4864class DownloadBase :
4965 """ Include latest releases in all views """
5066 def get_context_data (self , ** kwargs ):
5167 context = super ().get_context_data (** kwargs )
5268 context .update ({
5369 'latest_python2' : Release .objects .latest_python2 (),
5470 'latest_python3' : Release .objects .latest_python3 (),
71+ 'latest_pymanager' : Release .objects .latest_pymanager (),
5572 })
5673 return context
5774
@@ -71,6 +88,8 @@ def get_context_data(self, **kwargs):
7188 except Release .DoesNotExist :
7289 latest_python3 = None
7390
91+ latest_pymanager = context .get ('latest_pymanager' )
92+
7493 python_files = []
7594 for o in OS .objects .all ():
7695 data = {
@@ -80,6 +99,8 @@ def get_context_data(self, **kwargs):
8099 data ['python2' ] = latest_python2 .download_file_for_os (o .slug )
81100 if latest_python3 is not None :
82101 data ['python3' ] = latest_python3 .download_file_for_os (o .slug )
102+ if latest_pymanager is not None :
103+ data ['pymanager' ] = latest_pymanager .download_file_for_os (o .slug )
83104 python_files .append (data )
84105
85106 context .update ({
0 commit comments