コード例 #1
0
def seed_data():
    ron_key = Student(student_id=423491377, first_name ="Ron", last_name = "Weasley").put()
    harry_key = Student (student_id=423491782, first_name ="Harry", last_name = "Potter").put()
    hermione_key = Student(student_id=423491249, first_name="Hermione", last_name="Granger").put()
    malfoy_key = Student(student_id=42391043, first_name="Draco", last_name="Malfoy").put()
    crabbe_key = Student(student_id=42391122, first_name="Vincent", last_name="Crabbe").put()
    goyle_key = Student(student_id=42391063, first_name="Gregory", last_name="Goyle").put()


    ron_wand=Wand(length = 14.0, material = "willow", core="unicorn", owner=ron_key)
    harry_wand=Wand(length = 11.0, material = "holly", core="phoenix feather", owner=harry_key)
    hermione_wand = Wand(length=10.75, material="vinewood", core="dragon heartstring", owner=hermione_key)

    ron_wand.put()
    harry_wand.put()
    hermione_wand.put()

    gryff = House(name="Gryffindor", mascot="Lion", students=[ron_key, harry_key, hermione_key])
    snakes = House(name="Slytherin", mascot="Snake", students=[malfoy_key, crabbe_key, goyle_key])
    hufflepuff = House(name="Hufflepuff", mascot="Badger", students=[])
    ravenclaw = House(name="Ravenclaw",  mascot="Eagle", students=[])

    gryff.put()
    snakes.put()
    hufflepuff.put()
    ravenclaw.put()

    potions = Course(name="Potions", location="dungeon")
    dada = Course(name="Defense Against the Dark Arts", location="3C")
    transfiguration = Course(name="Transfiguration", location="Class 34")
    potions_key = potions.put()
    dada_key = dada.put()
    transfiguration_key = transfiguration.put()

    #dada
    Enrollment(student=ron_key, course=dada_key).put()
    Enrollment(student=harry_key, course=dada_key).put()
    Enrollment(student=hermione_key, course=dada_key).put()

    #potions
    Enrollment(student=hermione_key, course=potions_key).put()
    Enrollment(student=ron_key, course=potions_key).put()
    Enrollment(student=malfoy_key, course=potions_key).put()
    Enrollment(student=crabbe_key, course=potions_key).put()
    Enrollment(student=goyle_key, course=potions_key).put()

    #tranfirguration
    Enrollment(student=harry_key, course=transfiguration_key).put()
    Enrollment(student=hermione_key, course=transfiguration_key).put()
    Enrollment(student=crabbe_key, course=transfiguration_key).put()
    Enrollment(student=goyle_key, course=transfiguration_key).put()

    snape = Teacher(name="Severus Snape", years_experience=5, classes_taught=[potions_key])
    snape.put()
    moody = Teacher(name="Alastor Moody", years_experience=1, classes_taught=[dada_key])
    moody.put()
    mcgonagall = Teacher(name="Minerva McGonagall", years_experience=12, classes_taught=[transfiguration_key])
    mcgonagall.put()
コード例 #2
0
def addCourses():
    # Add some additional Courses
    db_session.add(Course(id='CS F241', name='Microprocessors and Interfacing'))
    db_session.add(Course(id='MATH F211', name='Mathematics III'))
    db_session.add(Course(id='ECON F211', name='Principle Of Economics'))
    db_session.add(Course(id='CS F215', name='Digital Design'))
    db_session.commit()

    print "Added Courses"
コード例 #3
0
def setup():
    print("Setup")
    Base.metadata.drop_all(bind=db.engine)
    Base.metadata.create_all(bind=db.engine)
    db.session.add(User('*****@*****.**', 'password123', 's'))
    db.session.add(User('*****@*****.**', 'password123', 'p'))
    db.session.add(User('*****@*****.**', 'password123', 'a'))
    db.session.add(
        Course('CS2043', 'Software Engineering 1', 'Dr. Jong-Kyou Kim', 3))
    db.session.add(
        Course('CS2263', 'Systems Software Development', 'Dr. Jeffrey McNally',
               6))
    db.session.add(Course('CS1083', 'Java 2', 'Dr. Josee Tasse', 9))
    db.session.commit()
コード例 #4
0
ファイル: app.py プロジェクト: Gellesh/CMP-Projects-Web-App
def courses():
    if request.method == 'GET':
        year = request.args.get('year')
        courses = query_factory.get_courses_by_year(year)
        courses_list = []
        for course in courses:
            course_dict = {
                'name': course[0],
                'code': course[1],
                'year': course[2]
            }
            staff_list = query_factory.get_course_staff(course[1])
            staff_members = []
            for staff_member in staff_list:
                staff_members.append(staff_member[0])
            course_dict['staff'] = staff_members
            courses_list.append(course_dict)
        return jsonify(courses_list)
    elif request.method == 'PUT':
        data = request.get_json()
        old_course_code = data.get('code')
        new_course_code = data.get('newCourse').get('code')
        new_course_name = data.get('newCourse').get('name')
        new_course_year = data.get('newCourse').get('year')
        new_course = Course(name=new_course_name,
                            code=new_course_code,
                            year=new_course_year)
        (is_successful,
         message) = query_factory.edit_course(old_course_code, new_course)
        response = {'is_successful': is_successful, 'message': message}
        return jsonify(response)
    elif request.method == 'POST':
        data = request.get_json()
        new_course_code = data.get('newCourse').get('code')
        new_course_name = data.get('newCourse').get('name')
        new_course_year = data.get('newCourse').get('year')
        new_course = Course(name=new_course_name,
                            code=new_course_code,
                            year=new_course_year)
        (is_successful, message) = query_factory.add_course(new_course)
        response = {'is_successful': is_successful, 'message': message}
        return jsonify(response)
    elif request.method == 'DELETE':
        deleted_course_code = request.args.get('deletedCourseCode')
        (is_successful,
         message) = query_factory.delete_course(deleted_course_code)
        response = {'is_successful': is_successful, 'message': message}
        return jsonify(response)
コード例 #5
0
    def test_missing_quizzes_check_true(self, m):
        m.register_uri(
            'GET',
            '/api/v1/courses/1/quizzes',
            json=[{'id': 1, 'title': 'Quiz 1'}]
        )

        course_id = 1

        course = Course(
            canvas_id=course_id,
            course_name='test'
        )
        views.db.session.add(course)
        views.db.session.commit()

        extension = Extension(
            course_id=course.id,
            user_id=5,
            percent=200
        )
        views.db.session.add(extension)
        views.db.session.commit()

        response = self.client.get('/missing_quizzes/{}/'.format(course_id))

        self.assert_200(response)
        self.assertEqual(response.data, 'true')
コード例 #6
0
    def setUp(self):
        print('\r')
        # drop all tables in the database
        db.session.remove()
        db.drop_all()
        # crete all tables in the database
        db.create_all()

        # adding users
        user = User(email='*****@*****.**',
                    encrypted_password=encrypt('password'),
                    name='john_doe')
        staff = Staff(user)
        db.session.add(staff)

        # adding courses
        course = Course(index='cz3003')
        db.session.add(course)

        # adding quizzes
        quiz = Quiz(
            staff_id=1,
            name="Quiz Test",
            is_fast=True,
            date_start='2020-03-01',
            date_end='2020-03-31',
        )
        db.session.add(quiz)

        db.session.commit()
コード例 #7
0
ファイル: test_models.py プロジェクト: shuheng-liu/rcm-system
def test_request_for_course():
    from models import RequestForCourse
    from models import Course, Instructor, Staff, Student
    from models import Instructor

    joe = Instructor(first_name='Joe',
                     last_name='Biden',
                     email='*****@*****.**',
                     password='******').save()
    pl999 = Course(code='PL999', course_name='US Presidency',
                   professor=joe).save()

    RequestForCourse(course=pl999, requests_quota=8,
                     recommender=joe).validate()

    # negative quota
    with pytest.raises(ValidationError):
        RequestForCourse(course=pl999, requests_quota=-1,
                         recommender=joe).validate()
    # missing quota
    with pytest.raises(ValidationError):
        RequestForCourse(course=pl999, recommender=joe).validate()
    # missing recommender
    with pytest.raises(ValidationError):
        RequestForCourse(course=pl999, requests_quota=10).validate()
    # missing course
    with pytest.raises(ValidationError):
        RequestForCourse(requests_quota=10, recommender=joe).validate()

    clean_up()
コード例 #8
0
    def setUp(self):
        """Add sample data.
        Create test client."""

        db.drop_all()
        db.create_all()

        user1 = User.signup("*****@*****.**", "allison", "allison", "Allison", "McAllison", None)
        user1.id = 1111

        user2 = User.signup("*****@*****.**", "jackson", "jackson", "Jackson", "McJackson", None)
        user2.id = 2222

        v = Video(title="Title of a YouTube Video", description="Description of a YouTube Video", yt_video_id="yfoY53QXEnI", yt_channel_id="UC29ju8bIPH5as8OGnQzwJyA")

        c = Course(title = "This course title is a test", description = "This course description is a test", creator_id = user1.id)

        db.session.add(v)
        db.session.add(c)
        db.session.commit()

        self.user1 = user1
        self.user2 = user2
        self.v = v
        self.c = c

        # set the testing client server
        self.client = app.test_client()
コード例 #9
0
def settings():
    form = CourseForm()

    # courses of current user
    courses = Course.query.filter_by(user_id=current_user.get_id()).all()

    if form.validate_on_submit():
        course = Course(
            name=form.name.data,
            meeting_day=form.meeting_day.data,
            meeting_time=form.meeting_time.data,
            price=form.price.data,
            user_id=current_user.get_id()
        )

        db.session.add(course)
        try:
            db.session.commit()
        except Exception:
            print(Exception)

        flash("Course added", "add_course")
        return redirect(url_for("settings"))

    return render_template("settings.html", form=form, courses=courses, page_name="settings")
コード例 #10
0
    def setUp(self):
        print('\r')
        # drop all tables in the database
        db.session.remove()
        db.drop_all()
        # crete all tables in the database
        db.create_all()

        # adding courses
        course = Course(index='cz3003')
        db.session.add(course)

        # adding users
        user = User(
            email='*****@*****.**',
            encrypted_password=encrypt('password'),
            name='std'
        )
        std = Student(user,"U1722")
        db.session.add(std)

        # adding RsStudentCourseEnrol
        rs = initializeRsStudentCourseEnrol(1,'cz3003')
        db.session.add(rs)
        
        db.session.commit()
コード例 #11
0
def add_course_form():
    if request.method == 'POST':
        first_name=request.form.get('first_name')
        last_name=request.form.get('last_name')
        email_address=request.form.get('email_address')
        contact=request.form.get('contact')
        course_url=request.form.get('course_url')
        english=request.form.get('english')
        hindi=request.form.get('hindi')
        clean_url = url_cleaner(course_url)
        course_tags = clean_url.lower()
        try:
            course=Course(
                first_name=first_name,
                last_name=last_name,
                email_address=email_address,
                contact=contact,
                course_url=course_url,
                english=english,
                hindi=hindi,
                course_tags=course_tags
            )
            db.session.add(course)
            db.session.commit()
            return "Course added. course id={}".format(course.id)
        except Exception as e:
            return(str(e))
    return render_template("add_course.html")
コード例 #12
0
    def test_staff_CourseManagerAPI_POST(self):

        # request has invalid params input
        response = self.app.post('/staffs/[email protected]')
        # check if status code is correct
        print('--- check if status code is correct (invalid params input)')
        self.assertEqual(response.status_code, 400)

        # request error as dependency record not found
        response = self.app.post('/staffs/[email protected]&course_index=cz1003')
        # check if status code is correct
        print('--- check if status code is correct (dependency record not found)')
        self.assertEqual(response.status_code, 409)

        # request error as record already exist
        response = self.app.post('/staffs/[email protected]&course_index=cz1005')
        # check if status code is correct
        print('--- check if status code is correct (record already exist)')
        self.assertEqual(response.status_code, 409)

        # adding courses
        course_cz1003 = Course('cz1003')
        db.session.add(course_cz1003)
        db.session.commit()

        # success case
        response = self.app.post('/staffs/[email protected]&course_index=cz1003')
        res = res_to_dict(response) # convert response to dictionary
        # check if status code is correct
        print('--- successful, check if status code is correct')
        self.assertEqual(response.status_code, 200)
        # check if JSON returned is correct
        print('--- successful, check if JSON returned is correct')
        self.assertEqual(res['staff_id'], 3)
        self.assertEqual(res['course_index'], 'cz1003')
コード例 #13
0
def saveData(datalist):
    # 检查专业是否已经在专业表中
    majors1 = Majors.query.filter(Majors.Mname == '生命科学学院',
                                   Majors.Sname == '复旦大学').first()
    if majors1:
        # 如果存在,获取专业编号
        mid = majors1.MID
    else:
        # 不存在,获取当前最大专业编号值,继续编码,专业存入表中
        mmajors = Majors.query.order_by(Majors.MID.desc()).first()
        mid = mmajors.MID + 1
        majors = Majors(SID=1004, Sname='复旦大学', MID=mid, Mname='生命科学学院')
        db.session.add(majors)
        db.session.commit()
    for data in datalist:

        # 检查该课程是否已经存在
        course1 = Course.query.filter(Course.MID == mid, Course.Cname == data).first()
        if course1:
            pass
        else:
            # 获取课程编号最大值
            mcourse = Course.query.order_by(Course.CID.desc()).first()
            cid = mcourse.CID + 1
            # 将课程存入表中
            course = Course(MID=mid, CID=cid, Cname=data, Cinfo="http://life.fudan.edu.cn/Data/View/3309")
            newcourse = newCourse(CID=cid)
            db.session.add(course)
            db.session.add(newcourse)
            db.session.commit()
            category = Category(TID=1002, Tname='生命科学类', CID=cid)
            db.session.add(category)
            db.session.commit()
コード例 #14
0
def create_course():

	try:
		if 'course_code' not in request.json or 'course_name' not in request.json:
			return (jsonify("course_code and course_name must be included in the request"),400)
		elif type(request.json["course_code"]) != str or type(request.json["course_name"]) != str:
			return (jsonify("course_code and course_name need to be in string format"),400)
		else:
			course_code = request.json["course_code"]
			course_name = request.json["course_name"]

		valid_course_code = Course.query.filter_by(course_code=course_code).first()
		valid_course_name = Course.query.filter_by(course_name=course_name).first()

		if valid_course_code is not None or valid_course_name is not None:
			return(jsonify("The course code or course name you are trying to add already exists"),400)
		else:
			new_entry = Course(course_code=course_code,course_name=course_name)
			db.session.add(new_entry)
			db.session.commit()
		
		return (jsonify("{} has been added to the database".format(new_entry.course_code)),200)
	
	except Exception as e:
		return(str(e))
コード例 #15
0
def saveData(datalist):
    # 检查专业是否已经在专业表中
    majors1 = Majors.query.filter(Majors.Mname == '环境学院',
                                   Majors.Sname == '清华大学').first()
    if majors1:
        # 如果存在,获取专业编号
        mid = majors1.MID
    else:
        # 不存在,获取当前最大专业编号值,继续编码,专业存入表中
        mmajors = Majors.query.order_by(Majors.MID.desc()).first()
        mid = mmajors.MID + 1
        majors = Majors(SID=1001, Sname='清华大学', MID=mid, Mname='环境学院')
        db.session.add(majors)
        db.session.commit()
    for data in datalist:
        # 检查该课程是否已经存在
        course1 = Course.query.filter(Course.MID == mid and Course.Cname == data).first()
        if course1:
            pass
        else:
            # 获取课程编号最大值
            mcourse = Course.query.order_by(Course.CID.desc()).first()
            cid = mcourse.CID + 1
            # 将课程存入表中
            course = Course(MID=mid, CID=cid, Cname=data, Cinfo="https://www.tsinghua.edu.cn/hjxy/jxjw/bksjx/kcjs.htm")
            db.session.add(course)
            db.session.commit()
            category = Category(TID=1001, Tname='环境类', CID=cid)
            db.session.add(category)
            db.session.commit()
コード例 #16
0
    def setUp(self):
        print('\r')
        # drop all tables in the database
        db.session.remove()
        db.drop_all()
        # crete all tables in the database
        db.create_all()

        # adding courses
        course = Course(index='cz3003')
        db.session.add(course)

        # adding users
        user = User(email='*****@*****.**',
                    encrypted_password=encrypt('password'),
                    name='staff')
        staff = Staff(user)
        db.session.add(staff)

        # adding quizzes
        qz = Quiz(1, 'quiz', True, '2020-03-21', '2020-03-22')
        db.session.add(qz)

        # adding RsQuizCourseAssign
        rs = initializeRsQuizCourseAssign(1, 'cz3003')
        db.session.add(rs)

        db.session.commit()
コード例 #17
0
    def create_new_course(payload):
        courses = []
        result = {
            "success": True,
        }

        try:
            body = json.loads(request.data)

            name = body['name']
            description = body['description']
            price = body['price']

            new_course = Course(name=name,
                                description=description,
                                price=price)
            new_course.insert()

            courses.append(new_course.format())

        except Exception as e:
            print(e)
            abort(500)

        result['courses'] = courses

        return jsonify(result)
コード例 #18
0
    def test_courseMngCreateOperation(self):

        # check that error raised when record (student) does not exist
        print('--- check that error raised when record (student) does not exist')
        with self.assertRaises(ErrorWithCode):
            courseMngCreateOperation("*****@*****.**",'cz3003')

        # check that error raised when record (course) does not exist
        print('--- check that error raised when record (course) does not exist')
        with self.assertRaises(ErrorWithCode):
            courseMngCreateOperation('*****@*****.**', "cz3007")

        # check that error raised when record already exist
        print('--- check that error raised when record already exist')
        with self.assertRaises(ErrorWithCode):
            courseMngCreateOperation('*****@*****.**', "cz3003")

        # adding courses
        course = Course(index='cz3007')
        db.session.add(course)
        db.session.commit()

        # check that when successful, result returned by function is of the correct type
        print('--- check that when successful, result returned by function is of the correct type')
        self.assertEqual(type(courseMngCreateOperation('*****@*****.**',"cz3007")), Rs_student_course_enrol)
コード例 #19
0
ファイル: views.py プロジェクト: shayestehhamid/ExamScheduler
def upload_courses(prid, filename):
    book = xlrd.open_workbook(filename)
    coursesNum = book.nsheets
    coursesNames = book.sheet_names()

    for i in range(coursesNum):
        thisSheet = book.sheet_by_index(i)
        #print thisSheet.col_values(0)
        cs = thisSheet.col_values(0)
        course_name = coursesNames[i]
        course = Course(name=course_name)
        course.save()
        pr = Project.objects.get(id=prid)
        print pr.name
        course.project = pr
        course.save()

        for st in cs:

            st = Student(stdnom=str(int(st)))
            st.save()

            course.students.add(st)
            course.save()
    return projects(request)
コード例 #20
0
def load_objects():
    with open('processed_data/student_objects.json', 'r', encoding='utf-8') as student_objects_file:
        data = json.load(student_objects_file)
        [Student(datum) for datum in data]
    with open('processed_data/course_objects.json', 'r', encoding='utf-8') as course_objects_file:
        data = json.load(course_objects_file)
        [Course(datum) for datum in data]
コード例 #21
0
    def test_Quiz_CourseManagerAPI_POST(self):

        # request has invalid params input
        response = self.app.post('/quizzes/courses?quiz_id=1&course_index=')
        # check if status code is correct
        print('--- check if status code is correct (invalid params input)')
        self.assertEqual(response.status_code, 400)

        # request error as dependency record not found
        response = self.app.post('/quizzes/courses?quiz_id=4&course_index=cz1005')
        # check if status code is correct
        print('--- check if status code is correct (dependency record not found)')
        self.assertEqual(response.status_code, 404)

        # adding courses
        course = Course('cz1003')
        db.session.add(course)
        db.session.commit()

        # success case
        response = self.app.post('/quizzes/courses?quiz_id=1&course_index=cz1003')
        res = res_to_dict(response) # convert response to dictionary
        # check if status code is correct
        print('--- successful (2), check if status code is correct')
        self.assertEqual(response.status_code, 200)
コード例 #22
0
ファイル: standalone.py プロジェクト: mooey5775/diderot-cli
 def list_assignments(self):
     course = Course(self.api_client.client, self.args.course)
     labs = [hw["name"] for hw in Lab.list(course)]
     if len(labs) == 0:
         print("Course has no labs.")
     else:
         print_list(labs)
コード例 #23
0
ファイル: app.py プロジェクト: Mustafa017/FSND
    def create_courses():
        body = request.get_json()
        crs_title = body.get('title')
        crs_code = body.get('code')
        crs_desc = body.get('desc')
        crs_book = body.get('book')
        crs_lec = int(body.get('lec'))
        crs_room = int(body.get('room'))

        error = False

        try:
            # instantiate course object
            crs = Course(crs_code, crs_title, crs_desc, crs_book, crs_lec,
                         crs_room)
            crs.insert()
            courses = Course.query.order_by(Course.crs_id).all()
            courses_list = [course.format for course in courses]

        except Exception as e:
            db.session.rollback()
            error = True
            print(sys.exc_info())
        finally:
            db.session.close()

        if error:
            abort(422)
        else:
            return redirect('/courses')
コード例 #24
0
def create_course():
    try:
        print('创建课程'.center(60, '-'))
        school_list = School.get_all_obj_list()
        for k, obj in enumerate(school_list):
            print(k, obj, obj.addr)
        sid = int(input('请选择学校:'))
        school_obj = school_list[sid]

        name = input('请输入课程名:').strip()
        price = input('请输入课程价格:').strip()
        period = input('请输入课程周期:').strip()

        course_name_list = [(obj.name, obj.school_nid.uuid)
                            for obj in Course.get_all_obj_list()]
        if (name, school_obj.nid.uuid) in course_name_list:
            raise Exception('\033[43;1m课程[%s] 已存在,不可重复创建\033[0m' % name)
        obj = Course(name, price, period, school_obj.nid)
        obj.save()
        status = True
        error = ''
        data = '\033[33;1m课程[%s] 价格[%s] 周期[%s] 创建成功\033[0m' % (
            obj.name, obj.price, obj.period)
    except Exception as e:
        status = False
        error = str(e)
        data = ''
    return {'status': status, 'error': error, 'data': data}
コード例 #25
0
def course_ratings_create(username: str):
    schema = Schema({
        "collegename": And(str, len, error="No College Name"),
        "coursename": And(str, len, error="No Course Name"),
        "coursenumber": And(str, len, error="No Course Number"),
        "courserating": And(str, len, error="No Course Rating"),
        "coursepositive": And(str, len, error="No Course Positive"),
        "coursenegative": And(str, len, error="No Course Negative"),
        "username": And(str, len, error="No Username")
    })
    form = {
        "collegename": request.json.get("collegename"),
        "coursename": request.json.get("coursename"),
        "coursenumber": request.json.get("coursenumber"),
        "courserating": request.json.get("courserating"),
        "coursepositive": request.json.get("coursepositive"),
        "coursenegative": request.json.get("coursenegative"),
        "username": request.json.get("username")
    }
    print(request.json)
    print(form)
    validated = schema.validate(form)
    #print(validated)
    #user = User.objects(username=username).first()
    post = Course(collegename=validated["collegename"],
                  coursename=validated["coursename"],
                  coursenumber=validated['coursenumber'],
                  courserating=validated["courserating"],
                  coursepositive=validated["coursepositive"],
                  coursenegative=validated["coursenegative"],
                  username=validated["username"]).save()
    print(post)
    return jsonify(post.to_public_json())
コード例 #26
0
def create_courses():
    Course.query.delete()
    ct = Course(name='compthink',
                term_start_date=datetime.date(2014, 7, 3),
                institution='Virginia Tech',
                default=True)
    db.session.add(ct)
    db.session.commit()
コード例 #27
0
def create_course():
    cid = request.json["cid"]
    name = request.json["name"]
    school = request.json["school"]
    new_course = Course(cid=cid, name=name, school=school)
    db.session.add(new_course)
    db.session.commit()
    return jsonify("{} was created".format(new_course))
コード例 #28
0
ファイル: 多对多操作.py プロジェクト: dteer/flask_study
 def create_data1(self):
     obj = Course(title='英语')
     obj.student_list = [
         Student(name='小杰'),
         Student(name='小工'),
     ]
     session.add(obj)
     session.commit()
コード例 #29
0
ファイル: mappers.py プロジェクト: a-morev/patterns
 def find_by_name(self, id):
     statement = f"SELECT id, name FROM {self.tablename} WHERE id=?"
     self.cursor.execute(statement, (id, ))
     result = self.cursor.fetchone()
     if result:
         return Course(*result)
     else:
         raise RecordNotFoundException(f'record with id={id} not found')
コード例 #30
0
 def create(self, request):
     serializer = self.serializer_class(data=request.data)
     if serializer.is_valid():
         course = Course(**serializer.data)
         course.owner = request.user
         course.save()
         return Response(status=201)
     return Response(serializer.errors, status=400)