Ticket #12699: stableversion.diff

File stableversion.diff, 2.2 KB (added by claudep, 5 years ago)

Handle a 'stable' version in djangodocs

  • djangodocs/views.py

     
    1212    return HttpResponseRedirect(
    1313        urlresolvers.reverse('document-index', kwargs={
    1414            'lang': 'en',
    15             'version': '1.1',
     15            'version': settings.STABLE_VERSION,
    1616        })
    1717    )
    1818   
     
    2020    return HttpResponseRedirect(
    2121        urlresolvers.reverse('document-index', kwargs={
    2222            'lang': lang,
    23             'version': '1.1',
     23            'version': settings.STABLE_VERSION,
    2424        })
    2525    )
    2626
     27def check_version(version):
     28    return version == 'stable' and settings.STABLE_VERSION or version
     29
    2730def get_docroot(lang, version):
    28     docroot = Path(settings.DOCS_PICKLE_ROOT).child(lang, version, "_build", "json")
     31    docroot = Path(settings.DOCS_PICKLE_ROOT).child(lang, check_version(version), "_build", "json")
    2932    if not docroot.exists():
    3033        raise Http404()
    3134    return docroot
    3235
    3336def document(request, lang, version, url):
     37    version = check_version(version)
    3438    docroot = get_docroot(lang, version)
    3539   
    3640    # First look for <bits>/index.fpickle, then for <bits>.fpickle
     
    8690    return response
    8791
    8892def search(request, lang, version):
     93    version = check_version(version)
    8994    docroot = get_docroot(lang, version)
    9095   
    9196    # Remove the 'cof' GET variable from the query string so that the page
     
    102107        'env': simplejson.load(open(docroot.child('globalcontext.json'), 'rb')),
    103108        'home': urlresolvers.reverse('document-index', kwargs={'lang':lang, 'version':version}),
    104109        'search': urlresolvers.reverse('document-search', kwargs={'lang':lang, 'version':version}),
    105     }))
    106  No newline at end of file
     110    }))
  • djangodocs/settings.py

     
    88ROOT_URLCONF = 'djangodocs.urls'
    99CACHE_MIDDLEWARE_KEY_PREFIX = 'djangodocs'
    1010
    11 DOCS_PICKLE_ROOT = "/home/djangodocs/"
    12  No newline at end of file
     11STABLE_VERSION = "1.1"
     12DOCS_PICKLE_ROOT = "/home/djangodocs/"
Back to Top