mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Remove os usage in common (#3459)
* make sure STATIC_COLOR_THEMES_DIR resolves * remove usage of os module for file operations
This commit is contained in:
parent
ce8448467a
commit
9ca0d6b0a9
@ -127,7 +127,7 @@ STATFILES_I18_PROCESSORS = [
|
||||
]
|
||||
|
||||
# Color Themes Directory
|
||||
STATIC_COLOR_THEMES_DIR = STATIC_ROOT.joinpath('css', 'color-themes')
|
||||
STATIC_COLOR_THEMES_DIR = STATIC_ROOT.joinpath('css', 'color-themes').resolve()
|
||||
|
||||
# Web URL endpoint for served media files
|
||||
MEDIA_URL = '/media/'
|
||||
|
@ -10,7 +10,6 @@ import hmac
|
||||
import json
|
||||
import logging
|
||||
import math
|
||||
import os
|
||||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
from enum import Enum
|
||||
@ -1775,15 +1774,15 @@ class ColorTheme(models.Model):
|
||||
@classmethod
|
||||
def get_color_themes_choices(cls):
|
||||
"""Get all color themes from static folder."""
|
||||
if not os.path.exists(settings.STATIC_COLOR_THEMES_DIR):
|
||||
if not settings.STATIC_COLOR_THEMES_DIR.exists():
|
||||
logger.error('Theme directory does not exsist')
|
||||
return []
|
||||
|
||||
# Get files list from css/color-themes/ folder
|
||||
files_list = []
|
||||
|
||||
for file in os.listdir(settings.STATIC_COLOR_THEMES_DIR):
|
||||
files_list.append(os.path.splitext(file))
|
||||
for file in settings.STATIC_COLOR_THEMES_DIR.iterdir():
|
||||
files_list.append(file.stem)
|
||||
|
||||
# Get color themes choices (CSS sheets)
|
||||
choices = [(file_name.lower(), _(file_name.replace('-', ' ').title()))
|
||||
|
Loading…
Reference in New Issue
Block a user