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
fceed0fc
Commit
fceed0fc
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
view for the certificate callback URL
parent
0ef54cde
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
19 deletions
+37
-19
lms/djangoapps/certificates/views.py
+34
-19
lms/urls.py
+3
-0
No files found.
lms/djangoapps/certificates/views.py
View file @
fceed0fc
import
logging
from
certificates.models
import
GeneratedCertificate
from
pprint
import
pprint
from
django.views.decorators.csrf
import
csrf_exempt
from
django.http
import
HttpResponse
import
json
log
=
logging
.
getLogger
(
"mitx.certificates"
)
@csrf_exempt
def
update_certificate
(
request
):
"""
Will update GeneratedCertificate for a new certificate or
...
...
@@ -12,20 +14,33 @@ def update_certificate(request):
"""
if
request
.
method
==
"POST"
:
pprint
(
request
)
# user = request.POST.get('user')
# try:
# generated_certificate = GeneratedCertificate.objects.get(
# key=key)
# except GeneratedCertificate.DoesNotExist:
# generated_certificate = GeneratedCertificate(user=user)
#
# enabled = request.POST.get('enabled')
# enabled = True if enabled == 'True' else False
# generated_certificate.grade = request.POST.get('grade')
# generated_certificate.download_url = request.POST.get('download_url')
# generated_certificate.graded_download_url = request.POST.get(
# 'graded_download_url')
# generated_certificate.course_id = request.POST.get('course_id')
# generated_certificate.enabled = enabled
# generated_certificate.save()
xqueue_body
=
json
.
loads
(
request
.
POST
.
get
(
'xqueue_body'
))
xqueue_header
=
json
.
loads
(
request
.
POST
.
get
(
'xqueue_header'
))
try
:
cert
=
GeneratedCertificate
.
objects
.
get
(
user__username
=
xqueue_body
[
'username'
],
course_id
=
xqueue_body
[
'course_id'
],
key
=
xqueue_header
[
'lms_key'
])
except
GeneratedCertificate
.
DoesNotExist
:
log
.
critical
(
'Unable to lookup certificate
\n
'
'xqueue_body: {0}
\n
'
'xqueue_header: {1}'
.
format
(
xqueue_body
,
xqueue_header
))
return
HttpResponse
(
json
.
dumps
({
'return_code'
:
1
,
'content'
:
'unable to lookup key'
}),
mimetype
=
'application/json'
)
cert
.
download_uuid
=
xqueue_body
[
'download_uuid'
]
cert
.
verify_uuid
=
xqueue_body
[
'download_uuid'
]
cert
.
download_url
=
xqueue_body
[
'url'
]
cert
.
status
=
'downloadable'
cert
.
save
()
return
HttpResponse
(
json
.
dumps
({
'return_code'
:
0
}),
mimetype
=
'application/json'
)
lms/urls.py
View file @
fceed0fc
...
...
@@ -4,6 +4,9 @@ from django.conf.urls.static import static
import
django.contrib.auth.views
urlpatterns
=
(
''
,
# certificate view
url
(
r'^update_certificate$'
,
'certificates.views.update_certificate'
),
url
(
r'^$'
,
'branding.views.index'
,
name
=
"root"
),
# Main marketing page, or redirect to courseware
url
(
r'^dashboard$'
,
'student.views.dashboard'
,
name
=
"dashboard"
),
...
...
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