Add django rest framework with CRUD views
This commit is contained in:
parent
221fc560a7
commit
abb8eaae13
10 changed files with 401 additions and 11 deletions
|
|
@ -245,7 +245,7 @@ IN_GAME_ERRORS = True
|
|||
# ENGINE - path to the the database backend. Possible choices are:
|
||||
# 'django.db.backends.sqlite3', (default)
|
||||
# 'django.db.backends.mysql',
|
||||
# 'django.db.backends.postgresql_psycopg2',
|
||||
# 'django.db.backends.postgresql',
|
||||
# 'django.db.backends.oracle' (untested).
|
||||
# NAME - database name, or path to the db file for sqlite3
|
||||
# USER - db admin (unused in sqlite3)
|
||||
|
|
@ -255,7 +255,9 @@ IN_GAME_ERRORS = True
|
|||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": os.getenv("TEST_DB_PATH", os.path.join(GAME_DIR, "server", "evennia.db3")),
|
||||
"NAME": os.getenv(
|
||||
"TEST_DB_PATH", os.path.join(GAME_DIR, "server", "evennia.db3")
|
||||
),
|
||||
"USER": "",
|
||||
"PASSWORD": "",
|
||||
"HOST": "",
|
||||
|
|
@ -472,7 +474,12 @@ SERVER_SESSION_CLASS = "evennia.server.serversession.ServerSession"
|
|||
# immediately entered path fail to find a typeclass. It allows for
|
||||
# shorter input strings. They must either base off the game directory
|
||||
# or start from the evennia library.
|
||||
TYPECLASS_PATHS = ["typeclasses", "evennia", "evennia.contrib", "evennia.contrib.tutorial_examples"]
|
||||
TYPECLASS_PATHS = [
|
||||
"typeclasses",
|
||||
"evennia",
|
||||
"evennia.contrib",
|
||||
"evennia.contrib.tutorial_examples",
|
||||
]
|
||||
|
||||
# Typeclass for account objects (linked to a character) (fallback)
|
||||
BASE_ACCOUNT_TYPECLASS = "typeclasses.accounts.Account"
|
||||
|
|
@ -550,7 +557,11 @@ VALIDATOR_FUNC_MODULES = ["evennia.utils.validatorfuncs"]
|
|||
|
||||
# Python path to a directory to be searched for batch scripts
|
||||
# for the batch processors (.ev and/or .py files).
|
||||
BASE_BATCHPROCESS_PATHS = ["world", "evennia.contrib", "evennia.contrib.tutorial_examples"]
|
||||
BASE_BATCHPROCESS_PATHS = [
|
||||
"world",
|
||||
"evennia.contrib",
|
||||
"evennia.contrib.tutorial_examples",
|
||||
]
|
||||
|
||||
######################################################################
|
||||
# Game Time setup
|
||||
|
|
@ -861,7 +872,9 @@ TEMPLATES = [
|
|||
os.path.join(GAME_DIR, "web", "template_overrides"),
|
||||
os.path.join(EVENNIA_DIR, "web", "website", "templates", WEBSITE_TEMPLATE),
|
||||
os.path.join(EVENNIA_DIR, "web", "website", "templates"),
|
||||
os.path.join(EVENNIA_DIR, "web", "webclient", "templates", WEBCLIENT_TEMPLATE),
|
||||
os.path.join(
|
||||
EVENNIA_DIR, "web", "webclient", "templates", WEBCLIENT_TEMPLATE
|
||||
),
|
||||
os.path.join(EVENNIA_DIR, "web", "webclient", "templates"),
|
||||
],
|
||||
"APP_DIRS": True,
|
||||
|
|
@ -912,6 +925,8 @@ INSTALLED_APPS = [
|
|||
"django.contrib.sites",
|
||||
"django.contrib.staticfiles",
|
||||
"django.contrib.messages",
|
||||
"rest_framework",
|
||||
"django_filters",
|
||||
"sekizai",
|
||||
"evennia.utils.idmapper",
|
||||
"evennia.server",
|
||||
|
|
@ -931,7 +946,9 @@ AUTH_USER_MODEL = "accounts.AccountDB"
|
|||
# Password validation plugins
|
||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
||||
"OPTIONS": {"min_length": 8},
|
||||
|
|
@ -944,8 +961,14 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
# Username validation plugins
|
||||
AUTH_USERNAME_VALIDATORS = [
|
||||
{"NAME": "django.contrib.auth.validators.ASCIIUsernameValidator"},
|
||||
{"NAME": "django.core.validators.MinLengthValidator", "OPTIONS": {"limit_value": 3}},
|
||||
{"NAME": "django.core.validators.MaxLengthValidator", "OPTIONS": {"limit_value": 30}},
|
||||
{
|
||||
"NAME": "django.core.validators.MinLengthValidator",
|
||||
"OPTIONS": {"limit_value": 3},
|
||||
},
|
||||
{
|
||||
"NAME": "django.core.validators.MaxLengthValidator",
|
||||
"OPTIONS": {"limit_value": 30},
|
||||
},
|
||||
{"NAME": "evennia.server.validators.EvenniaUsernameAvailabilityValidator"},
|
||||
]
|
||||
|
||||
|
|
@ -956,6 +979,38 @@ TEST_RUNNER = "evennia.server.tests.testrunner.EvenniaTestSuiteRunner"
|
|||
# messages.error() to Bootstrap 'danger' classes.
|
||||
MESSAGE_TAGS = {messages.ERROR: "danger"}
|
||||
|
||||
# Django REST Framework settings
|
||||
REST_FRAMEWORK = {
|
||||
# django_filters allows you to specify search fields for models in an API View
|
||||
'DEFAULT_FILTER_BACKENDS': (
|
||||
'django_filters.rest_framework.DjangoFilterBackend',
|
||||
),
|
||||
# whether to paginate results and how many per page
|
||||
"DEFAULT_PAGINATION_CLASS": 'rest_framework.pagination.LimitOffsetPagination',
|
||||
'PAGE_SIZE': 25,
|
||||
# require logged in users to call API so that access checks can work on them
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.IsAuthenticated',
|
||||
],
|
||||
# These are the different ways people can authenticate for API requests - via
|
||||
# session or with user/password. Other ways are possible, such as via tokens
|
||||
# or oauth, but require additional dependencies.
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||
'rest_framework.authentication.BasicAuthentication',
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
],
|
||||
# default permission checks used by the EvenniaPermission class
|
||||
"DEFAULT_CREATE_PERMISSION": "builder",
|
||||
"DEFAULT_LIST_PERMISSION": "builder",
|
||||
"DEFAULT_VIEW_LOCKS": ["examine"],
|
||||
"DEFAULT_DESTROY_LOCKS": ["delete"],
|
||||
"DEFAULT_UPDATE_LOCKS": ["control", "edit"],
|
||||
# No throttle class set by default. Setting one also requires a cache backend to be specified.
|
||||
}
|
||||
|
||||
# To enable the REST api, turn this to True
|
||||
REST_API_ENABLED = False
|
||||
|
||||
######################################################################
|
||||
# Django extensions
|
||||
######################################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue