Skip to content

Commit

Permalink
Merge branch 'master' into rpenido/fal-4012-fix-advanced-editor-styling
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV authored Jan 30, 2025
2 parents 6a2721a + 5e51e2d commit 8463317
Show file tree
Hide file tree
Showing 33 changed files with 353 additions and 777 deletions.
1 change: 1 addition & 0 deletions cms/djangoapps/api/v1/views/course_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CourseRunViewSet(viewsets.GenericViewSet): # lint-amnesty, pylint: disabl
lookup_value_regex = settings.COURSE_KEY_REGEX
permission_classes = (permissions.IsAdminUser,)
serializer_class = CourseRunSerializer
queryset = []

def get_object(self):
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/api/views/course_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class CourseImportView(CourseImportExportViewMixin, GenericAPIView):
# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
exclude_from_schema = True
swagger_schema = None

@course_author_access_required
def post(self, request, course_key):
Expand Down
5 changes: 5 additions & 0 deletions cms/djangoapps/contentstore/api/views/course_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView):
* mode
"""
# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
swagger_schema = None

@course_author_access_required
def get(self, request, course_key):
"""
Expand Down
5 changes: 5 additions & 0 deletions cms/djangoapps/contentstore/api/views/course_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView):
* has_proctoring_escalation_email - whether the course has a proctoring escalation email
"""
# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
swagger_schema = None

@course_author_access_required
def get(self, request, course_key):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,5 @@ def handle(self, *args, **options):

if error_keys:
msg = 'The following courses encountered errors and were not updated:\n'
for error_key in error_keys:
msg += f' - {error_key}\n'
msg += '\n'.join(f' - {error_key}' for error_key in error_keys)
logger.info(msg)
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ def handle(self, *args, **options):
tarball = tasks.create_export_tarball(library, library_key, {}, None)
except Exception as e:
raise CommandError(f'Failed to export "{library_key}" with "{e}"') # lint-amnesty, pylint: disable=raise-missing-from
else:
with tarball:
# Save generated archive with keyed filename
prefix, suffix, n = str(library_key).replace(':', '+'), '.tar.gz', 0
while os.path.exists(prefix + suffix):
n += 1
prefix = '{}_{}'.format(prefix.rsplit('_', 1)[0], n) if n > 1 else f'{prefix}_1'
filename = prefix + suffix
target = os.path.join(dest_path, filename)
tarball.file.seek(0)
with open(target, 'wb') as f:
shutil.copyfileobj(tarball.file, f)
print(f'Library "{library.location.library_key}" exported to "{target}"')
with tarball:
# Save generated archive with keyed filename
prefix, suffix, n = str(library_key).replace(':', '+'), '.tar.gz', 0
while os.path.exists(prefix + suffix):
n += 1
prefix = '{}_{}'.format(prefix.rsplit('_', 1)[0], n) if n > 1 else f'{prefix}_1'
filename = prefix + suffix
target = os.path.join(dest_path, filename)
tarball.file.seek(0)
with open(target, 'wb') as f:
shutil.copyfileobj(tarball.file, f)
print(f'Library "{library.location.library_key}" exported to "{target}"')
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ class GradersSerializer(serializers.Serializer):
weight = serializers.IntegerField()
id = serializers.IntegerField()

class Meta:
ref_name = "authoring_grading.Graders.v0"


class CourseGradingModelSerializer(serializers.Serializer):
""" Serializer for course grading model data """
graders = GradersSerializer(many=True, allow_null=True, allow_empty=True)

class Meta:
ref_name = "authoring_grading.CourseGrading.v0"
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/rest_api/v0/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
authoring_videos.VideoEncodingsDownloadView.as_view(), name='cms_api_videos_encodings'
),
re_path(
fr'grading/{settings.COURSE_ID_PATTERN}',
fr'grading/{settings.COURSE_ID_PATTERN}$',
AuthoringGradingView.as_view(), name='cms_api_update_grading'
),
path(
Expand Down
10 changes: 10 additions & 0 deletions cms/djangoapps/contentstore/rest_api/v0/views/authoring_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ class VideoEncodingsDownloadView(DeveloperErrorViewMixin, RetrieveAPIView):
course_key: required argument, needed to authorize course authors and identify relevant videos.
"""

# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
swagger_schema = None

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
Expand All @@ -151,6 +156,11 @@ class VideoFeaturesView(DeveloperErrorViewMixin, RetrieveAPIView):
public rest API endpoint providing a list of enabled video features.
"""

# TODO: ARCH-91
# This view is excluded from Swagger doc generation because it
# does not specify a serializer class.
swagger_schema = None

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
Expand Down
2 changes: 1 addition & 1 deletion cms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
contentstore_views.textbooks_detail_handler, name='textbooks_detail_handler'),
re_path(fr'^videos/{settings.COURSE_KEY_PATTERN}(?:/(?P<edx_video_id>[-\w]+))?$',
contentstore_views.videos_handler, name='videos_handler'),
re_path(fr'^generate_video_upload_link/{settings.COURSE_KEY_PATTERN}',
re_path(fr'^generate_video_upload_link/{settings.COURSE_KEY_PATTERN}$',
contentstore_views.generate_video_upload_link_handler, name='generate_video_upload_link'),
re_path(fr'^video_images/{settings.COURSE_KEY_PATTERN}(?:/(?P<edx_video_id>[-\w]+))?$',
contentstore_views.video_images_handler, name='video_images_handler'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def handle(self, *args, **options):
self.change_enrollments(csv_file)

else:
CommandError('No file is provided. File is required')
raise CommandError('No file is provided. File is required')

def change_enrollments(self, csv_file):
""" change the enrollments of the learners. """
Expand Down
5 changes: 2 additions & 3 deletions common/djangoapps/track/views/segmentio.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,8 @@ def track_segmentio_event(request): # pylint: disable=too-many-statements
raise EventValidationError(ERROR_USER_NOT_EXIST) # lint-amnesty, pylint: disable=raise-missing-from
except ValueError:
raise EventValidationError(ERROR_INVALID_USER_ID) # lint-amnesty, pylint: disable=raise-missing-from
else:
context['user_id'] = user.id
context['username'] = user.username
context['user_id'] = user.id
context['username'] = user.username

# course_id is expected to be provided in the context when applicable
course_id = context.get('course_id')
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/discussion/rest_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ def get_thread_list(
if view in ["unread", "unanswered", "unresponded"]:
query_params[view] = "true"
else:
ValidationError({
raise ValidationError({
"view": [f"Invalid value. '{view}' must be 'unread' or 'unanswered'"]
})

Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/experiments/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def get_bucket(self, course_key=None, track=True):
if (
track and hasattr(request, 'session') and
session_key not in request.session and
not masquerading_as_specific_student and not anonymous
not masquerading_as_specific_student and not anonymous # pylint: disable=used-before-assignment
):
segment.track(
user_id=user.id,
Expand Down
3 changes: 1 addition & 2 deletions lms/djangoapps/static_template_view/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def render_press_release(request, slug):
resp = render_to_response('static_templates/press_releases/' + template, {})
except TemplateDoesNotExist:
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
else:
return resp
return resp


@fix_crum_request
Expand Down
28 changes: 27 additions & 1 deletion lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3392,9 +3392,35 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
CSRF_COOKIE_SECURE = False
CSRF_TRUSTED_ORIGINS = []
CSRF_TRUSTED_ORIGINS_WITH_SCHEME = []
CROSS_DOMAIN_CSRF_COOKIE_DOMAIN = ''

# If setting a cross-domain cookie, it's really important to choose
# a name for the cookie that is DIFFERENT than the cookies used
# by each subdomain. For example, suppose the applications
# at these subdomains are configured to use the following cookie names:
#
# 1) foo.example.com --> "csrftoken"
# 2) baz.example.com --> "csrftoken"
# 3) bar.example.com --> "csrftoken"
#
# For the cross-domain version of the CSRF cookie, you need to choose
# a name DIFFERENT than "csrftoken"; otherwise, the new token configured
# for ".example.com" could conflict with the other cookies,
# non-deterministically causing 403 responses.
CROSS_DOMAIN_CSRF_COOKIE_NAME = ''

# When setting the domain for the "cross-domain" version of the CSRF
# cookie, you should choose something like: ".example.com"
# (note the leading dot), where both the referer and the host
# are subdomains of "example.com".
#
# Browser security rules require that
# the cookie domain matches the domain of the server; otherwise
# the cookie won't get set. And once the cookie gets set, the client
# needs to be on a domain that matches the cookie domain, otherwise
# the client won't be able to read the cookie.
CROSS_DOMAIN_CSRF_COOKIE_DOMAIN = ''


######################### Django Rest Framework ########################

REST_FRAMEWORK = {
Expand Down
Loading

0 comments on commit 8463317

Please sign in to comment.