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
0481cf99
Commit
0481cf99
authored
Nov 01, 2012
by
John Jarvis
Committed by
Carlos Andrés Rocha
Nov 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating view for different certificate statuses, error
parent
5529eecb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
lms/djangoapps/certificates/views.py
+22
-4
No files found.
lms/djangoapps/certificates/views.py
View file @
0481cf99
import
logging
from
certificates.models
import
GeneratedCertificate
from
certificates.models
import
CertificateStatuses
as
status
from
django.views.decorators.csrf
import
csrf_exempt
from
django.http
import
HttpResponse
import
json
log
=
logging
.
getLogger
(
"mitx.certificates"
)
log
ger
=
logging
.
getLogger
(
__name__
)
@csrf_exempt
...
...
@@ -12,6 +13,10 @@ def update_certificate(request):
"""
Will update GeneratedCertificate for a new certificate or
modify an existing certificate entry.
See models.py for a state diagram of certificate states
This view should only ever be accessed by the xqueue server
"""
if
request
.
method
==
"POST"
:
...
...
@@ -26,7 +31,7 @@ def update_certificate(request):
key
=
xqueue_header
[
'lms_key'
])
except
GeneratedCertificate
.
DoesNotExist
:
log
.
critical
(
'Unable to lookup certificate
\n
'
log
ger
.
critical
(
'Unable to lookup certificate
\n
'
'xqueue_body: {0}
\n
'
'xqueue_header: {1}'
.
format
(
xqueue_body
,
xqueue_header
))
...
...
@@ -36,10 +41,23 @@ def update_certificate(request):
'content'
:
'unable to lookup key'
}),
mimetype
=
'application/json'
)
if
'error'
in
xqueue_body
:
cert
.
status
=
status
.
error
else
:
if
cert
.
state
in
[
status
.
generating
,
status
.
regenerating
]:
cert
.
download_uuid
=
xqueue_body
[
'download_uuid'
]
cert
.
verify_uuid
=
xqueue_body
[
'download
_uuid'
]
cert
.
verify_uuid
=
xqueue_body
[
'verify
_uuid'
]
cert
.
download_url
=
xqueue_body
[
'url'
]
cert
.
status
=
'downloadable'
cert
.
status
=
status
.
downloadable
elif
cert
.
state
in
[
status
.
deleting
]:
cert
.
status
=
status
.
deleted
else
:
logger
.
critical
(
'Invalid state for cert update: {0}'
.
format
(
cert
.
state
))
return
HttpResponse
(
json
.
dumps
({
'return_code'
:
1
,
'content'
:
'invalid cert state'
}),
mimetype
=
'application/json'
)
cert
.
save
()
return
HttpResponse
(
json
.
dumps
({
'return_code'
:
0
}),
mimetype
=
'application/json'
)
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