77
88from os .path import abspath , dirname , join
99
10+ from edx_django_utils .plugins .plugin_apps import get_plugin_apps
11+ from edx_django_utils .plugins .plugin_settings import add_plugins
12+
1013
1114def root (* args ):
1215 """
@@ -16,70 +19,103 @@ def root(*args):
1619
1720
1821DATABASES = {
19- ' default' : {
20- ' ENGINE' : ' django.db.backends.sqlite3' ,
21- ' NAME' : ' default.db' ,
22- ' USER' : '' ,
23- ' PASSWORD' : '' ,
24- ' HOST' : '' ,
25- ' PORT' : '' ,
22+ " default" : {
23+ " ENGINE" : " django.db.backends.sqlite3" ,
24+ " NAME" : " default.db" ,
25+ " USER" : "" ,
26+ " PASSWORD" : "" ,
27+ " HOST" : "" ,
28+ " PORT" : "" ,
2629 }
2730}
2831
29- INSTALLED_APPS = (
30- 'django.contrib.admin' ,
31- 'django.contrib.auth' ,
32- 'django.contrib.contenttypes' ,
33- 'django.contrib.messages' ,
34- 'django.contrib.sessions' ,
35- 'rest_framework' ,
36- 'django_filters' ,
37- 'sample_plugin' ,
38- )
32+ # Plugin Settings
33+ ENABLE_PLUGINS = True
34+ # Define both contexts for reference, but we'll only use one for testing
35+ PLUGIN_CONTEXTS = ["lms.djangoapp" , "cms.djangoapp" ]
36+ # We only use the LMS context for testing as the plugin is configured similarly for both
37+ # Could use CMS context instead by changing the index to 1
38+
39+ # Base INSTALLED_APPS before plugin discovery
40+ INSTALLED_APPS = [
41+ "django.contrib.admin" ,
42+ "django.contrib.auth" ,
43+ "django.contrib.contenttypes" ,
44+ "django.contrib.messages" ,
45+ "django.contrib.sessions" ,
46+ "rest_framework" ,
47+ "django_filters" ,
48+ "edx_django_utils.plugins" ,
49+ "django_extensions" ,
50+ ]
51+
52+ # Dynamically add plugin apps - only using the LMS context for simplicity
53+ plugin_apps = get_plugin_apps (PLUGIN_CONTEXTS [0 ])
54+ INSTALLED_APPS .extend (plugin_apps )
3955
4056LOCALE_PATHS = [
41- root (' sample_plugin' , ' conf' , ' locale' ),
57+ root (" sample_plugin" , " conf" , " locale" ),
4258]
4359
44- ROOT_URLCONF = 'sample_plugin .urls'
60+ ROOT_URLCONF = "tests .urls"
4561
46- SECRET_KEY = ' insecure-secret-key'
62+ SECRET_KEY = " insecure-secret-key"
4763
4864MIDDLEWARE = (
49- ' django.contrib.sessions.middleware.SessionMiddleware' ,
50- ' django.contrib.auth.middleware.AuthenticationMiddleware' ,
51- ' django.contrib.messages.middleware.MessageMiddleware' ,
65+ " django.contrib.sessions.middleware.SessionMiddleware" ,
66+ " django.contrib.auth.middleware.AuthenticationMiddleware" ,
67+ " django.contrib.messages.middleware.MessageMiddleware" ,
5268)
5369
54- TEMPLATES = [{
55- 'BACKEND' : 'django.template.backends.django.DjangoTemplates' ,
56- 'APP_DIRS' : False ,
57- 'OPTIONS' : {
58- 'context_processors' : [
59- 'django.contrib.auth.context_processors.auth' , # this is required for admin
60- 'django.template.context_processors.request' , # this is also required for admin navigation sidebar
61- 'django.contrib.messages.context_processors.messages' , # this is required for admin
62- ],
63- },
64- }]
70+ TEMPLATES = [
71+ {
72+ "BACKEND" : "django.template.backends.django.DjangoTemplates" ,
73+ "APP_DIRS" : False ,
74+ "OPTIONS" : {
75+ "context_processors" : [
76+ "django.contrib.auth.context_processors.auth" , # this is required for admin
77+ "django.template.context_processors.request" , # this is also required for admin navigation sidebar
78+ "django.contrib.messages.context_processors.messages" , # this is required for admin
79+ ],
80+ },
81+ }
82+ ]
6583
6684REST_FRAMEWORK = {
67- ' DEFAULT_PERMISSION_CLASSES' : [
68- ' rest_framework.permissions.IsAuthenticated' ,
85+ " DEFAULT_PERMISSION_CLASSES" : [
86+ " rest_framework.permissions.IsAuthenticated" ,
6987 ],
70- ' DEFAULT_AUTHENTICATION_CLASSES' : [
71- ' rest_framework.authentication.SessionAuthentication' ,
88+ " DEFAULT_AUTHENTICATION_CLASSES" : [
89+ " rest_framework.authentication.SessionAuthentication" ,
7290 ],
73- ' DEFAULT_FILTER_BACKENDS' : [
74- ' django_filters.rest_framework.DjangoFilterBackend' ,
75- ' rest_framework.filters.OrderingFilter' ,
91+ " DEFAULT_FILTER_BACKENDS" : [
92+ " django_filters.rest_framework.DjangoFilterBackend" ,
93+ " rest_framework.filters.OrderingFilter" ,
7694 ],
77- ' DEFAULT_THROTTLE_CLASSES' : [
78- ' rest_framework.throttling.AnonRateThrottle' ,
79- ' rest_framework.throttling.UserRateThrottle' ,
95+ " DEFAULT_THROTTLE_CLASSES" : [
96+ " rest_framework.throttling.AnonRateThrottle" ,
97+ " rest_framework.throttling.UserRateThrottle" ,
8098 ],
81- 'DEFAULT_THROTTLE_RATES' : {
82- 'anon' : '20/hour' ,
83- 'user' : '100/hour' ,
99+ "DEFAULT_THROTTLE_RATES" : {
100+ "anon" : "20/hour" ,
101+ "user" : "100/hour" ,
102+ },
103+ }
104+
105+ LOGGING = {
106+ "version" : 1 ,
107+ "disable_existing_loggers" : False ,
108+ "handlers" : {
109+ "console" : {
110+ "class" : "logging.StreamHandler" ,
111+ },
112+ },
113+ "root" : {
114+ "handlers" : ["console" ],
115+ "level" : "DEBUG" ,
84116 },
85117}
118+ # Apply plugin settings - must be done after base settings are defined
119+ # Only using the LMS context for simplicity
120+ # Third parameter is the settings_type which should match the keys in settings_config
121+ add_plugins (__name__ , PLUGIN_CONTEXTS [0 ], "test" )
0 commit comments