Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
7506a479
Commit
7506a479
authored
Aug 21, 2014
by
Oleg Marshev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow one group in a group configuration.
parent
c12535c5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
14 deletions
+11
-14
cms/djangoapps/contentstore/views/course.py
+2
-2
cms/djangoapps/contentstore/views/tests/test_group_configurations.py
+2
-4
cms/static/js/models/group_configuration.js
+4
-4
cms/static/js/spec/models/group_configuration_spec.js
+3
-4
No files found.
cms/djangoapps/contentstore/views/course.py
View file @
7506a479
...
...
@@ -1134,8 +1134,8 @@ class GroupConfiguration(object):
"""
if
not
self
.
configuration
.
get
(
"name"
):
raise
GroupConfigurationsValidationError
(
_
(
"must have name of the configuration"
))
if
len
(
self
.
configuration
.
get
(
'groups'
,
[]))
<
2
:
raise
GroupConfigurationsValidationError
(
_
(
"must have at least
two groups
"
))
if
len
(
self
.
configuration
.
get
(
'groups'
,
[]))
<
1
:
raise
GroupConfigurationsValidationError
(
_
(
"must have at least
one group
"
))
def
generate_id
(
self
,
used_ids
):
"""
...
...
cms/djangoapps/contentstore/views/tests/test_group_configurations.py
View file @
7506a479
...
...
@@ -121,13 +121,11 @@ class GroupConfigurationsBaseTestCase(object):
{
u'name'
:
u'Group B'
},
],
},
# must have at least
two groups
# must have at least
one group
{
u'name'
:
u'Test name'
,
u'description'
:
u'Test description'
,
u'groups'
:
[
{
u'name'
:
u'Group A'
},
],
u'groups'
:
[],
},
# an empty json
{},
...
...
cms/static/js/models/group_configuration.js
View file @
7506a479
...
...
@@ -80,14 +80,14 @@ function(Backbone, _, str, gettext, GroupModel, GroupCollection) {
validate
:
function
(
attrs
)
{
if
(
!
_
.
str
.
trim
(
attrs
.
name
))
{
return
{
message
:
gettext
(
'Group Configuration name is required'
),
message
:
gettext
(
'Group Configuration name is required
.
'
),
attributes
:
{
name
:
true
}
};
}
if
(
attrs
.
groups
.
length
<
2
)
{
if
(
attrs
.
groups
.
length
<
1
)
{
return
{
message
:
gettext
(
'There must be at least
two groups
'
),
message
:
gettext
(
'There must be at least
one group.
'
),
attributes
:
{
groups
:
true
}
};
}
else
{
...
...
@@ -100,7 +100,7 @@ function(Backbone, _, str, gettext, GroupModel, GroupCollection) {
});
if
(
!
_
.
isEmpty
(
invalidGroups
))
{
return
{
message
:
gettext
(
'All groups must have a name'
),
message
:
gettext
(
'All groups must have a name
.
'
),
attributes
:
{
groups
:
invalidGroups
}
};
}
...
...
cms/static/js/spec/models/group_configuration_spec.js
View file @
7506a479
...
...
@@ -183,15 +183,14 @@ define([
expect
(
model
.
isValid
()).
toBeTruthy
();
});
it
(
'requires at least
two groups
'
,
function
()
{
it
(
'requires at least
one group
'
,
function
()
{
var
group1
=
new
GroupModel
({
name
:
'Group A'
}),
group2
=
new
GroupModel
({
name
:
'Group B'
}),
model
=
new
GroupConfigurationModel
({
name
:
'foo'
});
model
.
get
(
'groups'
).
reset
([
group1
]);
model
.
get
(
'groups'
).
reset
([]);
expect
(
model
.
isValid
()).
toBeFalsy
();
model
.
get
(
'groups'
).
add
(
group
2
);
model
.
get
(
'groups'
).
add
(
group
1
);
expect
(
model
.
isValid
()).
toBeTruthy
();
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment