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:
softwarefactory-project-zuul[bot] 2021-06-09 15:44:45 +00:00 committed by GitHub
commit 0a63c2d4a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -279,6 +279,7 @@ TEMPLATES = [
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'awx.ui.context_processors.csp',
'awx.ui.context_processors.version',
'social_django.context_processors.backends',
'social_django.context_processors.login_redirect',
],

View File

@ -1,6 +1,18 @@
import base64
import os
from awx.main.utils import get_awx_version
def csp(request):
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),
}