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
466abcdc
Commit
466abcdc
authored
Oct 14, 2015
by
Saleem Latif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated message for 500 error on certificate preview
parent
f49461c2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
0 deletions
+72
-0
common/djangoapps/util/views.py
+33
-0
lms/djangoapps/certificates/tests/test_webview_views.py
+12
-0
lms/djangoapps/certificates/views/webview.py
+2
-0
lms/templates/certificates/server-error.html
+25
-0
No files found.
common/djangoapps/util/views.py
View file @
466abcdc
...
...
@@ -56,6 +56,39 @@ def jsonable_server_error(request, template_name='500.html'):
return
server_error
(
request
,
template_name
=
template_name
)
def
handle_500
(
template_path
,
context
=
None
):
"""
Decorator for view specific 500 error handling.
Usage::
@handle_500(template_path='certificates/server-error.html', context={'error-info': 'Internal Server Error'})
def my_view(request):
# Any unhandled exception in this view would be handled by the handle_500 decorator
# ...
"""
def
decorator
(
func
):
"""
Decorator to render custom html template in case of uncaught exception in wrapped function
"""
@wraps
(
func
)
def
inner
(
request
,
*
args
,
**
kwargs
):
"""
Execute the function in try..except block and return custom server-error page in case of unhandled exception
"""
try
:
return
func
(
request
,
*
args
,
**
kwargs
)
except
Exception
:
# pylint: disable=broad-except
if
settings
.
DEBUG
:
# In debug mode let django process the 500 errors and display debug info for the developer
raise
else
:
return
render_to_response
(
template_path
,
context
)
return
inner
return
decorator
def
calculate
(
request
):
''' Calculator in footer of every page. '''
equation
=
request
.
GET
[
'equation'
]
...
...
lms/djangoapps/certificates/tests/test_webview_views.py
View file @
466abcdc
...
...
@@ -24,6 +24,7 @@ from certificates.models import (
CertificateStatuses
,
CertificateSocialNetworks
,
CertificateTemplate
,
CertificateHtmlViewConfiguration
)
from
certificates.tests.factories
import
(
...
...
@@ -418,6 +419,17 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
self
.
assertIn
(
"Invalid Certificate"
,
response
.
content
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
def
test_render_500_view_invalid_certificate_configuration
(
self
):
CertificateHtmlViewConfiguration
.
objects
.
all
()
.
update
(
enabled
=
False
)
test_url
=
get_certificate_url
(
user_id
=
self
.
user
.
id
,
course_id
=
unicode
(
self
.
course
.
id
)
)
response
=
self
.
client
.
get
(
test_url
)
self
.
assertIn
(
"Invalid Certificate Configuration"
,
response
.
content
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
def
test_certificate_evidence_event_emitted
(
self
):
self
.
client
.
logout
()
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
2
)
...
...
lms/djangoapps/certificates/views/webview.py
View file @
466abcdc
...
...
@@ -23,6 +23,7 @@ from opaque_keys import InvalidKeyError
from
opaque_keys.edx.keys
import
CourseKey
from
student.models
import
LinkedInAddToProfileConfiguration
from
util
import
organizations_helpers
as
organization_api
from
util.views
import
handle_500
from
xmodule.modulestore.django
import
modulestore
from
certificates.api
import
(
...
...
@@ -279,6 +280,7 @@ def _update_certificate_context(context, course, user, user_certificate):
)
@handle_500
(
template_path
=
"certificates/server-error.html"
)
def
render_html_view
(
request
,
user_id
,
course_id
):
"""
This public view generates an HTML representation of the specified student's certificate
...
...
lms/templates/certificates/server-error.html
0 → 100644
View file @
466abcdc
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%
inherit
file=
"../main.html"
/>
<
%
block
name=
"pagetitle"
>
${_("Invalid Certificate Configuration.")}
</
%
block>
<section
class=
"outside-app"
>
<h1>
${_(u"There is a problem with this certificate on {platform_name}".format(
platform_name=u"
<em>
{platform_name}
</em>
".format(platform_name=settings.PLATFORM_NAME)))}
</h1>
<div>
<p>
${_("To resolve the problem, your partner manager should verify that the following information is correct.")}
</p>
<ul>
<li>
${_("The institution
'
s logo.")}
</li>
<li>
${_("The institution that is linked to the course.")}
</li>
<li>
${_("The course information in the Course Administration tool.")}
</li>
</ul>
<br/>
<p>
${_("If all of the information is correct and the problem persists, contact technical support.")}
</p>
</div>
</section>
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