Skip to content

Commit

Permalink
Merge branch 'master' into viadanna/unhide-discussions
Browse files Browse the repository at this point in the history
  • Loading branch information
viadanna authored Nov 14, 2024
2 parents 3f7f6af + 5f5b8aa commit abb5b06
Show file tree
Hide file tree
Showing 9 changed files with 658 additions and 458 deletions.
19 changes: 11 additions & 8 deletions cms/djangoapps/contentstore/views/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,19 @@

# NOTE: This list is disjoint from ADVANCED_COMPONENT_TYPES
COMPONENT_TYPES = [
'discussion',
'library',
'library_v2', # Not an XBlock
'itembank',
'html',
'openassessment',
'problem',
'video',
'problem',
'itembank',
'library_v2', # Not an XBlock
'library',
'discussion',
'openassessment',
'drag-and-drop-v2',
]

BETA_COMPONENT_TYPES = ['library_v2', 'itembank']

ADVANCED_COMPONENT_TYPES = sorted({name for name, class_ in XBlock.load_classes()} - set(COMPONENT_TYPES))

ADVANCED_PROBLEM_TYPES = settings.ADVANCED_PROBLEM_TYPES
Expand Down Expand Up @@ -426,7 +428,8 @@ def create_support_legend_dict():
"type": category,
"templates": templates_for_category,
"display_name": component_display_names[category],
"support_legend": create_support_legend_dict()
"support_legend": create_support_legend_dict(),
"beta": category in BETA_COMPONENT_TYPES,
})

# Libraries do not support advanced components at this time.
Expand Down Expand Up @@ -476,7 +479,7 @@ def create_support_legend_dict():
course_advanced_keys
)
if advanced_component_templates['templates']:
component_templates.insert(0, advanced_component_templates)
component_templates.append(advanced_component_templates)

return component_templates

Expand Down
6 changes: 3 additions & 3 deletions cms/djangoapps/contentstore/views/tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -3184,13 +3184,13 @@ def _verify_advanced_xblocks(self, expected_xblocks, expected_support_levels):
templates = get_component_templates(self.course)
button_names = [template["display_name"] for template in templates]
self.assertIn("Advanced", button_names)
self.assertEqual(len(templates[0]["templates"]), len(expected_xblocks))
self.assertEqual(len(templates[-1]["templates"]), len(expected_xblocks))
template_display_names = [
template["display_name"] for template in templates[0]["templates"]
template["display_name"] for template in templates[-1]["templates"]
]
self.assertEqual(template_display_names, expected_xblocks)
template_support_levels = [
template["support_level"] for template in templates[0]["templates"]
template["support_level"] for template in templates[-1]["templates"]
]
self.assertEqual(template_support_levels, expected_support_levels)

Expand Down
4 changes: 3 additions & 1 deletion cms/static/js/models/component_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ define(['backbone'], function(Backbone) {
// boilerplate_name (may be null)
// is_common (only used for problems)
templates: [],
support_legend: {}
support_legend: {},
beta: false,
},
parse: function(response) {
// Returns true only for templates that both have no boilerplate and are of
Expand All @@ -26,6 +27,7 @@ define(['backbone'], function(Backbone) {
this.templates = response.templates;
this.display_name = response.display_name;
this.support_legend = response.support_legend;
this.beta = response.beta;

// Sort the templates.
this.templates.sort(function(a, b) {
Expand Down
3 changes: 2 additions & 1 deletion cms/static/js/views/components/add_xblock_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ define(['js/views/baseview', 'edx-ui-toolkit/js/utils/html-utils'],
var attributes = {
type: this.model.type,
templates: this.model.templates,
display_name: this.model.display_name
display_name: this.model.display_name,
beta: this.model.beta,
};
BaseView.prototype.initialize.call(this);
this.template = this.loadTemplate('add-xblock-component-button');
Expand Down
2 changes: 1 addition & 1 deletion cms/templates/js/add-xblock-component-button.underscore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<span class="large-template-icon large-<%- type %>-icon"></span>
<span class="sr"> <%- gettext("Add Component:") %></span>
<span class="name"><%- display_name %></span>
<% if (type === 'library_v2' || type === 'itembank') { %>
<% if (beta) { %>
<span class="beta"><%- gettext("Beta") %></span>
<% } %>
</button>
3 changes: 3 additions & 0 deletions openedx/core/djangoapps/user_authn/views/registration_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class AccountCreationForm(forms.Form):

_EMAIL_INVALID_MSG = _("A properly formatted e-mail is required")
_NAME_TOO_SHORT_MSG = _("Your legal name must be a minimum of one character long")
_NAME_TOO_LONG_MSG = _("Your legal name is too long. It must not exceed %(max_length)s characters")

# TODO: Resolve repetition

Expand All @@ -167,9 +168,11 @@ class AccountCreationForm(forms.Form):

name = forms.CharField(
min_length=accounts.NAME_MIN_LENGTH,
max_length=accounts.NAME_MAX_LENGTH,
error_messages={
"required": _NAME_TOO_SHORT_MSG,
"min_length": _NAME_TOO_SHORT_MSG,
"max_length": _NAME_TOO_LONG_MSG % {"max_length": accounts.NAME_MAX_LENGTH},
},
validators=[validate_name]
)
Expand Down
24 changes: 24 additions & 0 deletions openedx/core/djangoapps/user_authn/views/tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,30 @@ def test_register_fullname_url_validation_error(self):
}
)

def test_register_fullname_max_lenghth_validation_error(self):
"""
Full name error detection test if the length exceeds 255 characters.
"""
expected_error_message = f"Your legal name is too long. It must not exceed {NAME_MAX_LENGTH} characters"

response = self.client.post(self.url, {
"email": self.EMAIL,
"name": "x" * 256,
"username": self.USERNAME,
"password": self.PASSWORD,
"honor_code": "true",
})
assert response.status_code == 400

response_json = json.loads(response.content.decode('utf-8'))
self.assertDictEqual(
response_json,
{
"name": [{"user_message": expected_error_message}],
"error_code": "validation-error"
}
)

def test_register_fullname_html_validation_error(self):
"""
Test for catching invalid full name errors
Expand Down
Loading

0 comments on commit abb5b06

Please sign in to comment.