Skip to content

Commit

Permalink
Merge pull request #362 from ucsd-ets/release-candidate
Browse files Browse the repository at this point in the history
release-2020-05-06
  • Loading branch information
imhassantariq authored May 8, 2020
2 parents bb1815a + ae157ea commit a780d4f
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 7 deletions.
11 changes: 10 additions & 1 deletion cms/djangoapps/contentstore/views/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,16 @@ def _upload_asset(request, course_key):
return JsonResponse({'error': text_type(exception)}, status=413)

# readback the saved content - we need the database timestamp
readback = contentstore().find(content.location)
try:
readback = contentstore().find(content.location)
except NotFoundError:
# [UCSD_CUSTOM] Here we are facing delay in MongoDB replication so we are putting a delay of 5 secs for now
# Importing time here so that customization can stay at one place there is no other usage of time library
# anywhere other than this in file.
import time
time.sleep(5)
readback = contentstore().find(content.location)

locked = getattr(content, 'locked', False)
return JsonResponse({
'asset': _get_asset_json(
Expand Down
4 changes: 2 additions & 2 deletions cms/envs/devstack_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
LMS_ROOT_URL = 'http://{}'.format(LMS_BASE)

FEATURES.update({
'ENABLE_COURSEWARE_INDEX': False,
'ENABLE_LIBRARY_INDEX': False,
'ENABLE_COURSEWARE_INDEX': True,
'ENABLE_LIBRARY_INDEX': True,
'ENABLE_DISCUSSION_SERVICE': True,
})

Expand Down
4 changes: 4 additions & 0 deletions common/djangoapps/pipeline_mako/templates/static_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,7 @@
<%def name="get_contact_email_address()"><%
return get_value('email_from_address', settings.CONTACT_EMAIL)
%></%def>

<%def name="get_support_form_link()"><%
return get_value('support_form_link', settings.SUPPORT_FORM_LINK)
%></%def>
2 changes: 1 addition & 1 deletion common/djangoapps/student/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def __init__(

def clean_password(self):
"""Enforce password policies (if applicable)"""
password = self.cleaned_data["password"]
password = self.data["password"]
if not self.do_third_party_auth:
# Creating a temporary user object to test password against username
# This user should NOT be saved
Expand Down
1 change: 1 addition & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,7 @@ def _make_locale_paths(settings):
STATIC_TEMPLATE_VIEW_DEFAULT_FILE_EXTENSION = 'html'

SUPPORT_SITE_LINK = ''
SUPPORT_FORM_LINK = ''
ID_VERIFICATION_SUPPORT_LINK = ''
PASSWORD_RESET_SUPPORT_LINK = ''
ACTIVATION_EMAIL_SUPPORT_LINK = ''
Expand Down
6 changes: 3 additions & 3 deletions lms/envs/devstack_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@

FEATURES.update({
'AUTOMATIC_AUTH_FOR_TESTING': True,
'ENABLE_COURSEWARE_SEARCH': False,
'ENABLE_COURSE_DISCOVERY': False,
'ENABLE_DASHBOARD_SEARCH': False,
'ENABLE_COURSEWARE_SEARCH': True,
'ENABLE_COURSE_DISCOVERY': True,
'ENABLE_DASHBOARD_SEARCH': True,
'ENABLE_DISCUSSION_SERVICE': True,
'SHOW_HEADER_LANGUAGE_SELECTOR': True,
'ENABLE_ENTERPRISE_INTEGRATION': False,
Expand Down
1 change: 1 addition & 0 deletions lms/envs/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@

# Intentional defaults.
SUPPORT_SITE_LINK = ENV_TOKENS.get('SUPPORT_SITE_LINK', SUPPORT_SITE_LINK)
SUPPORT_FORM_LINK = ENV_TOKENS.get('SUPPORT_FORM_LINK', SUPPORT_FORM_LINK)
ID_VERIFICATION_SUPPORT_LINK = ENV_TOKENS.get('ID_VERIFICATION_SUPPORT_LINK', SUPPORT_SITE_LINK)
PASSWORD_RESET_SUPPORT_LINK = ENV_TOKENS.get('PASSWORD_RESET_SUPPORT_LINK', SUPPORT_SITE_LINK)
ACTIVATION_EMAIL_SUPPORT_LINK = ENV_TOKENS.get(
Expand Down
115 changes: 115 additions & 0 deletions openedx/features/ucsd_features/validators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
from django.core.exceptions import ValidationError
from django.utils.module_loading import import_string
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _, ungettext


class MasterPasswordValidator(object):
"""
Validate all of the validators given in the validators list.
Parameters:
validators (list): the list of validators to validate along with their options.
min_validations (int): the num of minimum validation must pass for password.
Raises:
ValidationError if minimum number of validations is not passed.
"""
def __init__(self, validators=[], min_validations=0):
self.check_validators_list(validators, min_validations)
validators_list = validators
self.validators = []
for validator in validators_list:
try:
validator_name = validator["NAME"]
except KeyError:
raise KeyError("Validator doesn't contain 'NAME'. Please enter valid Validator")
validator_options = validator.get("OPTIONS", {})
self.validators.append(import_string(validator_name)(**validator_options))
self.min_validations = min_validations

def validate(self, password, user=None):
errors, passed = [], 0
for v in self.validators:
try:
v.validate(password, user)
except ValidationError as e:
errors.append(e)
else:
passed += 1
if passed < self.min_validations:
errors.insert(0, ValidationError(" Fix at least {} of the following errors: ".format(
self.min_validations - passed)))
raise ValidationError(errors, code="too_few_validations",
params={"min_validations": self.min_validations})

def get_help_text(self):
text = ungettext(
"your password must confirm to at least %(min_validations)d of the following:",
"your password must confirm to at least %(min_validations)d of the followings:",
self.min_validations
) % {"min_validations": self.min_validations}
for v in self.validators:
text += v.get_help_text()
return mark_safe(text)

def get_instruction_text(self):
text = ungettext(
"your password must confirm to at least %(min_validations)d of the following:",
"your password must confirm to at least %(min_validations)d of the followings:",
self.min_validations
) % {"min_validations": self.min_validations}
for validator in self.validators:
if hasattr(validator, 'get_instruction_text'):
text += validator.get_instruction_text() + ", "
return mark_safe(text[:-1])

@staticmethod
def check_validators_list(validators, min_validations):
if len(validators) < min_validations:
raise Exception('Number of Validators in list is lower than the minimum number of required validations.')


class RestrictedSymbolValidator(object):
"""
Validate whether the password contains any of the restricted symbol.
Parameters:
restricted_symbol_list (list): the list of symbols not allowed to use in password.
"""
def __init__(self, restricted_symbol_list=[]):
self.restricted_symbol_list = restricted_symbol_list
self.restricted_symbol_text = self.get_restricted_symbol_text()

def validate(self, password, user=None):
if self.validate_restriction_list(password):
return
raise ValidationError(
_("Your password must not contain any of the following symbols: {}".format(self.restricted_symbol_text)),
code="restricted_symbol_used",
)

def get_help_text(self):
return _(
"Your password must not contain any of the following symbols: {}".format(self.restricted_symbol_text))

def get_instruction_text(self):
if len(self.restricted_symbol_list) > 0:
return _(
"your password must not contain any of the following symbols: {}".format(self.restricted_symbol_text))
return ""

def validate_restriction_list(self, password):
for c in password:
if c in self.restricted_symbol_list:
return False
return True

def get_restricted_symbol_text(self):
text = ""
for c in self.restricted_symbol_list:
if c.isspace():
text += " Space"
else:
text += " " + c
return text
2 changes: 2 additions & 0 deletions requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ git+https://github.com/edx/django-rest-framework.git@1ceda7c086fddffd1c440cc8685
git+https://github.com/mitodl/edx-sga.git@3828ba9e413080a81b907a3381e5ffa05e063f81#egg=edx-sga==0.8.3
git+https://github.com/edx/[email protected]#egg=lti_consumer-xblock==1.2.5
git+https://github.com/appsembler/[email protected]#egg=tahoe-lti==release-0.2.0
-e git+https://github.com/ucsd-ets/pycaption.git@3c6b85e5ccfd180a945a4a9725d355401810352b#egg=pycaption
-e git+https://github.com/ucsd-ets/xblock-video.git@1fda7cbff7a95c4f5ffe220010e9a642a7f2e6af#egg=video_xblock
git+https://github.com/edx/MongoDBProxy.git@25b99097615bda06bd7cdfe5669ed80dc2a7fed0#egg=MongoDBProxy==0.1.0
-e .
git+https://github.com/edx/[email protected]#egg=ora2==2.2.0
Expand Down
2 changes: 2 additions & 0 deletions requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ git+https://github.com/mitodl/edx-sga.git@3828ba9e413080a81b907a3381e5ffa05e063f
git+https://github.com/edx/lettuce.git@7a04591c78ac56dac3eb3e91ca94b15cce844133#egg=lettuce==0.2.23+edx.1
git+https://github.com/edx/[email protected]#egg=lti_consumer-xblock==1.2.5
git+https://github.com/appsembler/[email protected]#egg=tahoe-lti==release-0.2.0
-e git+https://github.com/ucsd-ets/pycaption.git@3c6b85e5ccfd180a945a4a9725d355401810352b#egg=pycaption
-e git+https://github.com/ucsd-ets/xblock-video.git@1fda7cbff7a95c4f5ffe220010e9a642a7f2e6af#egg=video_xblock
git+https://github.com/edx/MongoDBProxy.git@25b99097615bda06bd7cdfe5669ed80dc2a7fed0#egg=MongoDBProxy==0.1.0
-e .
git+https://github.com/edx/[email protected]#egg=ora2==2.2.0
Expand Down
3 changes: 3 additions & 0 deletions requirements/edx/github.in
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,6 @@
-e git+https://github.com/mitodl/edx-sga.git@3828ba9e413080a81b907a3381e5ffa05e063f81#egg=edx-sga==0.8.3
-e git+https://github.com/open-craft/xblock-poll@add89e14558c30f3c8dc7431e5cd6536fff6d941#egg=xblock-poll==1.5.1
-e git+https://github.com/edx-solutions/[email protected]#egg=xblock-drag-and-drop-v2==2.1.6
# Forks of pycaption and xblock-video with updated dependencies
-e git+https://github.com/ucsd-ets/pycaption.git@3c6b85e5ccfd180a945a4a9725d355401810352b#egg=pycaption
-e git+https://github.com/ucsd-ets/xblock-video.git@1fda7cbff7a95c4f5ffe220010e9a642a7f2e6af#egg=video_xblock
2 changes: 2 additions & 0 deletions requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ git+https://github.com/mitodl/edx-sga.git@3828ba9e413080a81b907a3381e5ffa05e063f
git+https://github.com/edx/lettuce.git@7a04591c78ac56dac3eb3e91ca94b15cce844133#egg=lettuce==0.2.23+edx.1
git+https://github.com/edx/[email protected]#egg=lti_consumer-xblock==1.2.5
git+https://github.com/appsembler/[email protected]#egg=tahoe-lti==release-0.2.0
-e git+https://github.com/ucsd-ets/pycaption.git@3c6b85e5ccfd180a945a4a9725d355401810352b#egg=pycaption
-e git+https://github.com/ucsd-ets/xblock-video.git@1fda7cbff7a95c4f5ffe220010e9a642a7f2e6af#egg=video_xblock
git+https://github.com/edx/MongoDBProxy.git@25b99097615bda06bd7cdfe5669ed80dc2a7fed0#egg=MongoDBProxy==0.1.0
-e .
git+https://github.com/edx/[email protected]#egg=ora2==2.2.0
Expand Down

0 comments on commit a780d4f

Please sign in to comment.