Commit 5600d135 by Omar Al-Ithawi

All courses page

parent 72881001
......@@ -18,4 +18,5 @@ def i18n_patterns(prefix, *args):
urlpatterns = patterns('',
url(r'^setlang/$', 'edraak_misc.views.set_language', name='edraak_setlang'),
url(r'^check_student_grades/$', 'edraak_misc.views.check_student_grades', name='edraak_check_student_grades'),
url(r'^all_courses/$', 'edraak_misc.views.all_courses', name='edraak_all_courses'),
)
from django.views.i18n import set_language as django_set_language
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie
from xmodule.modulestore.django import modulestore
from courseware.access import has_access
from util.json_request import JsonResponse
from courseware.grades import grade
from opaque_keys.edx import locator
from util.cache import cache_if_anonymous
from django.conf import settings
from courseware.courses import get_courses, sort_by_announcement
from edxmako.shortcuts import render_to_response
from django.contrib.auth.models import AnonymousUser
@csrf_exempt
def set_language(request):
......@@ -30,3 +35,28 @@ def check_student_grades(request):
return JsonResponse({'success': False, 'error': False})
except:
return JsonResponse({'success': False, 'error': True})
@ensure_csrf_cookie
@cache_if_anonymous
def all_courses(request, extra_context={}, user=AnonymousUser()):
"""
Render the edX main page.
extra_context is used to allow immediate display of certain modal windows, eg signup,
as used by external_auth.
"""
# The course selection work is done in courseware.courses.
domain = settings.FEATURES.get('FORCE_UNIVERSITY_DOMAIN') # normally False
# do explicit check, because domain=None is valid
if domain is False:
domain = request.META.get('HTTP_HOST')
courses = get_courses(user, domain=domain)
courses = sort_by_announcement(courses)
context = {'courses': courses}
context.update(extra_context)
return render_to_response('all_courses.html', context)
## Just an empty placeholder
## Actual implementation is available in Edraak theme
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment