fix tuple

This commit is contained in:
bkfox 2020-05-29 13:28:36 +02:00
parent b87581552f
commit c04c1f3a53
7 changed files with 89 additions and 122 deletions

View File

@ -14,7 +14,7 @@ class DiffusionBaseAdmin:
def get_readonly_fields(self, request, obj=None):
fields = super().get_readonly_fields(request, obj)
if not request.user.has_perm('aircox_program.scheduling'):
fields += ['program', 'start', 'end']
fields += ('program', 'start', 'end')
return [field for field in fields if field in self.fields]

View File

@ -54,9 +54,6 @@ class LogQuerySet(models.QuerySet):
@staticmethod
def _get_archive_path(station, date):
# note: station name is not included in order to avoid problems
# of retrieving archive when it changes
return os.path.join(
settings.AIRCOX_LOGS_ARCHIVES_DIR,
'{}_{}.log.gz'.format(date.strftime("%Y%m%d"), station.pk)

View File

@ -17,10 +17,11 @@ def ensure(key, default):
ensure('AIRCOX_DEFAULT_USER_GROUPS', {
'radio hosts': (
'change_program', 'change_episode', 'change_diffusion',
'add_comment', 'change_comment', 'delete_comment',
'add_article', 'change_article', 'delete_article',
'change_sound',
'add_track', 'change_track', 'delete_track',
'add_tag', 'change_tag', 'delete_tag',
'add_comment', 'edit_comment', 'delete_comment',
),
})

View File

@ -11,7 +11,11 @@ LOGGING = {
},
},
'loggers': {
'aircox.core': {
'aircox': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
},
'aircox.commands': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
},
@ -19,10 +23,6 @@ LOGGING = {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
},
'aircox.tools': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
},
},
}

View File

@ -9,7 +9,11 @@ LOGGING = {
},
},
'loggers': {
'aircox.core': {
'aircox': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
'aircox.commands': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
@ -17,10 +21,6 @@ LOGGING = {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
'aircox.tools': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
},
}

View File

@ -1,65 +1,53 @@
"""
Sample file for the settings.py
Django and Aircox instance settings. This file should be saved as `settings.py`
in the same directory as this one.
First part of the file is where you should put your hand, second part is
just basic django initialization.
User MUST define the following values: `SECRET_KEY`, `ALLOWED_HOSTS`, `DATABASES`
Some variable retrieve environnement variable if they are defined:
* AIRCOX_DEBUG: enable/disable debugging
* TZ: timezone (default: 'Europe/Brussels')
* LANG: language code
Note that:
- SECRET_KEY
- ALLOWED_HOSTS
- DATABASES
are not defined in sample_settings and must be defined here.
You can also configure specific Aircox & Aircox CMS settings. For more
information, please report to these application's settings.py
The following environment variables are used in settings:
* `AIRCOX_DEBUG` (`DEBUG`): enable/disable debugging
For Django settings see:
https://docs.djangoproject.com/en/1.8/topics/settings/
https://docs.djangoproject.com/en/1.8/ref/settings/
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
sys.path.insert(1, os.path.dirname(os.path.realpath(__file__)))
# Project root directory
PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
SITE_MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media')
########################################################################
#
# You can configure starting from here
#
########################################################################
# set current language code. e.g. 'fr_BE'
LANGUAGE_CODE = 'en_US'
# locale
LC_LOCALE = 'en_US.UTF-8'
# set current timezone. e.g. 'Europe/Brussels'
TIME_ZONE = os.environ.get('TZ') or 'UTC'
# debug mode
# DEBUG mode
DEBUG = (os.environ['AIRCOX_DEBUG'].lower() in ('true', 1)) \
if 'AIRCOX_DEBUG' in os.environ else \
False
if DEBUG:
from .dev import *
# 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'
# Locale
LC_LOCALE = 'en_US.UTF-8'
# Current timezone. e.g. 'Europe/Brussels'
TIME_ZONE = os.environ.get('TZ') or 'UTC'
########################################################################
#
# You MUST configure those values
#
########################################################################
# Secret key: you MUST put a consistent secret key. You can generate one
# at https://djecrety.ir/
SECRET_KEY = ''
# Database configuration
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
@ -67,19 +55,38 @@ if DEBUG:
'TIMEZONE': TIME_ZONE,
}
}
# Allowed host for HTTP requests
ALLOWED_HOSTS = ('127.0.0.1',)
########################################################################
#
# You CAN configure starting from here
#
########################################################################
# Assets and medias:
# In production, user MUST configure webserver in order to serve static
# and media files.
# Website's path to statics assets
STATIC_URL = '/static/'
# Website's path to medias (uploaded images, etc.)
MEDIA_URL = '/media/'
# Website URL path to medias (uploaded images, etc.)
SITE_MEDIA_URL = '/media/'
# Path to assets' directory (by default in project's directory)
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')
# Include specific configuration depending of DEBUG
if DEBUG:
from .dev import *
else:
from .prod import *
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'aircox',
'USER': 'aircox',
'PASSWORD': '',
'HOST': 'localhost',
'TIMEZONE': TIME_ZONE,
},
}
# caching uses memcache
# Enable caching using memcache
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
@ -87,19 +94,13 @@ else:
}
}
# allowed hosts
ALLOWED_HOSTS = ('127.0.0.1',)
# secret key: you MUST put a consistent secret key
SECRET_KEY = ''
########################################################################
#
# You don't really need to configure what is happening below
#
########################################################################
# Internationalization and timezone
# Enables internationalization and timezone
USE_I18N = True
USE_L10N = True
USE_TZ = True
@ -118,7 +119,7 @@ except:
pass
#-- django-ckEditor
#-- django-CKEditor
CKEDITOR_CONFIGS = {
"default": {
"toolbar": "Custom",
@ -146,17 +147,15 @@ THUMBNAIL_PROCESSORS = (
)
# Application definition
# Enabled applications
INSTALLED_APPS = (
'aircox',
'aircox.apps.AircoxAdminConfig',
'aircox_streamer',
# aircox applications
# Aircox dependencies
'rest_framework',
'django_filters',
# aircox_web applications
"content_editor",
"ckeditor",
'easy_thumbnails',
@ -165,7 +164,7 @@ INSTALLED_APPS = (
'adminsortable2',
'honeypot',
# django
# Django
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.humanize',
@ -217,29 +216,3 @@ TEMPLATES = [
WSGI_APPLICATION = 'instance.wsgi.application'
# FIXME: what about dev & prod modules?
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'aircox': {
'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'),
},
},
}

View File

@ -15,6 +15,7 @@ Including another URLconf
"""
# from django.conf.urls.i18n import i18n_patterns
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
@ -25,17 +26,12 @@ import aircox_streamer.urls
try:
urlpatterns = aircox.urls.urls + [
path('admin/', admin.site.urls),
path('filer/', include('filer.urls')),
]
if settings.DEBUG:
from django.views.static import serve
urlpatterns.append(
re_path(r'^media/(?P<path>.*)$', serve,
{'document_root': settings.MEDIA_ROOT, 'show_indexes':True}
)
)
urlpatterns.append(path('filer/', include('filer.urls')))
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