Commit 2eaa6dbc by ichuang

Merge pull request #198 from dementrock/master

fixed the bug that you can enroll a course several times
parents b0328b24 7c480dd5
......@@ -508,9 +508,10 @@ def course_info(request, course_id):
@ensure_csrf_cookie
def enroll(request, course_id):
course = check_course(course_id, course_must_be_open=False)
user = request.user
enrollment = CourseEnrollment(user=user,
course_id=course.id)
enrollment.save()
if not CourseEnrollment.objects.filter(user=user, course_id=course.id).exists():
enrollment = CourseEnrollment(user=user,
course_id=course.id)
enrollment.save()
return redirect(reverse('dashboard'))
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