Core

Apps

class ycms.core.apps.CoreConfig(app_name, app_module)

Bases: AppConfig

This class represents the Django-configuration of the backend.

See django.apps.AppConfig for more information.

Parameters:

name (str) – The name of the app

name = 'ycms.core'
verbose_name = 'Core'

Circleci Settings

Django settings for our CircleCI workflow. All configurations are imported from settings. For more information on this file, see Django settings. For the full list of settings and their values, see Settings.

ycms.core.circleci_settings.SECRET_KEY = 'dummy'

Set a dummy secret key for CircleCI build even if it’s not in debug mode

Docker Settings

Django settings for different database configuration. The docker container started in https://github.com/charludo/ycms/blob/develop/tools/run.sh exposes the alternative port 5434.

All other settings are imported from settings.

For more information on this file, see Django settings. For the full list of settings and their values, see Settings.

ycms.core.docker_settings.DATABASES = {'default': {'ENGINE': 'django.db.backends.postgresql', 'HOST': 'localhost', 'NAME': 'ycms', 'PASSWORD': 'password', 'PORT': '5434', 'USER': 'ycms'}}

A dictionary containing the settings for all databases to be used with this Django installation (see DATABASES)

{
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'HOST': 'localhost',
        'NAME': 'ycms',
        'PASSWORD': 'password',
        'PORT': '5434',
        'USER': 'ycms',
    },
}

Logging Formatter

class ycms.core.logging_formatter.ColorFormatter(fmt=None, datefmt=None, style='%', validate=True)

Bases: Formatter

Logging Formatter to add colors

COLORS = {10: 36, 20: 34, 30: 33, 40: 31, 50: 31}
format(record)

Format the specified record as colored text (see logging.Formatter.format()).

Parameters:

record (LogRecord) – The log record

Returns:

The formatted logging message

Return type:

str

class ycms.core.logging_formatter.RequestFormatter(fmt=None, datefmt=None, style='%', validate=True)

Bases: Formatter

Logging Formatter to log the GET parameters of a failed HTTP request

format(record)

Format the specified record including the request if possible (see logging.Formatter.format()).

Parameters:

record (LogRecord) – The log record

Returns:

The formatted logging message

Return type:

str

Settings

Django settings for ycms project.

Generated by ‘django-admin startproject’ using Django 4.1.2.

For more information on this file, see https://docs.djangoproject.com/en/4.1/topics/settings/

For the full list of settings and their values, see https://docs.djangoproject.com/en/4.1/ref/settings/

ycms.core.settings.ADMINS = [('YCMS Helpdesk', 'tech@ycms.de')]

A list of all the people who get code error notifications. When DEBUG is False, Django emails these people the details of exceptions raised in the request/response cycle.

[('YCMS Helpdesk', 'tech@ycms.de')]
ycms.core.settings.ALLOWED_HOSTS = ['.localhost', '127.0.0.1', '[::1]', 'localhost']

This is a security measure to prevent HTTP Host header attacks, which are possible even under many seemingly-safe

['.localhost', '127.0.0.1', '[::1]', 'localhost']
ycms.core.settings.AVAILABLE_LANGUAGES = {'de': 'German', 'en': 'English'}

A list of all available languages with locale files for translated strings

{'de': 'German', 'en': 'English'}
ycms.core.settings.DATABASES = {'default': {'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_HEALTH_CHECKS': False, 'CONN_MAX_AGE': 0, 'ENGINE': 'django.db.backends.postgresql', 'HOST': 'localhost', 'NAME': 'ycms', 'OPTIONS': {}, 'PASSWORD': '', 'PORT': '5432', 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIGRATE': True, 'MIRROR': None, 'NAME': None}, 'TIME_ZONE': None, 'USER': 'ycms'}}

A dictionary containing the settings for all databases to be used with this Django installation (see DATABASES)

{
    'default': {
        'ATOMIC_REQUESTS': False,
        'AUTOCOMMIT': True,
        'CONN_HEALTH_CHECKS': False,
        'CONN_MAX_AGE': 0,
        'ENGINE': 'django.db.backends.postgresql',
        'HOST': 'localhost',
        'NAME': 'ycms',
        'OPTIONS': {},
        'PASSWORD': '',
        'PORT': '5432',
        'TEST': {
            'CHARSET': None,
            'COLLATION': None,
            'MIGRATE': True,
            'MIRROR': None,
            'NAME': None,
        },
        'TIME_ZONE': None,
        'USER': 'ycms',
    },
}
ycms.core.settings.DEFAULT_FROM_EMAIL = 'noreply@example.com'

Default email address to use for various automated correspondence from the site manager(s) (see DEFAULT_FROM_EMAIL)

ycms.core.settings.DEFAULT_LANGUAGES = ['de', 'en']

The default UI languages

['de', 'en']
ycms.core.settings.DEFAULT_OFFER_LANGUAGE = {'english_name': 'German', 'native_name': 'Deutsch'}

The default offer language

{'english_name': 'German', 'native_name': 'Deutsch'}
ycms.core.settings.EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

The backend to use for sending emails (see EMAIL_BACKEND and Sending email)

ycms.core.settings.EMAIL_HOST = 'localhost'

The host to use for sending email (see EMAIL_HOST)

ycms.core.settings.EMAIL_HOST_PASSWORD = None

Password to use for the SMTP server defined in EMAIL_HOST (see EMAIL_HOST_PASSWORD). If empty, Django won’t attempt authentication.

ycms.core.settings.EMAIL_HOST_USER = 'noreply@example.com'

Username to use for the SMTP server defined in EMAIL_HOST (see EMAIL_HOST_USER). If empty, Django won’t attempt authentication.

ycms.core.settings.EMAIL_PORT = 587

Port to use for the SMTP server defined in EMAIL_HOST (see EMAIL_PORT)

ycms.core.settings.EMAIL_USE_SSL = False

Whether to use an implicit TLS (secure) connection when talking to the SMTP server. In most email documentation this type of TLS connection is referred to as SSL. It is generally used on port 465. (see EMAIL_USE_SSL)

ycms.core.settings.EMAIL_USE_TLS = True

Whether to use a TLS (secure) connection when talking to the SMTP server. This will use Opportunistic TLS (STARTTLS command after starting a plain text connection). (see EMAIL_USE_TLS)

ycms.core.settings.LANGUAGES = [('de', 'German'), ('en', 'English')]

The list of languages which are available in the UI (see LANGUAGES and Internationalization and localization)

[('de', 'German'), ('en', 'English')]
ycms.core.settings.LOCALE_PATHS = ['/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/locale']

A list of directories where Django looks for translation files (see LOCALE_PATHS and Internationalization and localization)

[
    '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/locale',
]
ycms.core.settings.LOGFILE = '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/ycms.log'

The file path of the logfile. Needs to be writable by the application.

ycms.core.settings.LOGGING = {'disable_existing_loggers': False, 'filters': {'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse'}, 'require_debug_true': {'()': 'django.utils.log.RequireDebugTrue'}}, 'formatters': {'console-colored': {'()': <class 'ycms.core.logging_formatter.ColorFormatter'>, 'datefmt': '%b %d %H:%M:%S', 'format': '{asctime} {levelname} {name} - {message}', 'style': '{'}, 'logfile': {'()': <class 'ycms.core.logging_formatter.RequestFormatter'>, 'datefmt': '%b %d %H:%M:%S', 'format': '{asctime} {levelname:7} {name} - {message}', 'style': '{'}, 'management-command': {'()': <class 'ycms.core.logging_formatter.ColorFormatter'>, 'format': '{message}', 'style': '{'}}, 'handlers': {'console-colored': {'class': 'logging.StreamHandler', 'filters': ['require_debug_true'], 'formatter': 'console-colored'}, 'logfile': {'class': 'logging.FileHandler', 'filename': '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/ycms.log', 'formatter': 'logfile'}, 'management-command': {'class': 'logging.StreamHandler', 'filters': ['require_debug_true'], 'formatter': 'management-command'}}, 'loggers': {'ycms': {'handlers': ['console-colored', 'logfile'], 'level': 'INFO'}, 'ycms.core.management.commands': {'handlers': ['management-command', 'logfile'], 'level': 'INFO', 'propagate': False}}, 'version': 1}

Logging configuration dictionary (see LOGGING)

{
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse'},
        'require_debug_true': {'()': 'django.utils.log.RequireDebugTrue'},
    },
    'formatters': {
        'console-colored': {
            '()': <class 'ycms.core.logging_formatter.ColorFormatter'>,
            'datefmt': '%b %d %H:%M:%S',
            'format': '{asctime} {levelname} {name} - {message}',
            'style': '{',
        },
        'logfile': {
            '()': <class 'ycms.core.logging_formatter.RequestFormatter'>,
            'datefmt': '%b %d %H:%M:%S',
            'format': '{asctime} {levelname:7} {name} - {message}',
            'style': '{',
        },
        'management-command': {
            '()': <class 'ycms.core.logging_formatter.ColorFormatter'>,
            'format': '{message}',
            'style': '{',
        },
    },
    'handlers': {
        'console-colored': {
            'class': 'logging.StreamHandler',
            'filters': ['require_debug_true'],
            'formatter': 'console-colored',
        },
        'logfile': {
            'class': 'logging.FileHandler',
            'filename': '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/ycms.log',
            'formatter': 'logfile',
        },
        'management-command': {
            'class': 'logging.StreamHandler',
            'filters': ['require_debug_true'],
            'formatter': 'management-command',
        },
    },
    'loggers': {
        'ycms': {'handlers': ['console-colored', 'logfile'], 'level': 'INFO'},
        'ycms.core.management.commands': {
            'handlers': ['management-command', 'logfile'],
            'level': 'INFO',
            'propagate': False,
        },
    },
    'version': 1,
}
ycms.core.settings.LOG_LEVEL = 'INFO'

The log level for ycms django apps

ycms.core.settings.MEDIA_MAX_UPLOAD_SIZE = 3145728

The maximum size of media files in bytes

ycms.core.settings.MEDIA_ROOT = '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/media'

Absolute filesystem path to the directory that will hold user-uploaded files (see MEDIA_ROOT)

ycms.core.settings.MEDIA_URL = '/media/'

URL that handles the media served from MEDIA_ROOT (see MEDIA_URL)

ycms.core.settings.PRA_BASE = '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/patient-to-room_assignment'

Base path of the PRA solver. Assumes it is located in a sibling directory to this project.

ycms.core.settings.PRA_INPUT_PATH = '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/patient-to-room_assignment/instances/generated.json'

Where to put the input for the PRA solver. Assumes it is located in a sibling directory to this project.

ycms.core.settings.PRA_OUTPUT_PATH = '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/patient-to-room_assignment/Results/instances/generated_out.json'

Where the PRA solver puts its output. Assumes it is located in a sibling directory to this project.

ycms.core.settings.SERVER_EMAIL = 'noreply@example.com'

The email address that error messages come from, such as those sent to ADMINS. (see SERVER_EMAIL)

ycms.core.settings.STATICFILES_DIRS = ['/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/static', '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/static/dist']

This setting defines the additional locations the django.contrib.staticfiles app will traverse to collect static files for deployment or to serve them during development (see STATICFILES_DIRS and Managing static files).

[
    '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/static',
    '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/static/dist',
]
ycms.core.settings.STATICFILES_FINDERS = ('django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder')

The list of finder backends that know how to find static files in various locations (see STATICFILES_FINDERS)

(
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
ycms.core.settings.STATIC_ROOT = None

The absolute path to the output directory where django.contrib.staticfiles will put static files for deployment (see STATIC_ROOT and Managing static files) In debug mode, this is not required since django.contrib.staticfiles can directly serve these files.

ycms.core.settings.STATIC_URL = 'static/'

URL to use in development when referring to static files located in STATICFILES_DIRS (see STATIC_URL and Managing static files)

ycms.core.settings.WEBPACK_LOADER = {'DEFAULT': {'BUNDLE_DIR_NAME': '', 'STATS_FILE': '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/webpack-stats.json'}}

Overwrite default bundle directory

{
    'DEFAULT': {
        'BUNDLE_DIR_NAME': '',
        'STATS_FILE': '/home/docs/checkouts/readthedocs.org/user_builds/ycms/envs/latest/lib/python3.9/site-packages/ycms/webpack-stats.json',
    },
}

Urls

ycms URL Configuration

The urlpatterns list routes URLs to views. For more information please see:

https://docs.djangoproject.com/en/4.1/topics/http/urls/

Examples:

Function views
  1. Add an import: from my_app import views

  2. Add a URL to urlpatterns: path(‘’, views.home, name=’home’)

Class-based views
  1. Add an import: from other_app.views import Home

  2. Add a URL to urlpatterns: path(‘’, Home.as_view(), name=’home’)

Including another URLconf
  1. Import the include() function: from django.urls import include, path

  2. Add a URL to urlpatterns: path(‘blog/’, include(‘blog.urls’))

Wsgi

WSGI config for ycms project.

It exposes the WSGI callable as a module-level variable named application.

For more information on this file, see https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/

ycms.core.wsgi.application(environ, start_response)

This returns the WSGI callable

Parameters:
  • environ (dict) – The environment variables

  • start_response (Callable) – A function which starts the response

Returns:

The WSGI callable

Return type:

WSGIHandler