Added custom context to send git describe to templates
This commit is contained in:
parent
2f07391ade
commit
fcb52ada1e
|
@ -1,10 +1,13 @@
|
|||
from django.shortcuts import render_to_response
|
||||
from database.models import Version
|
||||
from django.core.paginator import Paginator
|
||||
from django.template import Context
|
||||
from django.template import RequestContext
|
||||
|
||||
|
||||
def home(request):
|
||||
return render_to_response('home.html')
|
||||
context = RequestContext(request)
|
||||
return render_to_response('home.html', context_instance=context)
|
||||
|
||||
|
||||
def versions(request):
|
||||
section = 'versions'
|
||||
|
@ -23,8 +26,11 @@ def versions(request):
|
|||
'page_number': page_number,
|
||||
'paginator': paginator,
|
||||
}
|
||||
context = RequestContext(request, data)
|
||||
|
||||
return render_to_response('versions.html', context_instance=context)
|
||||
|
||||
return render_to_response('versions.html', data)
|
||||
|
||||
def about(request):
|
||||
return render_to_response('about.html')
|
||||
context = RequestContext(request)
|
||||
return render_to_response('about.html', context_instance=context)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
from os import environ
|
||||
|
||||
|
||||
def AppVersionContext(request):
|
||||
result = {}
|
||||
if 'APP_VERSION' in environ:
|
||||
result = {
|
||||
'app_version': environ['APP_VERSION']
|
||||
}
|
||||
|
||||
return result
|
|
@ -1,4 +1,4 @@
|
|||
# Django settings for herobrine project.
|
||||
from django.conf import global_settings
|
||||
|
||||
DEBUG = False
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
@ -93,6 +93,10 @@ TEMPLATE_LOADERS = (
|
|||
# 'django.template.loaders.eggs.Loader',
|
||||
)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
|
||||
'herobrine.context.AppVersionContext',
|
||||
)
|
||||
|
||||
JINGO_INCLUDE_PATTERN = r'\.html'
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
|
|
Loading…
Reference in New Issue