forked from edx/devstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlms.py
More file actions
36 lines (28 loc) · 1.06 KB
/
lms.py
File metadata and controls
36 lines (28 loc) · 1.06 KB
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
#!/usr/bin/env python
# Run like so:
# ./manage.py lms shell -c "`cat lms.py`"
from django.contrib.sites.models import Site
from openedx.core.djangoapps.catalog.models import CatalogIntegration
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
from openedx.core.djangoapps.site_configuration.models import SiteConfiguration
DISCOVERY_API_URL = 'http://edx.devstack.discovery:18381/api/v1/'
def set_current_config(cls, args):
if not cls.equal_to_current(args):
config = cls(**args)
config.save()
# Enable the program dashboard
set_current_config(ProgramsApiConfig, {'enabled': True})
# Enable the discovery worker
set_current_config(CatalogIntegration, {
'enabled': True,
'internal_api_url': 'https://example.com/api', # required but unused
'service_username': 'discovery_worker',
})
# Tell LMS about discovery
SiteConfiguration.objects.update_or_create(
site=Site.objects.get(domain='example.com'),
defaults={
'enabled': True,
'site_values': {'COURSE_CATALOG_API_URL': DISCOVERY_API_URL},
},
)