mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Merge pull request #10385 from mabashian/version_context_processor
Adds version context processor back in to fix api browser doc link SUMMARY Here's what it looks like on devel now (note the URL in the bottom left): Here's what it looks like after the change (note the URL in the bottom left): I dropped this in as it was before the removal of the old UI. I believe the new UI needs access to some of these variables as well to force assets to be refetched after upgrade. Also of note: I have no idea what I'm doing with django so please help me to become educated if I've done something silly here. ISSUE TYPE Bugfix Pull Request COMPONENT NAME API Reviewed-by: Jake McDermott <yo@jakemcdermott.me>
This commit is contained in:
@@ -279,6 +279,7 @@ TEMPLATES = [
|
|||||||
'django.template.context_processors.tz',
|
'django.template.context_processors.tz',
|
||||||
'django.contrib.messages.context_processors.messages',
|
'django.contrib.messages.context_processors.messages',
|
||||||
'awx.ui.context_processors.csp',
|
'awx.ui.context_processors.csp',
|
||||||
|
'awx.ui.context_processors.version',
|
||||||
'social_django.context_processors.backends',
|
'social_django.context_processors.backends',
|
||||||
'social_django.context_processors.login_redirect',
|
'social_django.context_processors.login_redirect',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from awx.main.utils import get_awx_version
|
||||||
|
|
||||||
|
|
||||||
def csp(request):
|
def csp(request):
|
||||||
return {'csp_nonce': base64.encodebytes(os.urandom(32)).decode().rstrip()}
|
return {'csp_nonce': base64.encodebytes(os.urandom(32)).decode().rstrip()}
|
||||||
|
|
||||||
|
|
||||||
|
def version(request):
|
||||||
|
context = getattr(request, 'parser_context', {})
|
||||||
|
return {
|
||||||
|
'version': get_awx_version(),
|
||||||
|
'tower_version': get_awx_version(),
|
||||||
|
'short_tower_version': get_awx_version().split('-')[0],
|
||||||
|
'deprecated': getattr(context.get('view'), 'deprecated', False),
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user