Skip to content

Commit

Permalink
Merge branch 'master' into chris/advanced-editors-iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV authored Jan 16, 2025
2 parents 9f86ddc + 8aeaaf4 commit 1422fde
Show file tree
Hide file tree
Showing 57 changed files with 699 additions and 3,039 deletions.
152 changes: 0 additions & 152 deletions .dockerignore

This file was deleted.

File renamed without changes.
14 changes: 6 additions & 8 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,13 @@ jobs:
run: |
sudo apt-get update && sudo apt-get install libmysqlclient-dev libxmlsec1-dev lynx
# Try to log into DockerHub so that we're less likely to be rate-limited when pulling certain images.
# This will fail on any edx-platform fork which doesn't explicitly define its own DockerHub creds.
# That's OK--if we fail to log in, we'll proceed anonymously, and hope we don't get rate-limited.
- name: Try to log into Docker Hub
uses: docker/login-action@v3.3.0
continue-on-error: true
# We pull this image a lot, and Dockerhub will rate limit us if we pull too often.
# This is an attempt to cache the image for better performance and to work around that.
# It will cache all pulled images, so if we add new images to this we'll need to update the key.
- name: Cache Docker images
uses: ScribeMD/docker-cache@0.5.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
key: docker-${{ runner.os }}-mongo-${{ matrix.mongo-version }}

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.11.0
Expand Down
5 changes: 4 additions & 1 deletion cms/djangoapps/contentstore/rest_api/v1/serializers/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class StudioHomeSerializer(serializers.Serializer):
child=serializers.CharField(),
allow_empty=True
)
allowed_organizations_for_libraries = serializers.ListSerializer(
child=serializers.CharField(),
allow_empty=True
)
archived_courses = CourseCommonSerializer(required=False, many=True)
can_access_advanced_settings = serializers.BooleanField()
can_create_organizations = serializers.BooleanField()
Expand All @@ -62,7 +66,6 @@ class StudioHomeSerializer(serializers.Serializer):
libraries_v2_enabled = serializers.BooleanField()
taxonomies_enabled = serializers.BooleanField()
taxonomy_list_mfe_url = serializers.CharField()
optimization_enabled = serializers.BooleanField()
request_course_creator_url = serializers.CharField()
rerun_creator_status = serializers.BooleanField()
show_new_library_button = serializers.BooleanField()
Expand Down
10 changes: 8 additions & 2 deletions cms/djangoapps/contentstore/rest_api/v1/views/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.views import APIView
from organizations import api as org_api
from openedx.core.lib.api.view_utils import view_auth_classes

from ....utils import get_home_context, get_course_context, get_library_context
Expand Down Expand Up @@ -51,6 +52,7 @@ def get(self, request: Request):
"allow_to_create_new_org": true,
"allow_unicode_course_id": false,
"allowed_organizations": [],
"allowed_organizations_for_libraries": [],
"archived_courses": [],
"can_access_advanced_settings": true,
"can_create_organizations": true,
Expand All @@ -62,7 +64,6 @@ def get(self, request: Request):
"libraries_v1_enabled": true,
"libraries_v2_enabled": true,
"library_authoring_mfe_url": "//localhost:3001/course/course-v1:edX+P315+2T2023",
"optimization_enabled": true,
"request_course_creator_url": "/request_course_creator",
"rerun_creator_status": true,
"show_new_library_button": true,
Expand All @@ -80,7 +81,12 @@ def get(self, request: Request):

home_context = get_home_context(request, True)
home_context.update({
'allow_to_create_new_org': settings.FEATURES.get('ENABLE_CREATOR_GROUP', True) and request.user.is_staff,
# 'allow_to_create_new_org' is actually about auto-creating organizations
# (e.g. when creating a course or library), so we add an additional test.
'allow_to_create_new_org': (
home_context['can_create_organizations'] and
org_api.is_autocreate_enabled()
),
'studio_name': settings.STUDIO_NAME,
'studio_short_name': settings.STUDIO_SHORT_NAME,
'studio_request_email': settings.FEATURES.get('STUDIO_REQUEST_EMAIL', ''),
Expand Down
41 changes: 13 additions & 28 deletions cms/djangoapps/contentstore/rest_api/v1/views/tests/test_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@
from django.conf import settings
from django.test import override_settings
from django.urls import reverse
from edx_toggles.toggles.testutils import (
override_waffle_switch,
)
from rest_framework import status

from cms.djangoapps.contentstore.tests.utils import CourseTestCase
from cms.djangoapps.contentstore.tests.test_libraries import LibraryTestCase
from cms.djangoapps.contentstore.views.course import ENABLE_GLOBAL_STAFF_OPTIMIZATION
from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory
from xmodule.modulestore.tests.factories import CourseFactory


FEATURES_WITH_HOME_PAGE_COURSE_V2_API = settings.FEATURES.copy()
Expand All @@ -37,9 +32,10 @@ def setUp(self):
self.url = reverse("cms.djangoapps.contentstore:v1:home")
self.expected_response = {
"allow_course_reruns": True,
"allow_to_create_new_org": False,
"allow_to_create_new_org": True,
"allow_unicode_course_id": False,
"allowed_organizations": [],
"allowed_organizations_for_libraries": [],
"archived_courses": [],
"can_access_advanced_settings": True,
"can_create_organizations": True,
Expand All @@ -52,7 +48,6 @@ def setUp(self):
"libraries_v2_enabled": False,
"taxonomies_enabled": True,
"taxonomy_list_mfe_url": 'http://course-authoring-mfe/taxonomies',
"optimization_enabled": False,
"request_course_creator_url": "/request_course_creator",
"rerun_creator_status": True,
"show_new_library_button": True,
Expand Down Expand Up @@ -84,6 +79,17 @@ def test_home_page_studio_with_meilisearch_enabled(self):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertDictEqual(expected_response, response.data)

@override_settings(ORGANIZATIONS_AUTOCREATE=False)
def test_home_page_studio_with_org_autocreate_disabled(self):
"""Check response content when Organization autocreate is disabled"""
response = self.client.get(self.url)

expected_response = self.expected_response
expected_response["allow_to_create_new_org"] = False

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertDictEqual(expected_response, response.data)

def test_taxonomy_list_link(self):
response = self.client.get(self.url)
self.assertTrue(response.data['taxonomies_enabled'])
Expand Down Expand Up @@ -242,27 +248,6 @@ def test_home_page_response_no_courses_non_staff(self, filter_key, filter_value)
self.assertEqual(len(response.data["courses"]), 0)
self.assertEqual(response.status_code, status.HTTP_200_OK)

@override_waffle_switch(ENABLE_GLOBAL_STAFF_OPTIMIZATION, True)
def test_org_query_if_passed(self):
"""Test home page when org filter passed as a query param"""
foo_course = self.store.make_course_key('foo-org', 'bar-number', 'baz-run')
test_course = CourseFactory.create(
org=foo_course.org,
number=foo_course.course,
run=foo_course.run
)
CourseOverviewFactory.create(id=test_course.id, org='foo-org')
response = self.client.get(self.url, {"org": "foo-org"})
self.assertEqual(len(response.data['courses']), 1)
self.assertEqual(response.status_code, status.HTTP_200_OK)

@override_waffle_switch(ENABLE_GLOBAL_STAFF_OPTIMIZATION, True)
def test_org_query_if_empty(self):
"""Test home page with an empty org query param"""
response = self.client.get(self.url)
self.assertEqual(len(response.data['courses']), 0)
self.assertEqual(response.status_code, status.HTTP_200_OK)


@ddt.ddt
class HomePageLibrariesViewTest(LibraryTestCase):
Expand Down
26 changes: 0 additions & 26 deletions cms/djangoapps/contentstore/rest_api/v2/views/tests/test_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
from django.conf import settings
from django.test import override_settings
from django.urls import reverse
from edx_toggles.toggles.testutils import override_waffle_switch
from rest_framework import status

from cms.djangoapps.contentstore.tests.utils import CourseTestCase
from cms.djangoapps.contentstore.utils import reverse_course_url
from cms.djangoapps.contentstore.views.course import ENABLE_GLOBAL_STAFF_OPTIMIZATION
from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory

FEATURES_WITH_HOME_PAGE_COURSE_V2_API = settings.FEATURES.copy()
Expand Down Expand Up @@ -104,30 +102,6 @@ def test_home_page_response(self):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertDictEqual(expected_response, response.data)

@override_waffle_switch(ENABLE_GLOBAL_STAFF_OPTIMIZATION, True)
def test_org_query_if_passed(self):
"""Get list of courses when org filter passed as a query param.
Expected result:
- A list of courses available to the logged in user for the specified org.
"""
response = self.client.get(self.api_v2_url, {"org": "demo-org"})

self.assertEqual(len(response.data['results']['courses']), 1)
self.assertEqual(response.status_code, status.HTTP_200_OK)

@override_waffle_switch(ENABLE_GLOBAL_STAFF_OPTIMIZATION, True)
def test_org_query_if_empty(self):
"""Get home page with an empty org query param.
Expected result:
- An empty list of courses available to the logged in user.
"""
response = self.client.get(self.api_v2_url)

self.assertEqual(len(response.data['results']['courses']), 0)
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_active_only_query_if_passed(self):
"""Get list of active courses only.
Expand Down
Loading

0 comments on commit 1422fde

Please sign in to comment.