Files
edx-platform/cms/djangoapps/contentstore/views/organization.py
Feanil Patel 9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00

26 lines
925 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 openedx.core.djangolib.js_utils import dump_js_escaped_json
from util.organizations_helpers import get_organizations
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')