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): def get_readonly_fields(self, request, obj=None):
fields = super().get_readonly_fields(request, obj) fields = super().get_readonly_fields(request, obj)
if not request.user.has_perm('aircox_program.scheduling'): 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] return [field for field in fields if field in self.fields]

View File

@ -54,9 +54,6 @@ class LogQuerySet(models.QuerySet):
@staticmethod @staticmethod
def _get_archive_path(station, date): 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( return os.path.join(
settings.AIRCOX_LOGS_ARCHIVES_DIR, settings.AIRCOX_LOGS_ARCHIVES_DIR,
'{}_{}.log.gz'.format(date.strftime("%Y%m%d"), station.pk) '{}_{}.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', { ensure('AIRCOX_DEFAULT_USER_GROUPS', {
'radio hosts': ( 'radio hosts': (
'change_program', 'change_episode', 'change_diffusion', 'change_program', 'change_episode', 'change_diffusion',
'add_comment', 'change_comment', 'delete_comment',
'add_article', 'change_article', 'delete_article',
'change_sound', 'change_sound',
'add_track', 'change_track', 'delete_track', 'add_track', 'change_track', 'delete_track',
'add_tag', 'change_tag', 'delete_tag', 'add_tag', 'change_tag', 'delete_tag',
'add_comment', 'edit_comment', 'delete_comment',
), ),
}) })

View File

@ -11,7 +11,11 @@ LOGGING = {
}, },
}, },
'loggers': { 'loggers': {
'aircox.core': { 'aircox': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
},
'aircox.commands': {
'handlers': ['console'], 'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'), 'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
}, },
@ -19,10 +23,6 @@ LOGGING = {
'handlers': ['console'], 'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'), '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': { 'loggers': {
'aircox.core': { 'aircox': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
'aircox.commands': {
'handlers': ['console'], 'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
}, },
@ -17,10 +21,6 @@ LOGGING = {
'handlers': ['console'], 'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
}, },
'aircox.tools': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
}, },
} }

View File

@ -1,85 +1,92 @@
""" """
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 User MUST define the following values: `SECRET_KEY`, `ALLOWED_HOSTS`, `DATABASES`
just basic django initialization.
The following environment variables are used in settings:
Some variable retrieve environnement variable if they are defined: * `AIRCOX_DEBUG` (`DEBUG`): enable/disable debugging
* 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
For Django settings see: For Django settings see:
https://docs.djangoproject.com/en/1.8/topics/settings/ https://docs.djangoproject.com/en/3.1/topics/settings/
https://docs.djangoproject.com/en/1.8/ref/settings/ https://docs.djangoproject.com/en/3.1/ref/settings/
""" """
import os import os
import sys import sys
import pytz import pytz
from django.utils import timezone from django.utils import timezone
sys.path.insert(1, os.path.dirname(os.path.realpath(__file__))) sys.path.insert(1, os.path.dirname(os.path.realpath(__file__)))
# Project root directory
PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__)) PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
STATIC_URL = '/static/' # DEBUG mode
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 = (os.environ['AIRCOX_DEBUG'].lower() in ('true', 1)) \ DEBUG = (os.environ['AIRCOX_DEBUG'].lower() in ('true', 1)) \
if 'AIRCOX_DEBUG' in os.environ else \ if 'AIRCOX_DEBUG' in os.environ else \
False 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'
# 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',
'NAME': os.path.join(PROJECT_ROOT, 'db.sqlite3'),
'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: if DEBUG:
from .dev import * from .dev import *
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_ROOT, 'db.sqlite3'),
'TIMEZONE': TIME_ZONE,
}
}
else: else:
from .prod import * from .prod import *
DATABASES = {
'default': { # Enable caching using memcache
'ENGINE': 'django.db.backends.mysql',
'NAME': 'aircox',
'USER': 'aircox',
'PASSWORD': '',
'HOST': 'localhost',
'TIMEZONE': TIME_ZONE,
},
}
# caching uses memcache
CACHES = { CACHES = {
'default': { 'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', '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 # You don't really need to configure what is happening below
# #
######################################################################## ########################################################################
# Internationalization and timezone # Enables internationalization and timezone
USE_I18N = True USE_I18N = True
USE_L10N = True USE_L10N = True
USE_TZ = True USE_TZ = True
@ -118,7 +119,7 @@ except:
pass pass
#-- django-ckEditor #-- django-CKEditor
CKEDITOR_CONFIGS = { CKEDITOR_CONFIGS = {
"default": { "default": {
"toolbar": "Custom", "toolbar": "Custom",
@ -146,17 +147,15 @@ THUMBNAIL_PROCESSORS = (
) )
# Application definition # Enabled applications
INSTALLED_APPS = ( INSTALLED_APPS = (
'aircox', 'aircox',
'aircox.apps.AircoxAdminConfig', 'aircox.apps.AircoxAdminConfig',
'aircox_streamer', 'aircox_streamer',
# aircox applications # Aircox dependencies
'rest_framework', 'rest_framework',
'django_filters', 'django_filters',
# aircox_web applications
"content_editor", "content_editor",
"ckeditor", "ckeditor",
'easy_thumbnails', 'easy_thumbnails',
@ -165,7 +164,7 @@ INSTALLED_APPS = (
'adminsortable2', 'adminsortable2',
'honeypot', 'honeypot',
# django # Django
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.humanize', 'django.contrib.humanize',
@ -217,29 +216,3 @@ TEMPLATES = [
WSGI_APPLICATION = 'instance.wsgi.application' 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.urls.i18n import i18n_patterns
from django.conf import settings from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.urls import include, path, re_path from django.urls import include, path, re_path
@ -25,17 +26,12 @@ import aircox_streamer.urls
try: try:
urlpatterns = aircox.urls.urls + [ urlpatterns = aircox.urls.urls + [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('filer/', include('filer.urls')),
] ]
if settings.DEBUG: if settings.DEBUG:
from django.views.static import serve urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + \
urlpatterns.append( static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
re_path(r'^media/(?P<path>.*)$', serve,
{'document_root': settings.MEDIA_ROOT, 'show_indexes':True}
)
)
urlpatterns.append(path('filer/', include('filer.urls')))
except Exception as e: except Exception as e:
import traceback import traceback