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
513cffb2
Commit
513cffb2
authored
May 01, 2014
by
Matt Drayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Group Profile fix
parent
98793cb7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
12 deletions
+30
-12
lms/djangoapps/api_manager/groups_views.py
+14
-11
lms/djangoapps/api_manager/tests/test_groups_views.py
+16
-1
No files found.
lms/djangoapps/api_manager/groups_views.py
View file @
513cffb2
...
...
@@ -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,18 +139,22 @@ class GroupsDetail(APIView):
response_data
[
'resources'
]
.
append
({
'uri'
:
resource_uri
})
resource_uri
=
'{}/groups'
.
format
(
base_uri
)
response_data
[
'resources'
]
.
append
({
'uri'
:
resource_uri
})
group_profile
=
GroupProfile
.
objects
.
get
(
group_id
=
group_id
)
if
len
(
group_profile
.
name
):
response_data
[
'name'
]
=
group_profile
.
name
try
:
group_profile
=
GroupProfile
.
objects
.
get
(
group_id
=
group_id
)
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
if
group_profile
.
group_type
:
response_data
[
'group_type'
]
=
group_profile
.
group_type
data
=
group_profile
.
data
if
data
:
response_data
[
'data'
]
=
json
.
loads
(
data
)
else
:
response_data
[
'name'
]
=
existing_group
.
name
if
group_profile
.
group_type
:
response_data
[
'group_type'
]
=
group_profile
.
group_type
data
=
group_profile
.
data
if
data
:
response_data
[
'data'
]
=
json
.
loads
(
data
)
return
Response
(
response_data
,
status
=
status
.
HTTP_200_OK
)
...
...
lms/djangoapps/api_manager/tests/test_groups_views.py
View file @
513cffb2
...
...
@@ -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