* Install `organizations` app into LMS and Studio non-optionally. * Add toggle `ORGANIZATIONS_AUTOCREATE` to Studio. * Remove the `FEATURES["ORGANIZATIONS_APP"]` toggle. * Use the new `organizations.api.ensure_organization` function to either validate or get-or-create organizations, depending on the value of `ORGANIZATIONS_AUTOCREATE`, when creating course runs and V2 content libraries. We'll soon use it for V1 content libraries as well. * Remove the `util.organizations_helpers` wrapper layer that had to exist because `organizations` was an optional app. * Add `.get_library_keys()` method to the Split modulestore. * Add Studio management command for backfilling organizations tables (`backfill_orgs_and_org_courses`). For full details, see https://github.com/edx/edx-organizations/blob/master/docs/decisions/0001-phase-in-db-backed-organizations-to-all.rst TNL-7646
26 lines
916 B
Python
26 lines
916 B
Python
"""Organizations views for use with Studio."""
|
|
|
|
|
|
from django.contrib.auth.decorators import login_required
|
|
from django.http import HttpResponse
|
|
from django.utils.decorators import method_decorator
|
|
from django.views.generic import View
|
|
from organizations.api import get_organizations
|
|
|
|
from openedx.core.djangolib.js_utils import dump_js_escaped_json
|
|
|
|
|
|
class OrganizationListView(View):
|
|
"""View rendering organization list as json.
|
|
|
|
This view renders organization list json which is used in org
|
|
autocomplete while creating new course.
|
|
"""
|
|
|
|
@method_decorator(login_required)
|
|
def get(self, request, *args, **kwargs):
|
|
"""Returns organization list as json."""
|
|
organizations = get_organizations()
|
|
org_names_list = [(org["short_name"]) for org in organizations]
|
|
return HttpResponse(dump_js_escaped_json(org_names_list), content_type='application/json; charset=utf-8')
|