Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'justinlilly/12699_doc_versioning' into …

…community_redux
  • Loading branch information...
commit eaffd658d13fb3861e61e9f807032c09cb44e6c0 2 parents 8b182ef + 7f24d72
@jacobian jacobian authored
View
15 django_website/context_processors.py
@@ -0,0 +1,15 @@
+from django.conf import settings
+from django.core.cache import cache
+
+from django_website.docs.models import DocumentRelease
+
+def recent_release(request):
+ recent_release = cache.get('recent_release')
+ if not recent_release:
+ recent_release = DocumentRelease.objects.default().version
+ cache.set(
+ DocumentRelease.DEFAULT_CACHE_KEY,
+ recent_release,
+ settings.CACHE_MIDDLEWARE_SECONDS,
+ )
+ return {'RECENT_RELEASE': recent_release}
View
7 django_website/docs/models.py
@@ -1,5 +1,6 @@
from django.db import models
from django.conf import settings
+from django.core.cache import cache
class DocumentReleaseManager(models.Manager):
def default(self):
@@ -9,6 +10,7 @@ class DocumentRelease(models.Model):
"""
A "release" of documentation -- i.e. English for v1.2.
"""
+ DEFAULT_CACHE_KEY = "%s_recent_release" % settings.CACHE_MIDDLEWARE_KEY_PREFIX
SVN = 'svn'
SCM_CHOICES = (
(SVN, 'SVN'),
@@ -33,6 +35,11 @@ def save(self, *args, **kwargs):
# There can be only one. Default, that is.
if self.is_default:
DocumentRelease.objects.update(is_default=False)
+ cache.set(
+ self.DEFAULT_CACHE_KEY,
+ self.version,
+ settings.CACHE_MIDDLEWARE_SECONDS,
+ )
super(DocumentRelease, self).save(*args, **kwargs)
@property
View
1  django_website/settings/www.py
@@ -88,6 +88,7 @@
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
+ "django_website.context_processors.recent_release",
]
View
2  django_website/templates/base_community.html
@@ -48,7 +48,7 @@
<h2>Get help</h2>
<ul>
-<li><strong><a href="http://docs.djangoproject.com/en/dev/faq/">Check our FAQ</a> first</strong>. If you have a basic question that's not answered by the FAQ, <a href="http://code.djangoproject.com/simpleticket">file a ticket</a> to tell us you think it should be in there.</li>
+<li><strong><a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/faq/">Check our FAQ</a> first</strong>. If you have a basic question that's not answered by the FAQ, <a href="http://code.djangoproject.com/simpleticket">file a ticket</a> to tell us you think it should be in there.</li>
<li><strong>Chat live with other Django users</strong> in the <a href="irc://irc.freenode.net/django">#django IRC channel on irc.freenode.net</a>.</li>
<li><strong>Ask questions</strong> on the <a href="http://groups-beta.google.com/group/django-users">django-users mailing list</a>.</li>
</ul>
View
20 django_website/templates/homepage.html
@@ -11,22 +11,22 @@
<h2 class="deck">Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.</h2>
<p>Developed four years ago by a fast-moving online-news operation, Django was designed to handle two challenges: the intensive deadlines of a newsroom and the stringent requirements of the experienced Web developers who wrote it. It lets you build high-performing, elegant Web applications quickly.</p>
<p>Django focuses on automating as much as possible and adhering to the <a href="http://c2.com/cgi/wiki?DontRepeatYourself"><abbr title="Don't Repeat Yourself">DRY</abbr> principle</a>.</p>
-<p>Dive in by <a href="http://docs.djangoproject.com/en/dev/intro/overview/">reading the overview &rarr;</a></p>
-<p>When you're ready to code, read the <a href="http://docs.djangoproject.com/en/dev/intro/install/">installation guide</a> and <a href="http://docs.djangoproject.com/en/dev/intro/tutorial01/">tutorial</a>.</p>
+<p>Dive in by <a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/intro/overview/">reading the overview &rarr;</a></p>
+<p>When you're ready to code, read the <a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/intro/install/">installation guide</a> and <a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/intro/tutorial01/">tutorial</a>.</p>
<div id="content-secondary">
<h2>The Django framework</h2>
<h3>Object-relational mapper</h3>
- <p>Define your <a href="http://docs.djangoproject.com/en/dev/topics/db/models/">data models</a> entirely in Python. You get a rich, <a href="http://docs.djangoproject.com/en/dev/topics/db/queries/">dynamic database-access API</a> for free &mdash; but you can still write SQL if needed.</p>
+ <p>Define your <a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/topics/db/models/">data models</a> entirely in Python. You get a rich, <a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/topics/db/queries/">dynamic database-access API</a> for free &mdash; but you can still write SQL if needed.</p>
<h3>Automatic admin interface</h3>
- <p>Save yourself the tedious work of creating interfaces for people to add and update content. <a href="http://docs.djangoproject.com/en/dev/intro/tutorial02/">Django does that automatically</a>, and it's production-ready.</p>
+ <p>Save yourself the tedious work of creating interfaces for people to add and update content. <a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/intro/tutorial02/">Django does that automatically</a>, and it's production-ready.</p>
<h3>Elegant URL design</h3>
- <p>Design pretty, <a href="http://docs.djangoproject.com/en/dev/topics/http/urls/">cruft-free URLs</a> with no framework-specific limitations. Be as flexible as you like.</p>
+ <p>Design pretty, <a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/topics/http/urls/">cruft-free URLs</a> with no framework-specific limitations. Be as flexible as you like.</p>
<h3>Template system</h3>
- <p>Use Django's powerful, extensible and designer-friendly <a href="http://docs.djangoproject.com/en/dev/topics/templates/">template language</a> to separate design, content and Python code.</p>
+ <p>Use Django's powerful, extensible and designer-friendly <a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/topics/templates/">template language</a> to separate design, content and Python code.</p>
<h3>Cache system</h3>
- <p>Hook into memcached or other cache frameworks for <a href="http://docs.djangoproject.com/en/dev/topics/cache/">super performance</a> &mdash; caching is as granular as you need.</p>
+ <p>Hook into memcached or other cache frameworks for <a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/topics/cache/">super performance</a> &mdash; caching is as granular as you need.</p>
<h3>Internationalization</h3>
- <p>Django has full support for <a href="http://docs.djangoproject.com/en/dev/topics/i18n/">multi-language applications</a>, letting you specify translation strings and providing hooks for language-specific functionality.</p>
+ <p>Django has full support for <a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/topics/i18n/">multi-language applications</a>, letting you specify translation strings and providing hooks for language-specific functionality.</p>
</div>
<!-- END #content-secondary -->
{% endblock %}
@@ -40,8 +40,8 @@ <h2 class="deck">Django is a high-level Python Web framework that encourages rap
<p>Open source, <a href="http://code.djangoproject.com/browser/django/trunk/LICENSE">BSD license</a></p>
<h2>Documentation</h2>
<ul class="linklist">
- <li><a href="http://docs.djangoproject.com/en/dev/intro/install/">Installation guide</a></li>
- <li><a href="http://docs.djangoproject.com/en/dev/intro/tutorial01/">Tutorial</a></li>
+ <li><a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/intro/install/">Installation guide</a></li>
+ <li><a href="http://docs.djangoproject.com/en/{{ RECENT_RELEASE }}/intro/tutorial01/">Tutorial</a></li>
<li><a href="http://docs.djangoproject.com/">Full index...</a></li>
</ul>
<h2>Sites that use Django</h2>
Please sign in to comment.
Something went wrong with that request. Please try again.