Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, April 9th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
fceed0fc
Commit
fceed0fc
authored
12 years ago
by
John Jarvis
Committed by
Carlos Andrés Rocha
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
view for the certificate callback URL
parent
0ef54cde
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/certificates/views.py
+34
-19
34 additions, 19 deletions
lms/djangoapps/certificates/views.py
lms/urls.py
+3
-0
3 additions, 0 deletions
lms/urls.py
with
37 additions
and
19 deletions
lms/djangoapps/certificates/views.py
+
34
−
19
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
'
)
This diff is collapsed.
Click to expand it.
lms/urls.py
+
3
−
0
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
"
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment