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
4cf04c91
Commit
4cf04c91
authored
May 01, 2014
by
Matt Drayer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #30 from edx-solutions/mattdrayer/group_profile_fix
Group Profile fix
parents
3d6e4b46
513cffb2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
5 deletions
+23
-5
lms/djangoapps/api_manager/groups_views.py
+7
-4
lms/djangoapps/api_manager/tests/test_groups_views.py
+16
-1
No files found.
lms/djangoapps/api_manager/groups_views.py
View file @
4cf04c91
...
...
@@ -122,7 +122,6 @@ class GroupsDetail(APIView):
response_data
[
'uri'
]
=
_generate_base_uri
(
request
)
return
Response
(
response_data
,
status
=
status
.
HTTP_201_CREATED
)
def
get
(
self
,
request
,
group_id
,
format
=
None
):
"""
GET retrieves an existing group from the system
...
...
@@ -140,9 +139,12 @@ class GroupsDetail(APIView):
response_data
[
'resources'
]
.
append
({
'uri'
:
resource_uri
})
resource_uri
=
'{}/groups'
.
format
(
base_uri
)
response_data
[
'resources'
]
.
append
({
'uri'
:
resource_uri
})
try
:
group_profile
=
GroupProfile
.
objects
.
get
(
group_id
=
group_id
)
if
len
(
group_profile
.
name
):
except
ObjectDoesNotExist
:
group_profile
=
None
if
group_profile
:
if
group_profile
.
name
:
response_data
[
'name'
]
=
group_profile
.
name
else
:
response_data
[
'name'
]
=
existing_group
.
name
...
...
@@ -151,7 +153,8 @@ class GroupsDetail(APIView):
data
=
group_profile
.
data
if
data
:
response_data
[
'data'
]
=
json
.
loads
(
data
)
else
:
response_data
[
'name'
]
=
existing_group
.
name
return
Response
(
response_data
,
status
=
status
.
HTTP_200_OK
)
...
...
lms/djangoapps/api_manager/tests/test_groups_views.py
View file @
4cf04c91
...
...
@@ -12,7 +12,7 @@ from django.core.cache import cache
from
django.test
import
TestCase
,
Client
from
django.test.utils
import
override_settings
from
api_manager.models
import
GroupRelationship
from
api_manager.models
import
GroupRelationship
,
GroupProfile
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
...
@@ -190,6 +190,21 @@ class GroupsApiTests(TestCase):
self
.
assertEqual
(
response
.
data
[
'uri'
],
confirm_uri
)
self
.
assertEqual
(
response
.
data
[
'name'
],
'{:04d}: '
.
format
(
group_id
))
def
test_group_detail_get_with_missing_profile
(
self
):
data
=
{
'name'
:
''
}
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
201
)
self
.
assertGreater
(
response
.
data
[
'id'
],
0
)
group_id
=
response
.
data
[
'id'
]
GroupProfile
.
objects
.
get
(
group_id
=
group_id
)
.
delete
()
test_uri
=
self
.
base_groups_uri
+
'/'
+
str
(
group_id
)
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
data
[
'id'
],
group_id
)
confirm_uri
=
self
.
test_server_prefix
+
test_uri
self
.
assertEqual
(
response
.
data
[
'uri'
],
confirm_uri
)
self
.
assertEqual
(
response
.
data
[
'name'
],
'{:04d}: '
.
format
(
group_id
))
def
test_group_detail_get_undefined
(
self
):
test_uri
=
self
.
base_groups_uri
+
'/123456789'
response
=
self
.
do_get
(
test_uri
)
...
...
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