Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Küng committed Jun 1, 2024
1 parent f910a45 commit bb1962b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 43 deletions.
13 changes: 0 additions & 13 deletions app/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,11 @@

LOGGER = logging.getLogger('munkiwebadmin')

try:
PROXY_ADDRESS = settings.PROXY_ADDRESS
except AttributeError:
PROXY_ADDRESS = ""

try:
TIMEOUT = settings.TIMEOUT
except AttributeError:
TIMEOUT = 20

proxies = {}
if PROXY_ADDRESS != "":
proxies = {
"http": 'http://'+PROXY_ADDRESS,
"https": 'https://'+PROXY_ADDRESS
}


def normalize_value_for_filtering(value):
'''Converts value to a list of strings'''
if isinstance(value, (int, float, bool, str, dict)):
Expand Down
27 changes: 13 additions & 14 deletions app/munkiwebadmin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,17 @@
APPNAME = os.getenv('APPNAME', 'MunkiWebAdmin')
MUNKI_REPO_DIR = os.getenv('MUNKI_REPO_DIR', '/munkirepo')
MAKECATALOGS_PATH = os.getenv('MAKECATALOGS_PATH', '/munkitools/makecatalogs')
MEDIA_ROOT = os.path.join(MUNKI_REPO_DIR, 'icons')
ICONS_URL = MEDIA_URL
PROXY_ADDRESS = os.getenv('PROXY_ADDRESS', '')
DEFAULT_MANIFEST = os.getenv('DEFAULT_MANIFEST')
MUNKISCRIPTS_PATH = os.path.join(BASE_DIR, 'munkiscripts', 'build')
FIELD_ENCRYPTION_KEY = os.environ.get('FIELD_ENCRYPTION_KEY', 'VDKEyIzST-hbtX7rvA7LPue63E0XB0m3pZEFWKk0BKI=')
DEFAULT_MANIFEST = os.getenv('DEFAULT_MANIFEST', 'serial_number')
REPO_MANAGEMENT_ONLY = os.getenv("REPO_MANAGEMENT_ONLY", 'False').lower() in ('true', '1', 't')
CLIENT_ID = os.getenv('CLIENT_ID', 'ID')
CLIENT_SECRET = os.getenv('CLIENT_SECRET', None)
TENANT_ID = os.getenv('TENANT_ID', None)

# enable git integration
if os.path.isdir(os.path.join(MUNKI_REPO_DIR, '.git')):
GIT_PATH = '/usr/bin/git'

SECRET_KEY = os.environ.get("SECRET_KEY", "CHANGEME!!!")
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "localhost 127.0.0.1 [::1]").split(" ")
CSRF_TRUSTED_ORIGINS = os.environ.get("CSRF_TRUSTED_ORIGINS", "http://localhost").split(" ")

# Azure AD settings
CLIENT_ID = os.getenv('CLIENT_ID', 'ID')
CLIENT_SECRET = os.getenv('CLIENT_SECRET', None)
TENANT_ID = os.getenv('TENANT_ID', None)

# Azure App Service
if os.environ.get('WEBSITE_HOSTNAME'):
ALLOWED_HOSTS.append(os.environ.get('WEBSITE_HOSTNAME'))
Expand All @@ -45,6 +37,13 @@
# debug mode
DEBUG = os.getenv("DEBUG", 'False').lower() in ('true', '1', 't')

#not changing this
MUNKISCRIPTS_PATH = os.path.join(BASE_DIR, 'munkiscripts', 'build')
MEDIA_ROOT = os.path.join(MUNKI_REPO_DIR, 'icons')
ICONS_URL = MEDIA_URL
if os.path.isdir(os.path.join(MUNKI_REPO_DIR, '.git')):
GIT_PATH = '/usr/bin/git'

# CORS settings
CORS_ORIGIN_ALLOW_ALL = DEBUG
CORS_ORIGIN_WHITELIST = ()
Expand Down
15 changes: 0 additions & 15 deletions app/reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@

LOGGER = logging.getLogger('munkiwebadmin')

try:
PROXY_ADDRESS = settings.PROXY_ADDRESS
except AttributeError:
PROXY_ADDRESS = ""

try:
DEFAULT_MANIFEST = settings.DEFAULT_MANIFEST
except AttributeError:
Expand All @@ -40,16 +35,6 @@
except AttributeError:
ICONS_URL = ""

proxies = {
"http": PROXY_ADDRESS,
"https": PROXY_ADDRESS
}

if PROXY_ADDRESS:
proxy = urllib.request.ProxyHandler(proxies)
opener = urllib.request.build_opener(proxy)
urllib.request.install_opener(opener)

def is_ajax(request):
return request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'

Expand Down
1 change: 0 additions & 1 deletion app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ django==4.2.11
psycopg2-binary==2.9.9
gunicorn==22.0.0
mysqlclient==2.2.4
django-encrypted-model-fields==0.6.5
python-ldap==3.4.3
django-auth-ldap==4.5.0
django-cors-headers==4.2.0
Expand Down

0 comments on commit bb1962b

Please sign in to comment.