django-auditlog/auditlog_tests/test_settings.py

64 lines
1.6 KiB
Python
Raw Normal View History

"""
Settings file for the Auditlog test suite.
"""
import os
2020-08-31 11:57:10 +00:00
DEBUG = True
2021-06-24 10:04:48 +00:00
SECRET_KEY = "test"
INSTALLED_APPS = [
2021-06-24 10:04:48 +00:00
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.messages",
"django.contrib.sessions",
"django.contrib.admin",
2020-12-06 20:29:24 +00:00
"django.contrib.staticfiles",
2021-06-24 10:04:48 +00:00
"auditlog",
"auditlog_tests",
]
MIDDLEWARE = [
2021-06-24 10:04:48 +00:00
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"auditlog.middleware.AuditlogMiddleware",
]
Fixes #93 - Add 'changes_display_dict' property to 'LogEntry' model to display diff in a more human readable format (#94) Fixes #93 - Add 'changes_display_dict' property to 'LogEntry' model to display diff in a more human readable format 'changes_display_dict' currently handles fields with choices, long textfields and charfields, datefields, timefields, and datetimefields. Supports `django-multiselectfield` with choices and Postgres's ArrayField with choices. Textfields and Charfields longer than 140 characters are truncated with an ellipsis appended. Date, Time and DateTime fields are rendered according to `L10N`, or if turned off fall back on Django settings defaults for DATE_FORMAT, TIME_FORMAT and DATETIME_FORMAT. A new kwarg was added to 'AuditlogModelRegistry' called 'mapping_fields'. The kwarg allows the user to map the fields in the model to a more human readable or intuitive name. If a field isn't mapped it will default to the `verbose_name` as defined on the model or the Django default `verbose_name`. Partial mapping is supported, all fields do not need to be mapped to use the feature. * Add django-multiselectfield test dep * Add psycopg2 test dep * Add postgres testing database and router * Add postgres support to travis builds * Add support for multiple databases. LogEntry saves to same database of the model its associated to * If any literal evals fail default to None * Add support for Postgres ArrayField in changes_display_dict * Revert to old travis image while they are fixing issues with it * Update docs * Add full test coverage
2017-09-13 14:57:47 +00:00
DATABASES = {
2021-06-24 10:04:48 +00:00
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.getenv(
"TEST_DB_NAME", "auditlog" + os.environ.get("TOX_PARALLEL_ENV", "")
),
"USER": os.getenv("TEST_DB_USER", "postgres"),
"PASSWORD": os.getenv("TEST_DB_PASS", ""),
"HOST": os.getenv("TEST_DB_HOST", "127.0.0.1"),
"PORT": os.getenv("TEST_DB_PORT", "5432"),
}
}
TEMPLATES = [
{
2021-06-24 10:04:48 +00:00
"APP_DIRS": True,
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"OPTIONS": {
"context_processors": [
2020-12-06 20:29:24 +00:00
"django.template.context_processors.request",
2021-06-24 10:04:48 +00:00
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
]
},
},
]
2020-12-06 20:29:24 +00:00
STATIC_URL = "/static/"
2020-08-31 11:57:10 +00:00
2021-06-24 10:04:48 +00:00
ROOT_URLCONF = "auditlog_tests.urls"
USE_TZ = True
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"