Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove hardcoded version numbers from the download page.

  • Loading branch information...
commit 1a94cedae7c9eacf5f755ec1bd37f9c3544576ca 1 parent b1dbfa6
Aymeric Augustin authored March 14, 2013
6  releases/urls.py
... ...
@@ -1,10 +1,10 @@
1 1
 from __future__ import absolute_import, unicode_literals
2 2
 
3  
-from django.conf.urls import patterns
  3
+from django.conf.urls import patterns, url
4 4
 
5 5
 from .views import index, redirect
6 6
 
7 7
 urlpatterns = patterns('',
8  
-    (r'^$', index),
9  
-    (r'^([0-9a-z_.-]+)/(tarball|checksum|egg)/$', redirect),
  8
+    url(r'^$', index, name='download'),
  9
+    url(r'^([0-9a-z_.-]+)/(tarball|checksum|egg)/$', redirect, name='download-redirect'),
10 10
 )
14  releases/views.py
@@ -7,7 +7,19 @@
7 7
 
8 8
 
9 9
 def index(request):
10  
-    return render(request, 'releases/download.html')
  10
+    # Build a dictionary of x => latest 1.x.y release
  11
+    releases = {}
  12
+    for release in Release.objects.filter(status='f', major=1).order_by('minor', 'micro'):
  13
+        releases[release.minor] = release
  14
+    releases = [releases[minor] for minor in sorted(releases)]
  15
+    current = releases.pop()
  16
+    previous = releases.pop()
  17
+    context = {
  18
+        'current_version': current.version,
  19
+        'previous_version': previous.version,
  20
+        'earlier_versions': [release.version for release in reversed(releases)],
  21
+    }
  22
+    return render(request, 'releases/download.html', context)
11 23
 
12 24
 
13 25
 def redirect(request, version, kind):
21  templates/releases/download.html
@@ -13,17 +13,17 @@
13 13
 
14 14
 <h2>Option 1. Get the latest official version</h2>
15 15
 
16  
-<p>The latest official version is 1.5. You can get it by direct download:
  16
+<p>The latest official version is {{ current_version }}. You can get it by direct download:
17 17
 
18  
-<p>First, download <a href="https://www.djangoproject.com/download/1.5/tarball/">Django-1.5.tar.gz</a> (<a href="https://www.djangoproject.com/download/1.5/checksum/">checksums</a>). Then:</p>
  18
+<p>First, download <a href="{% url 'download-redirect' current_version 'tarball' %}">Django-{{ current_version }}.tar.gz</a> (<a href="{% url 'download-redirect' current_version 'checksum' %}">checksums</a>). Then:</p>
19 19
 
20  
-<pre class="literal-block"><code>tar xzvf Django-1.5.tar.gz
21  
-cd Django-1.5
  20
+<pre class="literal-block"><code>tar xzvf Django-{{ current_version }}.tar.gz
  21
+cd Django-{{ current_version }}
22 22
 sudo python setup.py install</code></pre>
23 23
 
24 24
 <p>You can also use <a href="http://www.pip-installer.org/en/latest/">pip</a>:
25 25
 
26  
-<pre class="literal-block"><code>pip install Django==1.5</code></pre>
  26
+<pre class="literal-block"><code>pip install Django=={{ current_version }}</code></pre>
27 27
 
28 28
 <h2>Option 2. Get the latest development version</h2>
29 29
 
@@ -43,7 +43,7 @@
43 43
 {% block content-related %}
44 44
 <h2>For the impatient:</h2>
45 45
 <ul>
46  
-  <li>Latest release: <a href="https://www.djangoproject.com/download/1.5/tarball/">Django-1.5.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.5/checksum/">Django-1.5.checksum.txt</a></li>
  46
+  <li>Latest release: <a href="{% url 'download-redirect' current_version 'tarball' %}">Django-{{ current_version }}.tar.gz</a><br>Checksum: <a href="{% url 'download-redirect' current_version 'checksum' %}">Django-{{ current_version }}.checksum.txt</a></li>
47 47
 </ul>
48 48
 
49 49
 <h2>Which version is better?</h2>
@@ -52,14 +52,13 @@
52 52
 <p>If you're just looking for a stable deployment target and don't mind waiting for the next release, you'll want to stick with the latest official release (which will always include detailed notes on any changes you'll need to make while upgrading).</p>
53 53
 <h2>Previous releases</h2>
54 54
 <ul>
55  
-  <li>Django 1.4.5: <a href="https://www.djangoproject.com/download/1.4.5/tarball/">Django-1.4.5.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.4.5/checksum/">Django-1.4.5.checksum.txt</a></li>
  55
+  <li>Django {{ previous_version }}: <a href="{% url 'download-redirect' previous_version 'tarball' %}">Django-{{ previous_version }}.tar.gz</a><br>Checksum: <a href="{% url 'download-redirect' previous_version 'checksum' %}">Django-{{ previous_version }}.checksum.txt</a></li>
56 56
 </ul>
57 57
 
58 58
 <h2>Unsupported previous releases (no longer receive security updates or bugfixes)</h2>
59 59
 <ul>
60  
-  <li>Django 1.3: <a href="https://www.djangoproject.com/download/1.3.7/tarball/">Django-1.3.7.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.3.7/checksum/">Django-1.3.7.checksum.txt</a></li>
61  
-  <li>Django 1.2: <a href="https://www.djangoproject.com/download/1.2.7/tarball/">Django-1.2.7.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.2.7/checksum/">Django-1.2.7.checksum.txt</a></li>
62  
-  <li>Django 1.1: <a href="https://www.djangoproject.com/download/1.1.4/tarball/">Django-1.1.4.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.1.4/checksum/">Django-1.1.4.checksum.txt</a></li>
63  
-  <li>Django 1.0: <a href="https://www.djangoproject.com/download/1.0.4/tarball/">Django-1.0.4.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.0.4/checksum/">Django-1.0.4.checksum.txt</a></li>
  60
+  {% for earlier_version in earlier_versions %}
  61
+  <li>Django {{ earlier_version }}: <a href="{% url 'download-redirect' earlier_version 'tarball' %}">Django-{{ earlier_version }}.tar.gz</a><br>Checksum: <a href="{% url 'download-redirect' earlier_version 'checksum' %}">Django-{{ earlier_version }}.checksum.txt</a></li>
  62
+  {% endfor %}
64 63
 </ul>
65 64
 {% endblock %}

0 notes on commit 1a94ced

Please sign in to comment.
Something went wrong with that request. Please try again.