-
Notifications
You must be signed in to change notification settings - Fork 250
/
base.py
887 lines (738 loc) · 30.8 KB
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
"""Common settings and globals."""
import datetime
import os
import platform
from logging.handlers import SysLogHandler
from os.path import abspath, basename, dirname, join, normpath
from sys import path
from django.utils.translation import ugettext_lazy as _
from ecommerce.core.constants import (
ENTERPRISE_COUPON_ADMIN_ROLE,
ENTERPRISE_COUPON_LEARNER_ROLE,
ENTERPRISE_OFFER_ADMIN_ROLE,
ENTERPRISE_OFFER_LEARNER_ROLE,
ORDER_MANAGER_ROLE,
STUDENT_SUPPORT_ADMIN_ROLE,
SYSTEM_ENTERPRISE_ADMIN_ROLE,
SYSTEM_ENTERPRISE_LEARNER_ROLE,
SYSTEM_ENTERPRISE_OPERATOR_ROLE
)
from ecommerce.extensions.offer.constants import OfferUsageEmailTypes
from ecommerce.settings._oscar import *
# PATH CONFIGURATION
# Absolute filesystem path to the Django project directory
DJANGO_ROOT = dirname(dirname(abspath(__file__)))
# Absolute filesystem path to the top-level project folder
SITE_ROOT = dirname(DJANGO_ROOT)
# Site name
SITE_NAME = basename(DJANGO_ROOT)
# Add our project to our pythonpath; this way, we don't need to type our project
# name in our dotted import paths
path.append(DJANGO_ROOT)
# END PATH CONFIGURATION
# DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = False
# END DEBUG CONFIGURATION
# MANAGER CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
ADMINS = (
('Your Name', 'your_email@example.com'),
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
MANAGERS = ADMINS
# END MANAGER CONFIGURATION
# DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
# Note that we use connection pooling/persistent connections (CONN_MAX_AGE)
# in production, but the Django docs discourage its use in development.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.',
'NAME': 'ecommerce',
'USER': 'ecomm001',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '',
'ATOMIC_REQUESTS': True,
'CONN_MAX_AGE': 60,
}
}
# END DATABASE CONFIGURATION
# GENERAL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
TIME_ZONE = 'UTC'
# See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en'
SITE_ID = 1
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
USE_I18N = True
LANGUAGES = (
('en', _('English')),
('es', _('Spanish')),
('es-419', _('Spanish (Latin American)')),
)
LOCALE_PATHS = (
join(DJANGO_ROOT, 'conf', 'locale'),
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
USE_L10N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
USE_TZ = True
# END GENERAL CONFIGURATION
# MEDIA CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = normpath(join(SITE_ROOT, 'media'))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = '/media/'
# END MEDIA CONFIGURATION
# STATIC FILE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = normpath(join(SITE_ROOT, 'assets'))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = '/static/'
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = (
normpath(join(DJANGO_ROOT, 'static', 'build')), # Check the r.js output directory first
normpath(join(DJANGO_ROOT, 'static')),
)
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
# ThemeFilesFinder looks for static assets inside theme directories. It presents static assets according to the
# current theme. More details on ThemeFilesFinder can be seen at /ecommerce/theming/__init__.py
STATICFILES_FINDERS = (
'ecommerce.theming.finders.ThemeFilesFinder',
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
)
# ThemeStorage stores and retrieves files with theming in mind.
# More details on ThemeStorage can be seen at /ecommerce/theming/__init__.py
STATICFILES_STORAGE = "ecommerce.theming.storage.ThemeStorage"
COMPRESS_PRECOMPILERS = (
('text/x-scss', 'django_libsass.SassCompiler'),
)
# Note: COMPRESS_CSS_FILTERS has been replaced with COMPRESS_FILTERS in django-compressor,
# but replacing the settings name gives an error during compression in github test-python build check
# See info here: https://github.com/django-compressor/django-compressor/issues/985
COMPRESS_CSS_FILTERS = ['compressor.filters.css_default.CssAbsoluteFilter']
COMPRESS_OFFLINE_CONTEXT = 'ecommerce.theming.compressor.offline_context'
# END STATIC FILE CONFIGURATION
# SECRET CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
# Note: This key should only be used for development and testing.
SECRET_KEY = os.environ.get('ECOMMERCE_SECRET_KEY', 'insecure-secret-key')
# END SECRET CONFIGURATION
# SITE CONFIGURATION
# Hosts/domain names that are valid for this site
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = []
# END SITE CONFIGURATION
# FIXTURE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
FIXTURE_DIRS = (
normpath(join(SITE_ROOT, 'fixtures')),
)
# END FIXTURE CONFIGURATION
# TEMPLATE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': (
normpath(join(DJANGO_ROOT, 'templates')),
),
'OPTIONS': {
'loaders': [
# ThemeTemplateLoader should come before any other loader to give theme templates
# priority over system templates
'ecommerce.theming.template_loaders.ThemeTemplateLoader',
'django.template.loaders.app_directories.Loader',
],
'context_processors': (
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.request',
'oscar.apps.search.context_processors.search_form',
'oscar.apps.checkout.context_processors.checkout',
'oscar.apps.communication.notifications.context_processors.notifications',
'oscar.core.context_processors.metadata',
'ecommerce.core.context_processors.core',
'ecommerce.extensions.analytics.context_processors.analytics',
),
'debug': True, # Django will only display debug pages if the global DEBUG setting is set to True.
}
},
]
# END TEMPLATE CONFIGURATION
# MIDDLEWARE CONFIGURATION
# See: https://docs.djangoproject.com/en/1.11/ref/settings/#middleware
MIDDLEWARE = (
'corsheaders.middleware.CorsMiddleware',
'edx_django_utils.monitoring.DeploymentMonitoringMiddleware',
'edx_django_utils.cache.middleware.RequestCacheMiddleware',
'edx_django_utils.monitoring.CachedCustomMonitoringMiddleware',
'edx_django_utils.monitoring.CookieMonitoringMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'edx_rest_framework_extensions.auth.jwt.middleware.JwtRedirectToLoginIfUnauthenticatedMiddleware',
'edx_rest_framework_extensions.auth.jwt.middleware.JwtAuthCookieMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.sites.middleware.CurrentSiteMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'waffle.middleware.WaffleMiddleware',
'ecommerce.extensions.analytics.middleware.TrackingMiddleware',
# NOTE: The overridden BasketMiddleware relies on request.site. This middleware
# MUST appear AFTER CurrentSiteMiddleware.
'ecommerce.extensions.basket.middleware.BasketMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
'simple_history.middleware.HistoryRequestMiddleware',
'threadlocals.middleware.ThreadLocalMiddleware',
'ecommerce.theming.middleware.CurrentSiteThemeMiddleware',
'ecommerce.theming.middleware.ThemePreviewMiddleware',
'edx_django_utils.cache.middleware.TieredCacheMiddleware',
'edx_rest_framework_extensions.middleware.RequestMetricsMiddleware',
'edx_rest_framework_extensions.auth.jwt.middleware.EnsureJWTAuthSettingsMiddleware',
'crum.CurrentRequestUserMiddleware',
)
# END MIDDLEWARE CONFIGURATION
# URL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
ROOT_URLCONF = '{}.urls'.format(SITE_NAME)
# Commerce API settings used for publishing information to LMS.
COMMERCE_API_TIMEOUT = 7
# Cache course info from course API.
COURSES_API_CACHE_TIMEOUT = 3600 # Value is in seconds
PROGRAM_CACHE_TIMEOUT = 3600 # Value is in seconds.
# Cache catalog results from the enterprise and discovery service.
CATALOG_RESULTS_CACHE_TIMEOUT = 86400
# Cache timeout for enterprise customer results from the enterprise service.
ENTERPRISE_CUSTOMER_RESULTS_CACHE_TIMEOUT = 3600 # Value is in seconds
# PROVIDER DATA PROCESSING
PROVIDER_DATA_PROCESSING_TIMEOUT = 15 # Value is in seconds.
CREDIT_PROVIDER_CACHE_TIMEOUT = 600
# Anonymous User Calculate Cache timeout
ANONYMOUS_BASKET_CALCULATE_CACHE_TIMEOUT = 3600 # Value is in seconds.
# LMS API settings used for fetching information from LMS
LMS_API_CACHE_TIMEOUT = 30 # Value is in seconds.
# Add here custom payment processor urls. For instance:
# EXTRA_PAYMENT_PROCESSOR_URLS = {
# "mycustompaymentprocessor": "ecommerce.payment.processors.mycustompaymentprocessor.urls"
# }
EXTRA_PAYMENT_PROCESSOR_URLS = {}
# END URL CONFIGURATION
VOUCHER_CACHE_TIMEOUT = 10 # Value is in seconds.
SDN_CHECK_REQUEST_TIMEOUT = 5 # Value is in seconds.
# APP CONFIGURATION
DJANGO_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.flatpages',
'django.contrib.humanize',
'django.contrib.messages',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'widget_tweaks',
'compressor',
'rest_framework',
'waffle',
'django_filters',
'release_util',
'crispy_forms',
'solo',
'social_django',
'drf_yasg',
'rest_framework_datatables',
'django_sites_extensions',
# edx-drf-extensions
'csrf.apps.CsrfAppConfig', # Enables frontend apps to retrieve CSRF tokens.
'rules.apps.AutodiscoverRulesConfig',
'xss_utils',
'edx_django_utils.user',
]
# Apps specific to this project go here.
LOCAL_APPS = [
'ecommerce.core',
'ecommerce.coupons',
'ecommerce.courses',
'ecommerce.invoice',
'ecommerce.bff',
'ecommerce.programs',
'ecommerce.referrals',
'ecommerce.theming',
'ecommerce.sailthru',
'ecommerce.enterprise',
'ecommerce.management',
]
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + LOCAL_APPS + OSCAR_APPS
# END APP CONFIGURATION
# LOGGING CONFIGURATION
# Set up logging for development use (logging to stdout)
level = 'DEBUG' if DEBUG else 'INFO'
hostname = platform.node().split(".")[0]
# Use a different address for Mac OS X
syslog_address = '/var/run/syslog' if platform.system().lower() == 'darwin' else '/dev/log'
syslog_format = '[service_variant=ecommerce][%(name)s] %(levelname)s [{hostname} %(process)d] ' \
'[%(pathname)s:%(lineno)d] - %(message)s'.format(hostname=hostname)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(asctime)s %(levelname)s %(process)d [%(name)s] %(pathname)s:%(lineno)d - %(message)s',
},
'syslog_format': {'format': syslog_format},
},
'handlers': {
'console': {
'level': level,
'class': 'logging.StreamHandler',
'formatter': 'standard',
'stream': 'ext://sys.stdout',
},
'local': {
'level': level,
'class': 'logging.handlers.SysLogHandler',
'address': syslog_address,
'formatter': 'syslog_format',
'facility': SysLogHandler.LOG_LOCAL0,
},
},
'loggers': {
'django': {
'handlers': ['console', 'local'],
'propagate': True,
'level': 'INFO'
},
'requests': {
'handlers': ['console', 'local'],
'propagate': True,
'level': 'WARNING'
},
'factory': {
'handlers': ['console', 'local'],
'propagate': True,
'level': 'WARNING'
},
'elasticsearch': {
'handlers': ['console', 'local'],
'propagate': True,
'level': 'WARNING'
},
'urllib3': {
'handlers': ['console', 'local'],
'propagate': True,
'level': 'WARNING'
},
'django.request': {
'handlers': ['console', 'local'],
'propagate': True,
'level': 'WARNING'
},
'rules': {
'handlers': ['console', 'local'],
'level': 'DEBUG',
'propagate': True,
},
'': {
'handlers': ['console', 'local'],
'level': 'DEBUG',
'propagate': False
},
}
}
LOGGING_ROOT_OVERRIDES = {}
LOGGING_SUBSECTION_OVERRIDES = {}
# END LOGGING CONFIGURATION
# WSGI CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
WSGI_APPLICATION = 'wsgi.application'
# END WSGI CONFIGURATION
# AUTHENTICATION
# Overrides user model used by Oscar. Oscar's default user model doesn't
# include a username field, instead using email addresses to uniquely identify
# users. In order to pair with the LMS, we need our users to have usernames,
# and since we don't need Oscar's custom logic for transferring user notifications,
# we can rely on a user model which subclasses Django's AbstractUser.
AUTH_USER_MODEL = 'core.User'
# See: http://getblimp.github.io/django-rest-framework-jwt/#additional-settings
JWT_AUTH = {
'JWT_SECRET_KEY': 'SET-ME-PLEASE',
'JWT_ALGORITHM': 'HS256',
'JWT_AUTH_COOKIE': 'edx-jwt-cookie',
'JWT_VERIFY_EXPIRATION': True,
'JWT_LEEWAY': 1,
'JWT_DECODE_HANDLER': 'ecommerce.extensions.api.handlers.jwt_decode_handler',
# These settings are NOT part of DRF-JWT's defaults.
'JWT_ISSUERS': [
{
'AUDIENCE': 'SET-ME-PLEASE',
'ISSUER': 'http://127.0.0.1:8000/oauth2',
'SECRET_KEY': 'SET-ME-PLEASE'
},
{
'AUDIENCE': 'SET-ME-PLEASE',
'ISSUER': 'ecommerce_worker',
'SECRET_KEY': 'SET-ME-PLEASE'
}
],
# NOTE (CCB): This is temporarily set to False until we decide what values are acceptable.
'JWT_VERIFY_AUDIENCE': False,
'JWT_PUBLIC_SIGNING_JWK_SET': None,
'JWT_AUTH_COOKIE_HEADER_PAYLOAD': 'edx-jwt-cookie-header-payload',
'JWT_AUTH_COOKIE_SIGNATURE': 'edx-jwt-cookie-signature',
'JWT_AUTH_HEADER_PREFIX': 'JWT',
}
# Service user for worker processes.
ECOMMERCE_SERVICE_WORKER_USERNAME = 'ecommerce_worker'
# Worker user used by prospectus to query ecommerce
PROSPECTUS_WORKER_USERNAME = 'prospectus_worker'
# Worker used by Discovery to consume ecommerce endpoints
DISCOVERY_WORKER_USERNAME = 'discovery_worker'
# Used to access the Enrollment API. Set this to the same value used by the LMS.
EDX_API_KEY = 'PUT_YOUR_API_KEY_HERE'
# Enables a special view that, when accessed, creates and logs in a new user.
# This should NOT be enabled for production deployments.
ENABLE_AUTO_AUTH = False
# Prefix for auto auth usernames. This value must be set in order for auto-auth to function.
# If it were not set, we would be unable to automatically remove all auto-auth users.
AUTO_AUTH_USERNAME_PREFIX = 'AUTO_AUTH_'
AUTHENTICATION_BACKENDS = ('auth_backends.backends.EdXOAuth2',) + AUTHENTICATION_BACKENDS
SOCIAL_AUTH_STRATEGY = 'ecommerce.social_auth.strategies.CurrentSiteDjangoStrategy'
# Set these to the correct values for your OAuth2 provider
SOCIAL_AUTH_EDX_OAUTH2_KEY = "ecommerce-sso-key"
SOCIAL_AUTH_EDX_OAUTH2_SECRET = "ecommerce-sso-secret"
SOCIAL_AUTH_EDX_OAUTH2_ISSUER = "http://127.0.0.1:8000"
SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT = "http://127.0.0.1:8000"
SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL = "http://127.0.0.1:8000/logout"
# Redirect successfully authenticated users to the Oscar dashboard.
LOGIN_REDIRECT_URL = 'dashboard:index'
LOGIN_URL = 'login'
EXTRA_SCOPE = ['permissions']
# END AUTHENTICATION
# DJANGO REST FRAMEWORK
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication',
'ecommerce.extensions.api.authentication.BearerAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
'DEFAULT_PAGINATION_CLASS': 'ecommerce.extensions.api.pagination.PageNumberPagination',
'PAGE_SIZE': 20,
'DEFAULT_THROTTLE_CLASSES': (
'rest_framework.throttling.UserRateThrottle',
),
'DEFAULT_THROTTLE_RATES': {
'user': '75/minute',
},
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
'TEST_REQUEST_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
),
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'rest_framework_datatables.renderers.DatatablesRenderer',
'rest_framework_csv.renderers.CSVRenderer',
),
'DEFAULT_FILTER_BACKENDS': (
'rest_framework_datatables.filters.DatatablesFilterBackend',
),
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}
# END DJANGO REST FRAMEWORK
# Resolving deprecation warning
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
# COOKIE CONFIGURATION
# The purpose of customizing the cookie names is to avoid conflicts when
# multiple Django services are running behind the same hostname.
# Detailed information at: https://docs.djangoproject.com/en/dev/ref/settings/
SESSION_COOKIE_NAME = 'ecommerce_sessionid'
CSRF_COOKIE_NAME = 'ecommerce_csrftoken'
CSRF_COOKIE_SECURE = False
LANGUAGE_COOKIE_NAME = 'openedx-language-preference'
SESSION_COOKIE_SECURE = False
# END COOKIE CONFIGURATION
# CELERY
# Default broker URL. See http://celery.readthedocs.io/en/latest/userguide/configuration.html#broker-url.
# In order for tasks to be visible to the ecommerce worker, this must match the value of BROKER_URL
# configured for the ecommerce worker!
BROKER_URL = 'redis://:celery@127.0.0.1:6379'
# Disable connection pooling. Connections may be severed by load balancers.
# This forces the application to connect explicitly to the broker each time
# rather than assume a long-lived connection.
BROKER_POOL_LIMIT = 0
BROKER_CONNECTION_TIMEOUT = 1
# Use heartbeats to prevent broker connection loss. When the broker
# is behind a load balancer, the load balancer may timeout Celery's
# connection to the broker, causing messages to be lost.
BROKER_HEARTBEAT = 10.0
BROKER_HEARTBEAT_CHECKRATE = 2
# A sequence of modules to import when the worker starts.
# See http://celery.readthedocs.io/en/latest/userguide/configuration.html#imports.
CELERY_IMPORTS = (
'ecommerce_worker.fulfillment.v1.tasks',
)
DEFAULT_PRIORITY_QUEUE = 'ecommerce.default'
CELERY_DEFAULT_EXCHANGE = 'ecommerce'
CELERY_DEFAULT_ROUTING_KEY = 'ecommerce'
CELERY_DEFAULT_QUEUE = DEFAULT_PRIORITY_QUEUE
CELERY_ROUTES = {
'ecommerce_worker.email.v1.tasks.send_api_triggered_offer_usage_email': {'queue': 'ecommerce.email_marketing'},
'ecommerce_worker.email.v1.tasks.send_offer_assignment_email': {'queue': 'ecommerce.email_marketing'},
'ecommerce_worker.email.v1.tasks.send_offer_update_email': {'queue': 'ecommerce.email_marketing'},
'ecommerce_worker.email.v1.tasks.send_offer_usage_email': {'queue': 'ecommerce.email_marketing'},
'ecommerce_worker.email.v1.tasks.send_code_assignment_nudge_email': {'queue': 'ecommerce.email_marketing'},
'ecommerce_worker.fulfillment.v1.tasks.fulfill_order': {'queue': 'ecommerce.fulfillment'},
}
# Prevent Celery from removing handlers on the root logger. Allows setting custom logging handlers.
# See http://celery.readthedocs.io/en/latest/userguide/configuration.html#worker-hijack-root-logger.
CELERYD_HIJACK_ROOT_LOGGER = False
# Execute tasks locally (synchronously) instead of sending them to the queue.
# See http://celery.readthedocs.io/en/latest/userguide/configuration.html#task-always-eager.
CELERY_ALWAYS_EAGER = False
# Specify allowed serializers that are consistent with Celery 3 defaults
CELERY_TASK_SERIALIZER = 'pickle'
CELERY_RESULT_SERIALIZER = 'pickle'
CELERY_EVENT_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['json', 'pickle', 'yaml']
# END CELERY
THEME_SCSS = 'sass/themes/default.scss'
# URL for Discovery Service
COURSE_CATALOG_API_URL = 'http://localhost:8008/api/v1/'
# Black-listed course modes not allowed to create coupons with
BLACK_LIST_COUPON_COURSE_MODES = [u'audit', u'honor']
# Theme settings
# enable or disable comprehensive theming
ENABLE_COMPREHENSIVE_THEMING = True
# name for waffle switch to use for disabling theming on runtime.
# Note: management command ignore this switch
DISABLE_THEMING_ON_RUNTIME_SWITCH = "disable_theming_on_runtime"
# Directory that contains all themes
COMPREHENSIVE_THEME_DIRS = [
DJANGO_ROOT + "/themes",
]
# Theme to use when no site or site theme is defined,
# set to None if you want to use openedx theme
DEFAULT_SITE_THEME = None
# Cache time out for theme templates and related assets
THEME_CACHE_TIMEOUT = 30 * 60
# End Theme settings
EDX_DRF_EXTENSIONS = {
'JWT_PAYLOAD_USER_ATTRIBUTE_MAPPING': {
'administrator': 'is_staff',
'email': 'email',
'full_name': 'full_name',
'tracking_context': 'tracking_context',
'user_id': 'lms_user_id',
},
'JWT_PAYLOAD_MERGEABLE_USER_ATTRIBUTES': (
'tracking_context',
),
'OAUTH2_USER_INFO_URL': 'http://127.0.0.1:8000/oauth2/user_info',
'ENABLE_SET_REQUEST_USER_FOR_JWT_COOKIE': True,
}
# Enrollment codes voucher end datetime used for setting the end dates for vouchers
# created for the Enrollment code products.
ENROLLMENT_CODE_EXIPRATION_DATE = datetime.datetime.now() + datetime.timedelta(weeks=520)
ENROLLMENT_FULFILLMENT_TIMEOUT = 7
# Affiliate cookie key
AFFILIATE_COOKIE_KEY = 'affiliate_id'
CRISPY_TEMPLATE_PACK = 'bootstrap3'
# ENTERPRISE CONFIGURATION
# URL for Enterprise service
ENTERPRISE_SERVICE_URL = 'http://localhost:8000/enterprise/'
# Cache enterprise response from Enterprise API.
ENTERPRISE_API_CACHE_TIMEOUT = 300 # Value is in seconds
ENTERPRISE_CATALOG_SERVICE_URL = 'http://enterprise.catalog.app:18160/'
ENTERPRISE_ANALYTICS_API_URL = 'http://localhost:19001'
ENTERPRISE_LEARNER_PORTAL_HOSTNAME = os.environ.get('ENTERPRISE_LEARNER_PORTAL_HOSTNAME', 'localhost:8734')
# Name for waffle switch to use for enabling enterprise features on runtime.
ENABLE_ENTERPRISE_ON_RUNTIME_SWITCH = 'enable_enterprise_on_runtime'
ENTERPRISE_CUSTOMER_COOKIE_NAME = 'enterprise_customer_uuid'
ENTERPRISE_DATA_API_GROUP = 'enterprise_data_api_access'
SYSTEM_TO_FEATURE_ROLE_MAPPING = {
SYSTEM_ENTERPRISE_ADMIN_ROLE: [
ENTERPRISE_COUPON_ADMIN_ROLE,
ENTERPRISE_COUPON_LEARNER_ROLE,
ENTERPRISE_OFFER_ADMIN_ROLE,
ENTERPRISE_OFFER_LEARNER_ROLE,
],
SYSTEM_ENTERPRISE_OPERATOR_ROLE: [
ENTERPRISE_COUPON_ADMIN_ROLE,
ENTERPRISE_COUPON_LEARNER_ROLE,
ENTERPRISE_OFFER_ADMIN_ROLE,
ENTERPRISE_OFFER_LEARNER_ROLE,
],
STUDENT_SUPPORT_ADMIN_ROLE: [ORDER_MANAGER_ROLE],
SYSTEM_ENTERPRISE_LEARNER_ROLE: [
ENTERPRISE_COUPON_LEARNER_ROLE,
ENTERPRISE_OFFER_LEARNER_ROLE,
]
}
# END ENTERPRISE CONFIGURATION
# DJANGO DEBUG TOOLBAR CONFIGURATION
# http://django-debug-toolbar.readthedocs.org/en/latest/installation.html
if os.environ.get('ENABLE_DJANGO_TOOLBAR', False):
INSTALLED_APPS += [
'debug_toolbar',
]
MIDDLEWARE += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
# Determines if events are actually sent to Segment. This should only be set to False for testing purposes.
SEND_SEGMENT_EVENTS = True
NEW_CODES_EMAIL_CONFIG = {
'email_subject': 'New edX codes available',
'from_email': 'customersuccess@edx.org',
'email_body': '''
Hello,
This message is to inform you that a new order has been processed for your organization. Please visit the
following page, in your Admin Dashboard, to find new codes ready for use.
https://portal.edx.org/{enterprise_slug}/admin/coupons
Having trouble accessing your codes? Please contact edX Enterprise Support at customersuccess@edx.org.
Thank you.
'''
}
OFFER_ASSIGNMENT_EMAIL_TEMPLATE = '''
You may redeem this code for {REDEMPTIONS_REMAINING} course(s).
edX Login: {USER_EMAIL}
Access Code: {CODE}
Code Expiration Date: {EXPIRATION_DATE}
'''
OFFER_REVOKE_EMAIL_TEMPLATE = '''
Your Learning Manager has revoked access code {CODE} and it is no longer assigned to your edX account {USER_EMAIL}.
'''
OFFER_REMINDER_EMAIL_TEMPLATE = '''
You have redeemed this code {REDEEMED_OFFER_COUNT} time(s) out of {TOTAL_OFFER_COUNT} available course redemptions.
edX Login: {USER_EMAIL}
Access Code: {CODE}
Code Expiration Date: {EXPIRATION_DATE}
'''
OFFER_ASSIGNMEN_EMAIL_TEMPLATE_BODY_MAP = {
'assign': OFFER_ASSIGNMENT_EMAIL_TEMPLATE,
'revoke': OFFER_REVOKE_EMAIL_TEMPLATE,
'remind': OFFER_REMINDER_EMAIL_TEMPLATE,
}
USERNAME_REPLACEMENT_WORKER = "replace with valid username"
CORS_ALLOW_CREDENTIALS = False
ECOMMERCE_URL_ROOT = "http://localhost:8002"
OSCAR_FROM_EMAIL = 'oscar@example.com'
OSCAR_SLUG_ALLOW_UNICODE = True
PLATFORM_NAME = 'Your Platform Name Here'
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SOCIAL_AUTH_REDIRECT_IS_HTTPS = False
CORS_ORIGIN_WHITELIST = []
CORS_URLS_REGEX = ''
ECOMMERCE_PAYMENT_PROCESSOR_CONFIG = {
'edx': {
'cybersource': {
'apple_pay_country_code': 'US',
'apple_pay_merchant_id_certificate_path': '/edx/etc/ssl/apple_pay_merchant.pem',
'apple_pay_merchant_id_domain_association': 'This value should also be in private configuration. '
'It, too,\nwill span multiple lines.',
'apple_pay_merchant_identifier': 'merchant.com.example',
'cancel_page_url': '/checkout/cancel-checkout/',
'merchant_id': 'SET-ME-PLEASE',
'receipt_page_url': '/checkout/receipt/',
'send_level_2_3_details': True,
'soap_api_url': 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/'
'CyberSourceTransaction_1.140.wsdl',
'transaction_key': 'SET-ME-PLEASE',
'flex_shared_secret_key_id': 'SET-ME-PLEASE',
'flex_shared_secret_key': 'SET-ME-PLEASE',
},
'cybersource-rest': {
'apple_pay_country_code': 'US',
'apple_pay_merchant_id_certificate_path': '/edx/etc/ssl/apple_pay_merchant.pem',
'apple_pay_merchant_id_domain_association': 'This value should also be in private configuration. '
'It, too,\nwill span multiple lines.',
'apple_pay_merchant_identifier': 'merchant.com.example',
'cancel_page_url': '/checkout/cancel-checkout/',
'merchant_id': 'SET-ME-PLEASE',
'receipt_page_url': '/checkout/receipt/',
'send_level_2_3_details': True,
'transaction_key': 'SET-ME-PLEASE',
'flex_shared_secret_key_id': 'SET-ME-PLEASE',
'flex_shared_secret_key': 'SET-ME-PLEASE',
},
'paypal': {
'cancel_checkout_path': '/checkout/cancel-checkout/',
'client_id': 'SET-ME-PLEASE',
'client_secret': 'SET-ME-PLEASE',
'error_url': '/checkout/error/',
'mode': 'sandbox',
'receipt_url': '/checkout/receipt/'
},
'android-iap': {
'google_bundle_id': 'org.edx.mobile',
'google_service_account_key_file': 'SET-ME-PLEASE'
},
'ios-iap': {
'ios_bundle_id': 'org.edx.mobile',
},
'stripe': {
'api_version': '2022-08-01; server_side_confirmation_beta=v1',
'enable_telemetry': None,
'log_level': None,
'max_network_retries': 0,
'proxy': None,
'publishable_key': 'SET-ME-PLEASE',
'secret_key': 'SET-ME-PLEASE',
'webhook_endpoint_secret': 'SET-ME-PLEASE',
'receipt_url': '/checkout/receipt/',
},
}
}
MEDIA_STORAGE_BACKEND = {
'DEFAULT_FILE_STORAGE': 'django.core.files.storage.FileSystemStorage',
'MEDIA_ROOT': MEDIA_ROOT,
'MEDIA_URL': MEDIA_URL
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
BACKEND_SERVICE_EDX_OAUTH2_KEY = "ecommerce-backend-service-key"
BACKEND_SERVICE_EDX_OAUTH2_SECRET = "ecommerce-backend-service-secret"
BACKEND_SERVICE_EDX_OAUTH2_PROVIDER_URL = "http://127.0.0.1:8000/oauth2"
EXTRA_APPS = []
API_ROOT = None
ECOMMERCE_MICROFRONTEND_URL = os.environ.get('ECOMMERCE_MICROFRONTEND_URL')
# Needed to link to the payment micro-frontend
PAYMENT_MICROFRONTEND_URL = None
# For Enterprise purchases to send purchase information to HubSpot for marketing leads
HUBSPOT_FORMS_API_URI = "SET-ME-PLEASE"
HUBSPOT_PORTAL_ID = "SET-ME-PLEASE"
HUBSPOT_SALES_LEAD_FORM_GUID = "SET-ME-PLEASE"
# To check government purchase restriction lists
SDN_CHECK_API_URL = "https://data.trade.gov/consolidated_screening_list/v1/search"
SDN_CHECK_API_KEY = "sdn search key here"
# Awin advertiser id
AWIN_ADVERTISER_ID = None
################# Settings for brand logos. #################
LOGO_URL = None
FAVICON_URL = None
# s3 files for email-template, code management credentials
ENTERPRISE_EMAIL_FILE_ATTACHMENTS_BUCKET_NAME = ''
ENTERPRISE_EMAIL_FILE_ATTACHMENTS_BUCKET_LOCATION = 'us-east-1' # change this when developing with your own bucket
BRAZE_OFFER_DIGEST_CAMPAIGN = ''
BRAZE_OFFER_LOW_BALANCE_CAMPAIGN = ''
BRAZE_OFFER_NO_BALANCE_CAMPAIGN = ''
CAMPAIGN_IDS_BY_EMAIL_TYPE = {
OfferUsageEmailTypes.DIGEST: BRAZE_OFFER_DIGEST_CAMPAIGN,
OfferUsageEmailTypes.LOW_BALANCE: BRAZE_OFFER_LOW_BALANCE_CAMPAIGN,
OfferUsageEmailTypes.OUT_OF_BALANCE: BRAZE_OFFER_NO_BALANCE_CAMPAIGN
}