Remove vestigal django stuff for old ui

This commit is contained in:
Jake McDermott
2020-11-17 18:19:46 -05:00
parent f49e4a646f
commit 27219d34eb
11 changed files with 141 additions and 38 deletions

5
awx/ui/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
# Copyright (c) 2015 Ansible, Inc.
# All Rights Reserved.
default_app_config = 'awx.ui.apps.UIConfig'

10
awx/ui/apps.py Normal file
View File

@@ -0,0 +1,10 @@
# Django
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
class UIConfig(AppConfig):
name = 'awx.ui'
verbose_name = _('UI')

74
awx/ui/conf.py Normal file
View File

@@ -0,0 +1,74 @@
# Copyright (c) 2016 Ansible, Inc.
# All Rights Reserved.
# Django
from django.utils.translation import ugettext_lazy as _
# Tower
from awx.conf import register, fields
from awx.ui.fields import PendoTrackingStateField, CustomLogoField # noqa
register(
'PENDO_TRACKING_STATE',
field_class=PendoTrackingStateField,
choices=[
('off', _('Off')),
('anonymous', _('Anonymous')),
('detailed', _('Detailed')),
],
label=_('User Analytics Tracking State'),
help_text=_('Enable or Disable User Analytics Tracking.'),
category=_('UI'),
category_slug='ui',
)
register(
'CUSTOM_LOGIN_INFO',
field_class=fields.CharField,
allow_blank=True,
default='',
label=_('Custom Login Info'),
help_text=_('If needed, you can add specific information (such as a legal '
'notice or a disclaimer) to a text box in the login modal using '
'this setting. Any content added must be in plain text or an '
'HTML fragment, as other markup languages are not supported.'),
category=_('UI'),
category_slug='ui',
)
register(
'CUSTOM_LOGO',
field_class=CustomLogoField,
allow_blank=True,
default='',
label=_('Custom Logo'),
help_text=_('To set up a custom logo, provide a file that you create. For '
'the custom logo to look its best, use a .png file with a '
'transparent background. GIF, PNG and JPEG formats are supported.'),
placeholder='data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=',
category=_('UI'),
category_slug='ui',
)
register(
'MAX_UI_JOB_EVENTS',
field_class=fields.IntegerField,
min_value=100,
label=_('Max Job Events Retrieved by UI'),
help_text=_('Maximum number of job events for the UI to retrieve within a '
'single request.'),
category=_('UI'),
category_slug='ui',
)
register(
'UI_LIVE_UPDATES_ENABLED',
field_class=fields.BooleanField,
label=_('Enable Live Updates in the UI'),
help_text=_('If disabled, the page will not refresh when events are received. '
'Reloading the page will be required to get the latest details.'),
category=_('UI'),
category_slug='ui',
)

45
awx/ui/fields.py Normal file
View File

@@ -0,0 +1,45 @@
# Copyright (c) 2016 Ansible, Inc.
# All Rights Reserved.
# Python
import base64
import binascii
import re
# Django
from django.utils.translation import ugettext_lazy as _
# Tower
from awx.conf import fields, register
class PendoTrackingStateField(fields.ChoiceField):
def to_internal_value(self, data):
# Any false/null values get converted to 'off'.
if data in fields.NullBooleanField.FALSE_VALUES or data in fields.NullBooleanField.NULL_VALUES:
return 'off'
return super(PendoTrackingStateField, self).to_internal_value(data)
class CustomLogoField(fields.CharField):
CUSTOM_LOGO_RE = re.compile(r'^data:image/(?:png|jpeg|gif);base64,([A-Za-z0-9+/=]+?)$')
default_error_messages = {
'invalid_format': _('Invalid format for custom logo. Must be a data URL with a base64-encoded GIF, PNG or JPEG image.'),
'invalid_data': _('Invalid base64-encoded data in data URL.'),
}
def to_internal_value(self, data):
data = super(CustomLogoField, self).to_internal_value(data)
match = self.CUSTOM_LOGO_RE.match(data)
if not match:
self.fail('invalid_format')
b64data = match.group(1)
try:
base64.b64decode(b64data)
except (TypeError, binascii.Error):
self.fail('invalid_data')
return data