Ejemplo n.º 1
0
	def new_user(self, first_name, last_name, email, password, is_lecturer):
		user = Admin(
			first_name=first_name, last_name=last_name, email=email, password=password,
			is_lecturer=is_lecturer
		)
		user.save()
		return user
Ejemplo n.º 2
0
def create_admin():
    """
    创建管理员
    """
    log('程序执行创建添加管理员')
    for i in range(1, 10):
        n = str(i)
        form = dict(name='admin' + str(i), pwd=n.zfill(3), role_id=1)
        admin = Admin(form)
        log('a', admin)
        admin.save()
Ejemplo n.º 3
0
def add():
    form = AdminForm()
    if form.validate_on_submit():
        data = form.data
        admin_count = Admin.query.filter_by(name=data["name"]).count()
        if admin_count == 1:
            flash("管理员已经存在", 'err')
            return redirect(url_for('.add'))
        admin = Admin(data)
        admin.save()
        flash("管理员添加成功!", "ok")
        redirect(url_for('.add'))
    return render_template('admin/administrator/add.html', form=form)