Skip to content

Commit

Permalink
Unify settings.py.template and default_settings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
edokimok committed Mar 21, 2023
1 parent 6d3d64b commit a8653c8
Show file tree
Hide file tree
Showing 2 changed files with 323 additions and 278 deletions.
157 changes: 139 additions & 18 deletions oioioi/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@

INSTALLATION_CONFIG_VERSION = 49

# Enable debugging features.
#
# SET DEBUG = False FOR PRODUCTION DEPLOYMENT.
DEBUG = False
INTERNAL_IPS = ('127.0.0.1',)

# Site name displayed in the title and used by sioworkersd
# to distinguish OIOIOI instances.
SITE_NAME = 'OIOIOI'
SITE_ID = 1

# The website address as it will be displayed to users in some places,
# including but not limited to the mail notifications.
Expand All @@ -33,13 +37,16 @@
# None - nothing will be run
SERVER = None

# Controls if uwsgi in default configuration shall use gevent loop.
# To use it, you have to install gevent - please consult
# https://github.com/surfly/gevent
# This is recommended for heavy load, but you may still need to tune uwsgi
# options in deployment/supervisord.conf
UWSGI_USE_GEVENT = False

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'wsgi.application'

SEND_USER_ACTIVATION_EMAIL = True

LANGUAGES = (
('en', 'English'),
('pl', 'Polish'),
Expand Down Expand Up @@ -97,6 +104,36 @@
# Secret key can't be empty, it is overridden later.
SECRET_KEY = 'eca76a75-2b9f-4e09-8f88-86671acbed8b'

# Uncomment once oisubmit is used.
# OISUBMIT_MAGICKEY = '__OTHER_SECRET__'

# Email addresses to send error message reports.
ADMINS = (
('Your Name', '[email protected]'),
)

# Email addresses to send communication from users (for example requests for
# teacher accounts).
MANAGERS = ADMINS

# SMTP server parameters for sending emails.
EMAIL_USE_TLS = False
EMAIL_HOST = 'mail'
EMAIL_PORT = 25
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_SUBJECT_PREFIX = '[OIOIOI] '

# Sender email address for messages sent by OIOIOI to users.
DEFAULT_FROM_EMAIL = 'webmaster@localhost'

# Sender email address for error messages sent to admins.
SERVER_EMAIL = DEFAULT_FROM_EMAIL

# Set to true to send user activation emails. Needs an SMTP server to be
# configured above.
SEND_USER_ACTIVATION_EMAIL = True

# List of callables that know how to import templates from various sources.
UNCACHED_TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
Expand All @@ -107,12 +144,18 @@
('django.template.loaders.cached.Loader', UNCACHED_TEMPLATE_LOADERS),
)

# Set to True to show the link to the problemset with contests on navbar.
PROBLEMSET_LINK_VISIBLE = True

# Comment out to show tags on the list of problems
PROBLEM_TAGS_VISIBLE = False

# Enables problem statistics at the cost of some per-submission performance hit.
# Set to True if you want to see statistics in the Problemset and problem sites.
# After enabling you should use ./manage.py recalculate_statistics
PROBLEM_STATISTICS_AVAILABLE = False

# Set to True to allow every logged in user to add problems directly to Problemset
EVERYBODY_CAN_ADD_TO_PROBLEMSET = False

DEFAULT_GLOBAL_PORTAL_AS_MAIN_PAGE = True
Expand Down Expand Up @@ -195,6 +238,18 @@

LIBSASS_PRECISION = 8

# EXTRA MODULES
#
# Comment/uncomment components to disable/enable them.
#
# Additional components usually have to be prepended to the list in
# INSTALLED_APPS, because they may want to override some templates. But this is
# not always the case. Please consult the documentation of particular extension
# you're configuring.
#
# Some components need also corresponding lines in TEMPLATE_CONTEXT_PROCESSORS
# and/or AUTHENTICATION_BACKENDS commented/uncommented.

INSTALLED_APPS = (
'debug_toolbar',
'oioioi.filetracker',
Expand Down Expand Up @@ -250,6 +305,13 @@
'fontawesomefree',
)

# If set to locations of flite and sox executables, enables audio playback
# of captcha. Audio output generated by flite (CAPTCHA_FLITE_PATH) is identical
# across multiple generations. To prevent potential security risk,
# CAPTCHA_SOX_PATH should be set as well, in order to inject random noise into
# audio files generated by flite.
# If either sox or flite is installed and its location recognised by PATH
# variable, then corresponding setting will be set automatically.
CAPTCHA_FLITE_PATH = find_executable_path('flite')
CAPTCHA_SOX_PATH = find_executable_path('sox')
CAPTCHA_BACKGROUND_COLOR = '#daedf4'
Expand All @@ -268,6 +330,27 @@
FILETRACKER_CLIENT_FACTORY = 'oioioi.filetracker.client.remote_storage_factory'
DEFAULT_FILE_STORAGE = 'oioioi.filetracker.storage.FiletrackerStorage'

FILETRACKER_SERVER_ENABLED = True
FILETRACKER_LISTEN_ADDR = '127.0.0.1'
FILETRACKER_LISTEN_PORT = 9999

# When using distributed workers set this to url on which workers will be
# able to access filetracker server. When 'remote_storage_factory' is used,
# this also defines the filetracker server oioioi should connect to.
FILETRACKER_URL = 'http://127.0.0.1:9999'

# When using a remote storage it's recommended to enable a cache cleaner deamon
# which will periodically scan cache directory and remove files what aren't
# used. For a detailed description of each option, please read a cache cleaner
# configuration section in the sioworkersd documentation. Please note that
# the cache cleaner can delete *any* file found under FILETRACKER_CACHE_ROOT
# directory, so don't store other files there (unless you want them to be
# periodically deleted).
# FILETRACKER_CACHE_CLEANER_ENABLED = True
# FILETRACKER_CACHE_CLEANER_SCAN_INTERVAL = '1h'
# FILETRACKER_CACHE_CLEANER_CLEAN_LEVEL = '50'
# FILETRACKER_CACHE_SIZE = '8G'

SUPERVISOR_AUTORELOAD_PATTERNS = [".py", ".pyc", ".pyo"]

# For dj_pagination
Expand Down Expand Up @@ -303,9 +386,14 @@

SIOWORKERSD_URL = 'http://localhost:7889/'
SIOWORKERS_BACKEND = 'oioioi.sioworkers.backends.SioworkersdBackend'

# Set this to false if you don't need sioworkersd instance (e. g.
# because you use instance started by another instance of OIOIOI)
RUN_SIOWORKERSD = True

# On which interface should the sioworkers receiver listen
# On which interface should the sioworkers receiver listen. You should
# set the address to 0.0.0.0 if you want remote workers to access
# your server.
SIOWORKERS_LISTEN_ADDR = '127.0.0.1'
SIOWORKERS_LISTEN_PORT = 7890

Expand All @@ -314,6 +402,7 @@
# http://$SIOWORKERS_LISTEN_ADDR:$SIOWORKERS_LISTEN_PORT
SIOWORKERS_LISTEN_URL = None

# Set to false to disable workers running on the server machine.
RUN_LOCAL_WORKERS = False

# This setting specifies which languages are available on the platform.
Expand Down Expand Up @@ -407,13 +496,23 @@
'Python': 'python', 'Output-only': 'output-only'}

SYSTEM_DEFAULT_COMPILERS = {'C': 'system-gcc', 'C++': 'system-g++',
'Pascal': 'system-fpc', 'Java': 'system-java',
'Python': 'system-python', 'Output-only': 'output-only'}
'Pascal': 'system-fpc', 'Java': 'system-java',
'Python': 'system-python', 'Output-only': 'output-only'}

# Set the following option to false to enable the safe execution supervisor.
USE_UNSAFE_EXEC = False

# Default safe execution tool
# You can change the safe execution tool. Current options are:
# - "sio2jail" - (default) SIO2Jail
# - "cpu" - ptrace (measures real time)
DEFAULT_SAFE_EXECUTION_MODE = "sio2jail"

# WARNING: experimental, see settings template
# WARNING: setting this to False is experimental until we make sure that
# checkers do work well in sandbox
#
# Setting this to False will run checkers in sandbox. This option is
# independent to USE_UNSAFE_EXEC.
USE_UNSAFE_CHECKER = True

# When USE_SINOLPACK_MAKEFILES equals True, the sinolpack upload workflow uses
Expand Down Expand Up @@ -445,17 +544,32 @@
MAX_TEST_TIME_LIMIT_PER_PROBLEM = 1000 * 60 * 60 * 30
MAX_MEMORY_LIMIT_FOR_TEST = 256 * 1024

FILETRACKER_SERVER_ENABLED = True
FILETRACKER_LISTEN_ADDR = '127.0.0.1'
FILETRACKER_LISTEN_PORT = 9999

FILETRACKER_URL = 'http://127.0.0.1:9999'

DEFAULT_CONTEST = None
ONLY_DEFAULT_CONTEST = False

# Contest mode - automatic activation of contests.
#
# Available choices are:
# ContestMode.neutral - no contest is activated automatically,
# users have to explicitly enter into a contest specific page if they want
# to participate. They can visit both contest specific as well as non-contest
# specific pages.
# ContestMode.contest_if_possible - if there exists a contest, users
# are automatically redirected to one when visiting a page which
# has a contest specific version, e.g. visiting index ('/') could redirect
# to "c" contest's dashboard page ('/c/c/dashboard') if there existed
# a contest "c". The contest picking algorithm is described in detail
# in oioioi.contests.middleware module.
# If a page requires that no contest is active (e.g. user's portal page
# from the "portals" app), it can still be visited and no redirection
# will be made.
# ContestMode.contest_only - this setting is similar to the previous one
# except that pages requiring no contest to be active can only be visited
# by superusers (other users get "403 - Permission Denied").
#
# Some features may depend on this setting, e.g. the "portals" app requires
# that either the "neutral" or the "contest_if_possible" option is picked.
from oioioi.contests.current_contest import ContestMode

CONTEST_MODE = ContestMode.contest_if_possible

# A sample logging configuration. The only tangible logging
Expand All @@ -472,10 +586,10 @@
}
},
'formatters': {
'date_and_level': {
'format': '[%(asctime)s %(levelname)s %(process)d:%(thread)d]'
' %(message)s',
},
'date_and_level': {
'format': '[%(asctime)s %(levelname)s %(process)d:%(thread)d]'
' %(message)s',
},
},
'handlers': {
'console': {
Expand Down Expand Up @@ -515,7 +629,7 @@
CELERY_SEND_EVENTS = True

BROKER_URL = 'sqla+sqlite:///' + os.path.join(tempfile.gettempdir(),
'celerydb.sqlite')
'celerydb.sqlite')

CELERY_IMPORTS = [
'oioioi.evalmgr.tasks',
Expand Down Expand Up @@ -577,6 +691,10 @@
ZEUS_SEND_RETRIES = 3
ZEUS_RETRY_SLEEP = 1 # second

# Complaints
# COMPLAINTS_EMAIL = 'email_to_send_complaints_to'
# COMPLAINTS_SUBJECT_PREFIX = '[oioioi-complaints] '

# Cache
CACHES = {
'default': {
Expand Down Expand Up @@ -676,6 +794,9 @@
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}

# If set to True, usercontests will become read-only: it will be impossible to
# change, delete or submit to existing usercontests, as well as add new ones.
# This operation is fully reversible.
ARCHIVE_USERCONTESTS = False

FORUM_PAGE_SIZE = 15
Expand Down
Loading

0 comments on commit a8653c8

Please sign in to comment.