Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lms/djangoapps/certificates/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class GeneratedCertificateAdmin(admin.ModelAdmin):
raw_id_fields = ('user',)
show_full_result_count = False
search_fields = ('course_id', 'user__username')
list_display = ('id', 'course_id', 'mode', 'user')
list_display = ('id', 'course_id', 'mode', 'user', 'status')


class CertificateGenerationCourseSettingAdmin(admin.ModelAdmin):
Expand Down
18 changes: 18 additions & 0 deletions lms/djangoapps/certificates/views/webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pytz
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.http import Http404, HttpResponse
from django.template import RequestContext
from django.utils.encoding import smart_str
Expand Down Expand Up @@ -42,6 +43,7 @@
from openedx.core.djangoapps.catalog.utils import get_course_run_details
from openedx.core.djangoapps.lang_pref.api import get_closest_released_language
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, WaffleFlagNamespace
from openedx.core.lib.courses import course_image_url
from openedx.core.djangoapps.certificates.api import display_date_for_certificate, certificates_viewable_for_course
from student.models import LinkedInAddToProfileConfiguration
Expand All @@ -55,6 +57,21 @@


INVALID_CERTIFICATE_TEMPLATE_PATH = 'certificates/invalid.html'
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='certificates')
LOGIN_REQUIRED_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'require_login')


def certs_login_required(view):
"""
Require login when the 'certificates.require_login' is enabled
"""
def wrap(request, user_id, course_id, *args, **kwargs):
course_key = CourseKey.from_string(course_id)
if LOGIN_REQUIRED_FLAG.is_enabled(course_key):
return login_required(view)(request, user_id, course_id, *args, **kwargs)
else:
return view(request, user_id, course_id, *args, **kwargs)
return wrap


def get_certificate_description(mode, certificate_type, platform_name):
Expand Down Expand Up @@ -482,6 +499,7 @@ def render_cert_by_uuid(request, certificate_uuid):
template_path="certificates/server-error.html",
test_func=lambda request: request.GET.get('preview', None)
)
@certs_login_required
def render_html_view(request, user_id, course_id):
"""
This public view generates an HTML representation of the specified user and course
Expand Down