Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Automate the download page for preview releases.

  • Loading branch information...
commit 291fd575a8994aee954dac97b7489544b3be7ec0 1 parent 10f0828
Aymeric Augustin authored March 14, 2013
5  releases/models.py
@@ -12,8 +12,11 @@
12 12
 
13 13
 class ReleaseManager(models.Manager):
14 14
 
  15
+    def preview(self):
  16
+        return self.filter(major=1).exclude(status='f')
  17
+
15 18
     def final(self):
16  
-        return self.filter(status='f', major=1)
  19
+        return self.filter(major=1, status='f')
17 20
 
18 21
     def current(self):
19 22
         return self.final().order_by('-minor', '-micro')[0]
18  releases/views.py
@@ -14,10 +14,28 @@ def index(request):
14 14
     releases = [releases[minor] for minor in sorted(releases)]
15 15
     current = releases.pop()
16 16
     previous = releases.pop()
  17
+    # Handle preview releases
  18
+    try:
  19
+        preview = (Release.objects.preview()
  20
+                .filter(minor__gt=current.minor)
  21
+                .order_by('-minor', '-micro', '-status', '-iteration'))[0]
  22
+    except Release.DoesNotExist:
  23
+        preview_version = None
  24
+        preview_kind = None
  25
+    else:
  26
+        preview_version = preview.version
  27
+        preview_kind = {
  28
+            'a': 'alpha',
  29
+            'b': 'beta',
  30
+            'c': 'release candidate',
  31
+        }[preview.status]
  32
+
17 33
     context = {
18 34
         'current_version': current.version,
19 35
         'previous_version': previous.version,
20 36
         'earlier_versions': [release.version for release in reversed(releases)],
  37
+        'preview_version': preview_version,
  38
+        'preview_kind': preview_kind,
21 39
     }
22 40
     return render(request, 'releases/download.html', context)
23 41
 
20  templates/releases/download.html
@@ -11,7 +11,7 @@
11 11
 
12 12
 <p>Django is available open-source under the <a href="https://github.com/django/django/blob/master/LICENSE">BSD license</a>. It requires Python version 2.6.5 or higher, but it has no dependencies on other Python libraries. There are several ways you can get it:</p>
13 13
 
14  
-<h2>Option 1. Get the latest official version</h2>
  14
+<h2>Option {% cycle '1' '2' '3' as options %}. Get the latest official version</h2>
15 15
 
16 16
 <p>The latest official version is {{ current_version }}. You can get it by direct download:
17 17
 
@@ -25,7 +25,23 @@
25 25
 
26 26
 <pre class="literal-block"><code>pip install Django=={{ current_version }}</code></pre>
27 27
 
28  
-<h2>Option 2. Get the latest development version</h2>
  28
+{% if preview_version %}
  29
+<h2>Option {% cycle options %}. Get the {{ preview_kind }} for {{ preview_version|slice:":3" }}</h2>
  30
+
  31
+<p>As part of the Django {{ preview_version|slice:":3" }} development process, Django {{ preview_version }} is available. This release is only for experienced users who want to try out the new version and help identify any remaining bugs prior to the {{ preview_version|slice:":3" }} release. Please read the {{ preview_version|slice:":3" }} release notes before using this package.
  32
+
  33
+<p>To try out the {{ preview_kind }}, download <a href="{% url 'download-redirect' preview_version 'tarball' %}">Django-{{ preview_version }}.tar.gz</a> (<a href="{% url 'download-redirect' preview_version 'checksum' %}">checksums</a>). Then:</p>
  34
+
  35
+<pre class="literal-block"><code>tar xzvf Django-{{ preview_version }}.tar.gz
  36
+cd Django-{{ preview_version }}
  37
+sudo python setup.py install</code></pre>
  38
+
  39
+<p>You can also use <a href="http://www.pip-installer.org/en/latest/">pip</a>:
  40
+
  41
+<pre class="literal-block"><code>pip install Django=={{ preview_version }}</code></pre>
  42
+{% endif %}
  43
+
  44
+<h2>Option {% cycle options %}. Get the latest development version</h2>
29 45
 
30 46
 <p>The latest and greatest Django version is the one that's in our Git repository (our revision-control system). Get it using this shell command, which requires <a href="http://git-scm.com/">Git</a>:</p>
31 47
 

0 notes on commit 291fd57

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