• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tjcsl / tin / 11766501715

10 Nov 2024 03:49PM UTC coverage: 54.923% (+0.1%) from 54.79%
11766501715

Pull #86

github

web-flow
Merge dc1dc32b2 into 6a43c847c
Pull Request #86: Improve instructions for dev env

403 of 895 branches covered (45.03%)

Branch coverage included in aggregate %.

26 of 43 new or added lines in 6 files covered. (60.47%)

13 existing lines in 2 files now uncovered.

1516 of 2599 relevant lines covered (58.33%)

0.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.52
/tin/settings/__init__.py
1
"""Django settings for tin project.
2

3
Generated by 'django-admin startproject' using Django 2.1.3.
4

5
For more information on this file, see
6
https://docs.djangoproject.com/en/4.2/topics/settings/
7

8
For the full list of settings and their values, see
9
https://docs.djangoproject.com/en/4.2/ref/settings/
10
"""
11

12
from __future__ import annotations
1✔
13

14
import os
1✔
15
from pathlib import Path
1✔
16

17
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
18
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1✔
19

20
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
1✔
21

22

23
# Quick-start development settings - unsuitable for production
24
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
25

26
# SECURITY WARNING: keep the secret key used in production secret!
27
SECRET_KEY = "naxigo(w3=$1&!-t4vbb9)g^8#lnt6ygr)(2qfi1z(h(r_cjhy"
1✔
28

29
# SECURITY WARNING: don't run with debug turned on in production!
30
DEBUG = True
1✔
31

32
USE_SANDBOXING = (
1✔
33
    not DEBUG or Path(BASE_DIR).joinpath("sandboxing", "wrappers", "sandboxed", "P.txt").exists()
34
)
35

36

37
ALLOWED_HOSTS = [
1✔
38
    "127.0.0.1",
39
    "localhost",
40
    "tin",
41
    "tin.tjhsst.edu",
42
    "tin.csl.tjhsst.edu",
43
    "tin.sites.tjhsst.edu",
44
]
45

46
INTERNAL_IPS = [
1✔
47
    "127.0.0.1",
48
    "localhost",
49
]
50

51

52
# Application definition
53

54
INSTALLED_APPS = [
1✔
55
    "daphne",
56
    "django.contrib.admin",
57
    "django.contrib.auth",
58
    "django.contrib.contenttypes",
59
    "django.contrib.sessions",
60
    "django.contrib.messages",
61
    "django.contrib.staticfiles",
62
    "social_django",
63
    "django_extensions",
64
    "django_celery_results",
65
    "debug_toolbar",
66
    "markdownify.apps.MarkdownifyConfig",
67
    "tin.apps",
68
    "tin.apps.users",
69
    "tin.apps.auth",
70
    "tin.apps.courses",
71
    "tin.apps.assignments",
72
    "tin.apps.submissions",
73
    "tin.apps.docs",
74
    "tin.apps.venvs",
75
]
76

77
MIDDLEWARE = [
1✔
78
    "debug_toolbar.middleware.DebugToolbarMiddleware",
79
    "django.middleware.security.SecurityMiddleware",
80
    "django.contrib.sessions.middleware.SessionMiddleware",
81
    "django.middleware.common.CommonMiddleware",
82
    "django.middleware.csrf.CsrfViewMiddleware",
83
    "django.contrib.auth.middleware.AuthenticationMiddleware",
84
    "django.contrib.messages.middleware.MessageMiddleware",
85
    "django.middleware.clickjacking.XFrameOptionsMiddleware",
86
]
87

88
ROOT_URLCONF = "tin.urls"
1✔
89

90
TEMPLATES = [
1✔
91
    {
92
        "BACKEND": "django.template.backends.django.DjangoTemplates",
93
        "DIRS": [os.path.join(BASE_DIR, "templates")],
94
        "APP_DIRS": True,
95
        "OPTIONS": {
96
            "context_processors": [
97
                "django.template.context_processors.debug",
98
                "django.template.context_processors.request",
99
                "django.contrib.auth.context_processors.auth",
100
                "django.contrib.messages.context_processors.messages",
101
                "social_django.context_processors.backends",
102
                "social_django.context_processors.login_redirect",
103
                "tin.apps.context_processors.response_footer",
104
            ]
105
        },
106
    }
107
]
108

109
WSGI_APPLICATION = "tin.wsgi.application"
1✔
110
ASGI_APPLICATION = "tin.asgi.application"
1✔
111

112

113
CHANNEL_LAYERS = {
1✔
114
    "default": {
115
        "BACKEND": "channels_redis.core.RedisChannelLayer",
116
        "CONFIG": {"hosts": [("localhost", 6379)]},
117
    },
118
}
119

120
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
1✔
121

122
TEST_RUNNER = "tin.tests.runner.PytestRunner"
1✔
123

124

125
# Database
126
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
127

128
DATABASES = {
1✔
129
    "default": {
130
        "ENGINE": "django.db.backends.sqlite3",
131
        "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
132
    }
133
}
134

135

136
# Password validation
137
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
138

139
if DEBUG:
1!
140
    AUTH_PASSWORD_VALIDATORS = []
1✔
141
else:
UNCOV
142
    AUTH_PASSWORD_VALIDATORS = [
×
143
        {"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
144
        {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
145
        {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
146
        {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
147
    ]
148

149

150
# Authentication-related settings
151

152
AUTHENTICATION_BACKENDS = ("tin.apps.auth.oauth.IonOauth2",)
1✔
153

154
if DEBUG:
1!
155
    AUTHENTICATION_BACKENDS += ("django.contrib.auth.backends.ModelBackend",)
1✔
156

157
SOCIAL_AUTH_USER_FIELDS = [
1✔
158
    "username",
159
    "full_name",
160
    "first_name",
161
    "last_name",
162
    "email",
163
    "id",
164
    "is_student",
165
    "is_teacher",
166
]
167

168
SOCIAL_AUTH_URL_NAMESPACE = "social"
1✔
169

170
SOCIAL_AUTH_PIPELINE = (
1✔
171
    "social_core.pipeline.social_auth.social_details",
172
    "social_core.pipeline.social_auth.social_uid",
173
    "social_core.pipeline.social_auth.auth_allowed",
174
    "social_core.pipeline.social_auth.social_user",
175
    "tin.apps.auth.oauth.get_username",
176
    "social_core.pipeline.social_auth.associate_by_email",
177
    "social_core.pipeline.user.create_user",
178
    "social_core.pipeline.social_auth.associate_user",
179
    "social_core.pipeline.social_auth.load_extra_data",
180
)
181

182
AUTH_USER_MODEL = "users.User"
1✔
183

184
SOCIAL_AUTH_ALWAYS_ASSOCIATE = True
1✔
185

186
LOGOUT_URL = "/logout/"
1✔
187

188
LOGIN_URL = "/login/"
1✔
189

190
LOGIN_REDIRECT_URL = "/"
1✔
191

192
SOCIAL_AUTH_LOGIN_ERROR_URL = "/"
1✔
193
SOCIAL_AUTH_RAISE_EXCEPTIONS = False
1✔
194

195

196
# Internationalization
197
# https://docs.djangoproject.com/en/2.1/topics/i18n/
198

199
LANGUAGE_CODE = "en-us"
1✔
200

201
TIME_ZONE = "America/New_York"
1✔
202

203
USE_I18N = True
1✔
204

205
USE_TZ = True
1✔
206

207

208
# Static files (CSS, JavaScript, Images)
209
# https://docs.djangoproject.com/en/2.1/howto/static-files/
210

211
STATIC_URL = "/static/"
1✔
212

213
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)
1✔
214
STATIC_ROOT = os.path.join(BASE_DIR, "serve")
1✔
215

216

217
# Logging
218

219
LOGGING = {
1✔
220
    "version": 1,
221
    "disable_existing_loggers": False,
222
    "formatters": {"simple": {"format": "{asctime}: {levelname:>8s}: {message}", "style": "{"}},
223
    "handlers": {
224
        "console": {"level": "DEBUG", "class": "logging.StreamHandler", "formatter": "simple"},
225
        "info_log": {
226
            "level": "INFO",
227
            "class": "logging.FileHandler",
228
            "filename": os.path.join(BASE_DIR, "logs/info.log"),
229
            "formatter": "simple",
230
        },
231
    },
232
    "loggers": {
233
        "django": {"handlers": ["console", "info_log"], "level": "INFO", "propagate": True},
234
        "tin": {"handlers": ["console", "info_log"], "level": "INFO", "propagate": True},
235
    },
236
}
237

238

239
# Celery settings
240

241
CELERY_RESULT_BACKEND = "django-db"
1✔
242

243

244
CELERY_BROKER_URL = "redis://localhost:6379/1"
1✔
245

246

247
# Markdown
248
MARKDOWNIFY = {
1✔
249
    "default": {
250
        "MARKDOWN_EXTENSIONS": [
251
            "fenced_code",
252
        ],
253
        "WHITELIST_ATTRS": ["class", "href", "src", "alt"],
254
        "WHITELIST_TAGS": [
255
            "a",
256
            "abbr",
257
            "acronym",
258
            "b",
259
            "blockquote",
260
            "code",
261
            "em",
262
            "h1",
263
            "h2",
264
            "h3",
265
            "h4",
266
            "h5",
267
            "h6",
268
            "i",
269
            "img",
270
            "li",
271
            "ol",
272
            "p",
273
            "pre",
274
            "span",
275
            "strong",
276
            "ul",
277
        ],
278
    }
279
}
280

281

282
# Django debug toolbar settings
283

284
_enabled_panels = {
1✔
285
    "debug_toolbar.panels.history.HistoryPanel",
286
    "debug_toolbar.panels.versions.VersionsPanel",
287
    "debug_toolbar.panels.timer.TimerPanel",
288
    "debug_toolbar.panels.settings.SettingsPanel",
289
    "debug_toolbar.panels.headers.HeadersPanel",
290
    "debug_toolbar.panels.request.RequestPanel",
291
    "debug_toolbar.panels.sql.SQLPanel",
292
    "debug_toolbar.panels.staticfiles.StaticFilesPanel",
293
    "debug_toolbar.panels.templates.TemplatesPanel",
294
    "debug_toolbar.panels.cache.CachePanel",
295
    "debug_toolbar.panels.signals.SignalsPanel",
296
    "debug_toolbar.panels.redirects.RedirectsPanel",
297
    "debug_toolbar.panels.profiling.ProfilingPanel",
298
}
299

300
DEBUG_TOOLBAR_CONFIG = {
1✔
301
    "DISABLE_PANELS": _enabled_panels,
302
    "SHOW_COLLAPSED": True,
303
}
304

305
# Tin-specific settings
306

307
SUBMISSION_SIZE_LIMIT = 1 * 1000 * 1000  # 1 MB
1✔
308

309
DEVELOPER_EMAIL = "tin@tjhsst.edu"
1✔
310
REPO_URL = "https://github.com/tjcsl/tin"
1✔
311

312
VENV_FILE_SIZE_LIMIT = 1 * 1000 * 1000 * 1000  # 1 GB
1✔
313

314
# The wrapper script to use when running submissions outside of production
315
# We still need this so that it can handle cli arguments to the wrapper script
316
DEBUG_GRADER_WRAPPER_SCRIPT = Path(BASE_DIR).parent / "scripts" / "grader_wrapper.py"
1✔
317

318
# Spaces and special characters may not be handled correctly
319
# Not importing correctly - specified directly in apps/submissions/tasks.py
320
# as of 8/3/2022, 2022ldelwich
321
SUBMISSION_PYTHON = "/usr/bin/python3.10"
1✔
322

323
SUBMISSION_NAMESERVERS = ["198.38.16.40", "198.38.16.41"]
1✔
324

325
# Users may only have this many submissions running
326
CONCURRENT_USER_SUBMISSION_LIMIT = 2
1✔
327

328
# Threshold for log messages being issues
329
QUIZ_ISSUE_THRESHOLD = 5
1✔
330

331
# ImgBB API key (set in secret.py)
332
IMGBB_API_KEY = ""
1✔
333

334
try:
1✔
335
    from .secret import *
1✔
336
except ImportError:
1✔
337
    pass
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc