def add_course(id, cname="noname"):
    # course_response_object = json.loads(views.get_course(course_id))
    if course_in_database(id) == False:
        course = Course()
        course.course_id = id
        course.course_name = cname
        course.save()
        return course
    else:
        return Course.objects.get(course_id=id)
def add_course():
    form = CourseForm()
    course = Course()
    if request.method == 'POST' and form.validate_on_submit():
        course.course_title = form.course_title.data
        course.course_name = form.course_name.data
        course.add_course()
        flash(f'Successfully Added course of title "{form.course_title.data}"',
              category='success')
        return redirect(url_for('courses'))
    else:
        return render_template('add_course.html', form=form)