code quality
This commit is contained in:
@ -1,36 +1,34 @@
|
||||
import os
|
||||
|
||||
LOCALE_PATHS = ['aircox/locale', 'aircox_streamer/locale']
|
||||
LOCALE_PATHS = ["aircox/locale", "aircox_streamer/locale"]
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'timestamp': {
|
||||
'format': '{asctime} {levelname} {message}',
|
||||
'style': '{',
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"formatters": {
|
||||
"timestamp": {
|
||||
"format": "{asctime} {levelname} {message}",
|
||||
"style": "{",
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'console': {
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'timestamp',
|
||||
"handlers": {
|
||||
"console": {
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "timestamp",
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'aircox': {
|
||||
'handlers': ['console'],
|
||||
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
|
||||
"loggers": {
|
||||
"aircox": {
|
||||
"handlers": ["console"],
|
||||
"level": os.getenv("DJANGO_LOG_LEVEL", "DEBUG"),
|
||||
},
|
||||
'aircox.commands': {
|
||||
'handlers': ['console'],
|
||||
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
|
||||
"aircox.commands": {
|
||||
"handlers": ["console"],
|
||||
"level": os.getenv("DJANGO_LOG_LEVEL", "DEBUG"),
|
||||
},
|
||||
'aircox.test': {
|
||||
'handlers': ['console'],
|
||||
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
|
||||
"aircox.test": {
|
||||
"handlers": ["console"],
|
||||
"level": os.getenv("DJANGO_LOG_LEVEL", "DEBUG"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,35 +1,32 @@
|
||||
import os
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'timestamp': {
|
||||
'format': '{asctime} {levelname} {message}',
|
||||
'style': '{',
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"formatters": {
|
||||
"timestamp": {
|
||||
"format": "{asctime} {levelname} {message}",
|
||||
"style": "{",
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'console': {
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'timestamp',
|
||||
"handlers": {
|
||||
"console": {
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "timestamp",
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'aircox': {
|
||||
'handlers': ['console'],
|
||||
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
|
||||
"loggers": {
|
||||
"aircox": {
|
||||
"handlers": ["console"],
|
||||
"level": os.getenv("DJANGO_LOG_LEVEL", "INFO"),
|
||||
},
|
||||
'aircox.commands': {
|
||||
'handlers': ['console'],
|
||||
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
|
||||
"aircox.commands": {
|
||||
"handlers": ["console"],
|
||||
"level": os.getenv("DJANGO_LOG_LEVEL", "INFO"),
|
||||
},
|
||||
'aircox.test': {
|
||||
'handlers': ['console'],
|
||||
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
|
||||
"aircox.test": {
|
||||
"handlers": ["console"],
|
||||
"level": os.getenv("DJANGO_LOG_LEVEL", "INFO"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
"""
|
||||
Django and Aircox instance settings. This file should be saved as `settings.py`
|
||||
in the same directory as this one.
|
||||
"""Django and Aircox instance settings. This file should be saved as
|
||||
`settings.py` in the same directory as this one.
|
||||
|
||||
User MUST define the following values: `SECRET_KEY`, `ALLOWED_HOSTS`, `DATABASES`
|
||||
|
||||
@ -10,10 +9,10 @@ The following environment variables are used in settings:
|
||||
For Django settings see:
|
||||
https://docs.djangoproject.com/en/3.1/topics/settings/
|
||||
https://docs.djangoproject.com/en/3.1/ref/settings/
|
||||
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytz
|
||||
from django.utils import timezone
|
||||
|
||||
@ -22,19 +21,21 @@ sys.path.insert(1, os.path.dirname(os.path.realpath(__file__)))
|
||||
# Project root directory
|
||||
PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
|
||||
# DEBUG mode
|
||||
DEBUG = (os.environ['AIRCOX_DEBUG'].lower() in ('true', 1)) \
|
||||
if 'AIRCOX_DEBUG' in os.environ else \
|
||||
False
|
||||
DEBUG = (
|
||||
(os.environ["AIRCOX_DEBUG"].lower() in ("true", 1))
|
||||
if "AIRCOX_DEBUG" in os.environ
|
||||
else False
|
||||
)
|
||||
|
||||
# Internationalization and timezones: thoses values may be set in order to
|
||||
# have correct translation and timezone.
|
||||
|
||||
# Current language code. e.g. 'fr_BE'
|
||||
LANGUAGE_CODE = 'en-US'
|
||||
LANGUAGE_CODE = "en-US"
|
||||
# Locale
|
||||
LC_LOCALE = 'en_US.UTF-8'
|
||||
LC_LOCALE = "en_US.UTF-8"
|
||||
# Current timezone. e.g. 'Europe/Brussels'
|
||||
TIME_ZONE = os.environ.get('TZ') or 'UTC'
|
||||
TIME_ZONE = os.environ.get("TZ") or "UTC"
|
||||
|
||||
|
||||
########################################################################
|
||||
@ -45,19 +46,19 @@ TIME_ZONE = os.environ.get('TZ') or 'UTC'
|
||||
|
||||
# Secret key: you MUST put a consistent secret key. You can generate one
|
||||
# at https://djecrety.ir/
|
||||
SECRET_KEY = ''
|
||||
SECRET_KEY = ""
|
||||
|
||||
# Database configuration
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(PROJECT_ROOT, 'db.sqlite3'),
|
||||
'TIMEZONE': TIME_ZONE,
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": os.path.join(PROJECT_ROOT, "db.sqlite3"),
|
||||
"TIMEZONE": TIME_ZONE,
|
||||
}
|
||||
}
|
||||
|
||||
# Allowed host for HTTP requests
|
||||
ALLOWED_HOSTS = ('127.0.0.1',)
|
||||
ALLOWED_HOSTS = ("127.0.0.1",)
|
||||
|
||||
########################################################################
|
||||
#
|
||||
@ -70,15 +71,15 @@ ALLOWED_HOSTS = ('127.0.0.1',)
|
||||
# and media files.
|
||||
|
||||
# Website's path to statics assets
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_URL = "/static/"
|
||||
# Website's path to medias (uploaded images, etc.)
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_URL = "/media/"
|
||||
# Website URL path to medias (uploaded images, etc.)
|
||||
SITE_MEDIA_URL = '/media/'
|
||||
SITE_MEDIA_URL = "/media/"
|
||||
# Path to assets' directory (by default in project's directory)
|
||||
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
|
||||
STATIC_ROOT = os.path.join(PROJECT_ROOT, "static")
|
||||
# Path to media directory (by default in static's directory)
|
||||
MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media')
|
||||
MEDIA_ROOT = os.path.join(STATIC_ROOT, "media")
|
||||
|
||||
# Include specific configuration depending of DEBUG
|
||||
if DEBUG:
|
||||
@ -88,9 +89,9 @@ else:
|
||||
|
||||
# Enable caching using memcache
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
'LOCATION': '127.0.0.1:11211',
|
||||
"default": {
|
||||
"BACKEND": "django.core.cache.backends.memcached.MemcachedCache",
|
||||
"LOCATION": "127.0.0.1:11211",
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,118 +110,172 @@ timezone.activate(pytz.timezone(TIME_ZONE))
|
||||
|
||||
try:
|
||||
import locale
|
||||
|
||||
locale.setlocale(locale.LC_ALL, LC_LOCALE)
|
||||
except:
|
||||
print(
|
||||
'Can not set locale {LC}. Is it available on you system? Hint: '
|
||||
'Check /etc/locale.gen and rerun locale-gen as sudo if needed.'
|
||||
.format(LC = LANGUAGE_CODE)
|
||||
"Can not set locale {LC}. Is it available on you system? Hint: "
|
||||
"Check /etc/locale.gen and rerun locale-gen as sudo if needed.".format(
|
||||
LC=LANGUAGE_CODE
|
||||
)
|
||||
)
|
||||
pass
|
||||
|
||||
#-- django-taggit
|
||||
# -- django-taggit
|
||||
TAGGIT_CASE_INSENSITIVE = True
|
||||
|
||||
#-- django-CKEditor
|
||||
# -- django-CKEditor
|
||||
CKEDITOR_CONFIGS = {
|
||||
"default": {
|
||||
"format_tags": "h1;h2;h3;p;pre",
|
||||
# 'skin': 'office2013',
|
||||
"toolbar_Custom": [
|
||||
{'name': 'editing', 'items': ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'Source']},
|
||||
{'name': 'basicstyles',
|
||||
'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']},
|
||||
{'name': 'paragraph',
|
||||
'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-',
|
||||
'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-']},
|
||||
'/',
|
||||
{'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']},
|
||||
{'name': 'insert',
|
||||
'items': ['Image', 'Table', 'HorizontalRule', 'SpecialChar', 'PageBreak', 'Iframe']},
|
||||
{'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']},
|
||||
{'name': 'colors', 'items': ['TextColor', 'BGColor']},
|
||||
'/', # put this to force next toolbar on new line
|
||||
{
|
||||
"name": "editing",
|
||||
"items": [
|
||||
"Undo",
|
||||
"Redo",
|
||||
"-",
|
||||
"Find",
|
||||
"Replace",
|
||||
"-",
|
||||
"Source",
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "basicstyles",
|
||||
"items": [
|
||||
"Bold",
|
||||
"Italic",
|
||||
"Underline",
|
||||
"Strike",
|
||||
"Subscript",
|
||||
"Superscript",
|
||||
"-",
|
||||
"RemoveFormat",
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "paragraph",
|
||||
"items": [
|
||||
"NumberedList",
|
||||
"BulletedList",
|
||||
"-",
|
||||
"Outdent",
|
||||
"Indent",
|
||||
"-",
|
||||
"Blockquote",
|
||||
"CreateDiv",
|
||||
"-",
|
||||
"JustifyLeft",
|
||||
"JustifyCenter",
|
||||
"JustifyRight",
|
||||
"JustifyBlock",
|
||||
"-",
|
||||
],
|
||||
},
|
||||
"/",
|
||||
{"name": "links", "items": ["Link", "Unlink", "Anchor"]},
|
||||
{
|
||||
"name": "insert",
|
||||
"items": [
|
||||
"Image",
|
||||
"Table",
|
||||
"HorizontalRule",
|
||||
"SpecialChar",
|
||||
"PageBreak",
|
||||
"Iframe",
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "styles",
|
||||
"items": ["Styles", "Format", "Font", "FontSize"],
|
||||
},
|
||||
{"name": "colors", "items": ["TextColor", "BGColor"]},
|
||||
"/", # put this to force next toolbar on new line
|
||||
],
|
||||
'toolbar': 'Custom',
|
||||
'extraPlugins': ','.join([
|
||||
'uploadimage',
|
||||
'div',
|
||||
'autolink',
|
||||
'autoembed', 'embedsemantic', 'embed',
|
||||
'iframe', 'iframedialog',
|
||||
'autogrow',
|
||||
'widget',
|
||||
'lineutils',
|
||||
'dialog',
|
||||
'dialogui',
|
||||
'elementspath'
|
||||
]),
|
||||
"toolbar": "Custom",
|
||||
"extraPlugins": ",".join(
|
||||
[
|
||||
"uploadimage",
|
||||
"div",
|
||||
"autolink",
|
||||
"autoembed",
|
||||
"embedsemantic",
|
||||
"embed",
|
||||
"iframe",
|
||||
"iframedialog",
|
||||
"autogrow",
|
||||
"widget",
|
||||
"lineutils",
|
||||
"dialog",
|
||||
"dialogui",
|
||||
"elementspath",
|
||||
]
|
||||
),
|
||||
},
|
||||
}
|
||||
CKEDITOR_UPLOAD_PATH = 'uploads/'
|
||||
CKEDITOR_UPLOAD_PATH = "uploads/"
|
||||
|
||||
|
||||
#-- easy_thumbnails
|
||||
# -- easy_thumbnails
|
||||
THUMBNAIL_PROCESSORS = (
|
||||
'easy_thumbnails.processors.colorspace',
|
||||
'easy_thumbnails.processors.autocrop',
|
||||
"easy_thumbnails.processors.colorspace",
|
||||
"easy_thumbnails.processors.autocrop",
|
||||
#'easy_thumbnails.processors.scale_and_crop',
|
||||
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
|
||||
'easy_thumbnails.processors.filters',
|
||||
"filer.thumbnail_processors.scale_and_crop_with_subject_location",
|
||||
"easy_thumbnails.processors.filters",
|
||||
)
|
||||
|
||||
|
||||
# Enabled applications
|
||||
INSTALLED_APPS = (
|
||||
'aircox.apps.AircoxConfig',
|
||||
'aircox.apps.AircoxAdminConfig',
|
||||
'aircox_streamer.apps.AircoxStreamerConfig',
|
||||
|
||||
"aircox.apps.AircoxConfig",
|
||||
"aircox.apps.AircoxAdminConfig",
|
||||
"aircox_streamer.apps.AircoxStreamerConfig",
|
||||
# Aircox dependencies
|
||||
'rest_framework',
|
||||
'django_filters',
|
||||
"rest_framework",
|
||||
"django_filters",
|
||||
"content_editor",
|
||||
"ckeditor",
|
||||
"ckeditor_uploader",
|
||||
'easy_thumbnails',
|
||||
'filer',
|
||||
'taggit',
|
||||
'adminsortable2',
|
||||
'honeypot',
|
||||
|
||||
"easy_thumbnails",
|
||||
"filer",
|
||||
"taggit",
|
||||
"adminsortable2",
|
||||
"honeypot",
|
||||
# Django
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.humanize',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.humanize",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
)
|
||||
|
||||
MIDDLEWARE = (
|
||||
'django.middleware.gzip.GZipMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
|
||||
'aircox.middleware.AircoxMiddleware'
|
||||
"django.middleware.gzip.GZipMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.locale.LocaleMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"aircox.middleware.AircoxMiddleware",
|
||||
)
|
||||
|
||||
|
||||
ROOT_URLCONF = 'instance.urls'
|
||||
ROOT_URLCONF = "instance.urls"
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': (os.path.join(PROJECT_ROOT, 'templates'),),
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": (os.path.join(PROJECT_ROOT, "templates"),),
|
||||
# 'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': (
|
||||
"OPTIONS": {
|
||||
"context_processors": (
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.template.context_processors.debug",
|
||||
"django.template.context_processors.i18n",
|
||||
@ -230,14 +285,13 @@ TEMPLATES = [
|
||||
"django.template.context_processors.tz",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
),
|
||||
'loaders': (
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
"loaders": (
|
||||
"django.template.loaders.filesystem.Loader",
|
||||
"django.template.loaders.app_directories.Loader",
|
||||
),
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
WSGI_APPLICATION = 'instance.wsgi.application'
|
||||
|
||||
WSGI_APPLICATION = "instance.wsgi.application"
|
||||
|
@ -1,4 +1,4 @@
|
||||
"""aircox URL Configuration
|
||||
"""Aircox URL Configuration.
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/1.8/topics/http/urls/
|
||||
@ -17,24 +17,17 @@ Including another URLconf
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path, re_path
|
||||
from django.urls import include, path
|
||||
|
||||
import aircox.urls
|
||||
import aircox_streamer.urls
|
||||
|
||||
urlpatterns = aircox.urls.urls + [
|
||||
path("admin/", admin.site.urls),
|
||||
path("ckeditor/", include("ckeditor_uploader.urls")),
|
||||
path("filer/", include("filer.urls")),
|
||||
]
|
||||
|
||||
try:
|
||||
urlpatterns = aircox.urls.urls + [
|
||||
path('admin/', admin.site.urls),
|
||||
path('ckeditor/', include('ckeditor_uploader.urls')),
|
||||
path('filer/', include('filer.urls')),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + \
|
||||
static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
except Exception as e:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(
|
||||
settings.STATIC_URL, document_root=settings.STATIC_ROOT
|
||||
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
@ -1,5 +1,4 @@
|
||||
"""
|
||||
WSGI config for aircox project.
|
||||
"""WSGI config for aircox project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
@ -13,4 +12,3 @@ from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "instance.settings")
|
||||
application = get_wsgi_application()
|
||||
|
||||
|
Reference in New Issue
Block a user