def confirm_trial(request, course_id): course, course_name = Course.get_course(Course, course_id=course_id) if request.method == "POST": trial = request.user.trial if trial.trial_available(): # ADDING USER TO THE TRIAL GROUP trial.status = False trial.course = course_name trial.set_trial_datetime() trial.save() add_user_to_group(group_id=3, user_id=request.user.id) messages.success(request, "You are Successfully enrolled in the trial.") return redirect( "dashboard:dashboard", user_id=request.user.id, ) else: messages.warning( request, "you are not elligible for this trial. may be becuase you have already taken one.", ) return redirect("dashboard:dashboard", user_id=request.user.id) else: context = { "course": course, } return render(request, "dashboard/confirm_trial.html", context=context)
def courses_data(request, course_id): courses, name = Course.get_course(Course, course_id) if not courses: raise Http404("invalid request") else: courses = Course.seperate_query_sets(Course, courses) context = {"name": name, "courses": courses} return render(request, "dashboard/courses_data.html", context=context)