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
2545c67f
Commit
2545c67f
authored
Jan 27, 2017
by
Renzo Lucioni
Committed by
GitHub
Jan 27, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14412 from edx/renzo/remove-program-certification-view
Remove program certification view from the support app
parents
99910240
136e7f9b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
113 deletions
+0
-113
lms/djangoapps/support/tests/test_programs.py
+0
-61
lms/djangoapps/support/urls.py
+0
-1
lms/djangoapps/support/views/__init__.py
+0
-1
lms/djangoapps/support/views/programs.py
+0
-50
No files found.
lms/djangoapps/support/tests/test_programs.py
deleted
100644 → 0
View file @
99910240
# pylint: disable=missing-docstring
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
import
mock
from
edx_oauth2_provider.tests.factories
import
AccessTokenFactory
,
ClientFactory
from
student.tests.factories
import
UserFactory
class
IssueProgramCertificatesViewTests
(
TestCase
):
password
=
'password'
def
setUp
(
self
):
super
(
IssueProgramCertificatesViewTests
,
self
)
.
setUp
()
self
.
path
=
reverse
(
'support:programs-certify'
)
self
.
user
=
UserFactory
(
password
=
self
.
password
,
is_staff
=
True
)
self
.
data
=
{
'username'
:
self
.
user
.
username
}
self
.
headers
=
{}
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
self
.
password
)
def
_verify_response
(
self
,
status_code
):
"""Verify that the endpoint returns the provided status code and enqueues the task if appropriate."""
with
mock
.
patch
(
'lms.djangoapps.support.views.programs.award_program_certificates.delay'
)
as
mock_task
:
response
=
self
.
client
.
post
(
self
.
path
,
self
.
data
,
**
self
.
headers
)
self
.
assertEqual
(
response
.
status_code
,
status_code
)
self
.
assertEqual
(
status_code
==
200
,
mock_task
.
called
)
def
test_authentication_required
(
self
):
"""Verify that the endpoint requires authentication."""
self
.
client
.
logout
()
self
.
_verify_response
(
403
)
def
test_session_auth
(
self
):
"""Verify that the endpoint supports session auth."""
self
.
_verify_response
(
200
)
def
test_oauth
(
self
):
"""Verify that the endpoint supports OAuth 2.0."""
access_token
=
AccessTokenFactory
(
user
=
self
.
user
,
client
=
ClientFactory
())
.
token
# pylint: disable=no-member
self
.
headers
[
'HTTP_AUTHORIZATION'
]
=
'Bearer '
+
access_token
self
.
client
.
logout
()
self
.
_verify_response
(
200
)
def
test_staff_permissions_required
(
self
):
"""Verify that staff permissions are required to access the endpoint."""
self
.
user
.
is_staff
=
False
self
.
user
.
save
()
# pylint: disable=no-member
self
.
_verify_response
(
403
)
def
test_username_required
(
self
):
"""Verify that the endpoint returns a 400 when a username isn't provided."""
self
.
data
.
pop
(
'username'
)
self
.
_verify_response
(
400
)
lms/djangoapps/support/urls.py
View file @
2545c67f
...
...
@@ -16,5 +16,4 @@ urlpatterns = patterns(
views
.
EnrollmentSupportListView
.
as_view
(),
name
=
"enrollment_list"
),
url
(
r'^programs/certify/$'
,
views
.
IssueProgramCertificatesView
.
as_view
(),
name
=
'programs-certify'
),
)
lms/djangoapps/support/views/__init__.py
View file @
2545c67f
...
...
@@ -6,4 +6,3 @@ from .index import *
from
.certificate
import
*
from
.enrollments
import
*
from
.refund
import
*
from
.programs
import
IssueProgramCertificatesView
lms/djangoapps/support/views/programs.py
deleted
100644 → 0
View file @
99910240
# pylint: disable=missing-docstring
import
logging
from
rest_framework
import
permissions
,
status
,
views
from
rest_framework.authentication
import
SessionAuthentication
from
rest_framework.response
import
Response
from
rest_framework_oauth.authentication
import
OAuth2Authentication
from
openedx.core.djangoapps.programs.tasks.v1.tasks
import
award_program_certificates
log
=
logging
.
getLogger
(
__name__
)
class
IssueProgramCertificatesView
(
views
.
APIView
):
"""
**Use Cases**
Trigger the task responsible for awarding program certificates on behalf
of the user with the provided username.
**Example Requests**
POST /support/programs/certify/
{
'username': 'foo'
}
**Returns**
* 200 on success.
* 400 if program certification is disabled or a username is not provided.
* 401 if the request is not authenticated.
* 403 if the authenticated user does not have staff permissions.
"""
authentication_classes
=
(
SessionAuthentication
,
OAuth2Authentication
)
permission_classes
=
(
permissions
.
IsAuthenticated
,
permissions
.
IsAdminUser
,)
def
post
(
self
,
request
):
username
=
request
.
data
.
get
(
'username'
)
if
username
:
log
.
info
(
'Enqueuing program certification task for user [
%
s]'
,
username
)
award_program_certificates
.
delay
(
username
)
return
Response
()
else
:
return
Response
(
{
'error'
:
'A username is required in order to issue program certificates.'
},
status
=
status
.
HTTP_400_BAD_REQUEST
)
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