Exemple #1
0
def ajaxAddGrade():
    g_name = request.form.get('g_name')
    g = Grade.query.filter(Grade.g_name == g_name).first()
    # 判断要添加的信息数据库中是否存在(因为班级名称不能重复)
    if g:
        msg = '班级名称不能重复,请核对好在来添加'
    # 创建班级
    grade = Grade(g_name)
    # 保存班级信息
    grade.save()

    return redirect(url_for('user.grade_list'))
Exemple #2
0
def add_grade():
    grades = {'python': '人生苦短', 'php': '好好学习', 'java': '好辛苦', 'go': '跑路了'}
    g_list = []
    for key in grades:
        g = Grade()
        g.g_name = key
        g.g_desc = grades[key]
        g_list.append(g)

    db.session.add_all(g_list)
    db.session.commit()

    return '成功'
Exemple #3
0
 def post(self):
     args = self.reqparse.parse_args()
     g_name = args.get('grade_name')
     if Grade.query.filter_by(g_name=g_name).first():
         return status_code.GRADE_ADD_EXITS_ERROR
     gr = Grade(g_name=g_name)
     db.session.add(gr)
     db.session.commit()
     return {
         'code': 200,
         'msg': '添加班级成功~',
         'data': gr.to_dict()
     }
Exemple #4
0
def add_grade():
    if request.method == 'GET':
        return render_template('addgrade.html')
    if request.method == 'POST':
        g_name = request.form.get('g_name')
        g_dese = request.form.get('g_dese')
        grade = Grade()
        grade.g_name = g_name
        grade.g_dese = g_dese

        db.session.add(grade)
        db.session.commit()

        return '创建成功'
Exemple #5
0
def grade():
    grade_list = []
    for i in range(1, 11):
        g = Grade()
        g.g_name = 'pyhton%02d班' % i
        # random.sample(s, num)  随机取样, 得到的是列表
        g.g_desc = random.choice('sadfsadfasfdfsafdasdfweadfadf')
        g.g_create_time = datetime.datetime.now() + datetime.timedelta(hours=i)
        grade_list.append(g)

    db.session.add_all(grade_list)
    db.session.commit()

    return '<h1>创建班级成功</h1>'
Exemple #6
0
def add_grade():
    if request.method == 'GET':
        return render_template('addgrade.html')

    if request.method == 'POST':
        grade_name = request.form.get('grade_name')

        grade = Grade()
        grade.g_name = grade_name

        db.session.add(grade)
        db.session.commit()

        return redirect(url_for('user.grade'))
Exemple #7
0
def auto_add_grade():
    grade_name_list = ['python', 'java', 'php', 'c', 'c++', 'js']
    grade_list = []
    for name in grade_name_list:
        grade_list.append(Grade(name))
    db.session.add_all(grade_list)
    db.session.commit()
    return '自动添加班级成功'
def add_grades():
    if request.method == 'GET':
        grades = {
            'python': '人生苦短, 我用python',
            'php': '我是拍片的',
            'Java': '从入门到放弃',
            'go': 'go~go~go~'
        }
        g_list = []
        for key in grades:
            g = Grade()
            g.g_name = key
            g.g_desc = grades[key]
            g_list.append(g)
        db.session.add_all(g_list)
        db.session.commit()
        return '创建班级成功'
Exemple #9
0
def add_grade():
    """添加班级"""
    if request.method == 'GET':
        return render_template('addgrade.html')

    if request.method == 'POST':
        g_name = request.form.get('g_name')
        g = Grade.query.filter(Grade.g_name == g_name).first()
        # 判断要添加的信息数据库中是否存在(因为班级名称不能重复)
        if g:
            msg = '*班级名称不能重复,请核对好在来添加'
            return render_template('addgrade.html', msg=msg)
        # 创建班级
        grade = Grade(g_name)
        # 保存班级信息
        grade.save()

        return redirect(url_for('user.grade_list'))
Exemple #10
0
def add_grade():
	'''
	add the grade
	'''
	if request.method == 'GET':
		return render_template('addgrade.html')

	if request.method == 'POST':
		g_name = request.form.get('g_name')
		g = Grade.query.filter_by(g_name=g_name).first()

		if g:
			msg = 'class name is repeated'
			render_template('addgrade.html',msg=msg)

		grade = Grade(g_name)
		grade.save()

		return redirect(url_for('user.grade_list'))
Exemple #11
0
def add_grade():
    if request.method == 'GET':
        return render_template('addgrade.html')
    if request.method == 'POST':
        g_name = request.form.get('grade_name')
        if Grade.query.filter(Grade.g_name == g_name).first():
            return render_template('addgrade.html', msg='该班级已经存在')
        db.session.add(Grade(g_name))
        db.session.commit()
        return redirect(url_for('main.show_grade'))
Exemple #12
0
def add_grades(request):
    for i in range(10):
        g = Grade()
        g.g_name = 'Python180%d' % random.randrange(10)
        g.g_boy_num = random.randrange(50)
        g.g_girl_num = random.randrange(66)
        g.save()

    return HttpResponse("创建班级成功")
def add_grade():
    """添加年级"""
    if request.method == 'GET':
        return render_template('addgrade.html')

    if request.method == 'POST':
        g_name = request.form.get('g_name')
        grade = Grade.query.filter(Grade.g_name == g_name).first()
        if grade:
            msg = '*班级名称不能重复,请核对好在来添加'
            return render_template('addgrade.html', msg=msg)
        Grade(g_name).save()
        return redirect(url_for('user.grade_list'))
Exemple #14
0
def addgrade():
    if request.method == 'GET':
        return render_template('addgrade.html')
    if request.method == 'POST':
        g_name = request.form['g_name']
        grade_obj = Student.query.filter(Grade.g_name == g_name).first()
        if grade_obj:
            msg = "该班级已存在"
            return render_template('addgrade.html', msg=msg)
        elif g_name == "":
            msg = "班级名称不能为空"
            return render_template('addgrade.html', msg=msg)
        else:
            new_grade = Grade(g_name=g_name)
            db.session.add_all([new_grade])
            db.session.commit()
            return redirect('/user/grade/')
def add_grade():
    grade = Grade()
    grade.g_name = 'python%d' % random.randrange(2000)
    db.session.add(grade)
    db.session.commit()
    return 'Grade Add Success'
Exemple #16
0
def addgrade(request):
    grade = Grade()
    grade.g_name = 'python18' + str(random.randrange(10, 100))
    grade.save()

    return HttpResponse('添加 {} 班级成功!'.format(grade.g_name))
Exemple #17
0
def add_grade(request):
    grade = Grade()
    grade.g_name = "python18%d" % random.randrange(10, 100)

    grade.save()
    return HttpResponse('创建班级成功%d' % grade.id)
Exemple #18
0
def add_grade(request):
    grade = Grade()
    grade.g_name = 'python18120'
    grade.g_info = 'python'
    grade.save()
    return HttpResponse("新建一个班级")
Exemple #19
0
def grade_add(request):
    grade = Grade()
    grade.g_name = "python18%d" % random.randrange(200)
    grade.save()
    return HttpResponse("班级添加成功%d" % grade.id)
Exemple #20
0
def addgrade(request):
    grade = Grade()
    grade.g_name = 'computer' + str(random.randrange(1,10))
    grade.save()
    return HttpResponse("{}班添加成功".format(grade.g_name))