Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added DocumentRelease object to manage doc versions instead of settings.

  • Loading branch information...
commit 5744132cd57c6843e2b0137f2696ef81e98b5b40 1 parent 39b0aaf
@jacobian jacobian authored
View
1  django_website/settings.py
@@ -50,6 +50,7 @@
'django.contrib.sitemaps',
'django_website.blog',
'django_website.aggregator',
+ 'djangodocs',
'registration',
)
View
9 djangodocs/admin.py
@@ -0,0 +1,9 @@
+from __future__ import absolute_import
+
+from django.contrib import admin
+from .models import DocumentRelease
+
+admin.site.register(DocumentRelease,
+ list_display = ['version', 'lang', 'scm_url', 'is_default'],
+ list_editable = ['is_default'],
+)
View
12 djangodocs/fixtures/initial_data.json
@@ -0,0 +1,12 @@
+[
+ {
+ "model": "djangodocs.documentrelease",
+ "pk": 1,
+ "fields": {
+ "lang": "en",
+ "version": "dev",
+ "scm_url": "http://code.djangoproject.com/svn/django/trunk/docs",
+ "is_default": false
+ }
+ }
+]
View
32 djangodocs/fixtures/releases.json
@@ -0,0 +1,32 @@
+[
+ {
+ "model": "djangodocs.documentrelease",
+ "pk": 2,
+ "fields": {
+ "lang": "en",
+ "version": "1.0",
+ "scm_url": "http://code.djangoproject.com/svn/django/branches/releases/1.0.X/docs",
+ "is_default": false
+ }
+ },
+ {
+ "model": "djangodocs.documentrelease",
+ "pk": 3,
+ "fields": {
+ "lang": "en",
+ "version": "1.1",
+ "scm_url": "http://code.djangoproject.com/svn/django/branches/releases/1.1.X/docs",
+ "is_default": false
+ }
+ },
+ {
+ "model": "djangodocs.documentrelease",
+ "pk": 4,
+ "fields": {
+ "lang": "en",
+ "version": "1.2",
+ "scm_url": "http://code.djangoproject.com/svn/django/trunk/docs",
+ "is_default": true
+ }
+ }
+]
View
0  djangodocs/management/__init__.py
No changes.
View
0  djangodocs/management/commands/__init__.py
No changes.
View
0  djangodocs/bin/update-docs.py → djangodocs/management/commands/update_docs.py
File renamed without changes
View
23 djangodocs/models.py
@@ -0,0 +1,23 @@
+from django.db import models
+from django.conf import settings
+
+class DocumentReleaseManager(models.Manager):
+ def default(self):
+ return DocumentRelease.objects.get(is_default=True)
+
+class DocumentRelease(models.Model):
+ lang = models.CharField(max_length=2, choices=settings.LANGUAGES, default='en')
+ version = models.CharField(max_length=20)
+ scm_url = models.URLField()
+ is_default = models.BooleanField()
+
+ objects = DocumentReleaseManager()
+
+ def __unicode__(self):
+ return "%s/%s" % (self.lang, self.version)
+
+ def save(self, *args, **kwargs):
+ # There can be only one. Default, that is.
+ if self.is_default:
+ DocumentRelease.objects.update(is_default=False)
+ super(DocumentRelease, self).save(*args, **kwargs)
View
2  manage-docs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python -Wall
import os
import sys
View
2  manage-www.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python -Wall
import os
import sys
Please sign in to comment.
Something went wrong with that request. Please try again.