예제 #1
0
def create_sudent():
    form = CreateUser()
    if form.is_submitted():
        try:
            oracle_connection_string = 'oracle+cx_oracle://{username}:{password}@{host}:{port}/{sid}'

            engine = create_engine(oracle_connection_string.format(
                username="******",
                password="******",
                sid="XE",
                host="localhost",
                port="1521",
                database="WORKSHOP"),
                                   echo=True)

            Session = sessionmaker(bind=engine)
            session = Session()

            result = request.form
            adddata = student_database(result['student_name'],
                                       result['student_mail'],
                                       result['student_group'],
                                       result['login'], result['student_pass'])
            session.add(adddata)
            session.commit()
            return render_template('ConfirmOK.html', result=result)

        except:
            result = request.form
            return render_template('ConfirmNotOK.html', result=result)

    return render_template('createStudent.html', form=form)
예제 #2
0
def user_create():
    """
    创建用户
    :return:
    """
    form = CreateUser()
    if request.method == 'POST':
        if form.validate_on_submit():
            user = User.query.filter_by(
                username=form.username.data
            ).first()
            pwd = request.values.get("pwd")
            if user:
                flash(u"用户名已存在,请更换用户名", "user_error")
            else:
                permissions = form.permission.data
                if permissions == 'ptman':
                    user_permission = 10
                elif permissions == 'admin':
                    user_permission = 70
                elif permissions == 'suadmin':
                    user_permission = 80
                else:
                    abort(500)
                newuser = User(
                    username=form.username.data,password=md5s(None, pwd),permissions=user_permission
                )
                db.session.add(newuser)
                db.session.commit()
                flash(u"新用户创建成功")
                eventlog("[创建用户]")
                return 0
    return form
예제 #3
0
def profile():
    form = CreateUser()
    if request.method == "POST" and form.validate_on_submit():

        userid = random.randint(1, 1000)
        firstname = form.firstname.data
        lastname = form.lastname.data
        username = form.username.data
        age = form.age.data
        gender = form.gender.data
        bio = form.bio.data
        file = request.files['img']
        img = secure_filename(file.filename)
        file.save(os.path.join("app/static/uploads", img))
        pwd = form.password.data
        date_added = datetime.now().strftime("%a, %d, %b, %Y")

        new_user = UserProfile(userid, firstname, lastname, username, age,
                               gender, bio, img, pwd, date_added)
        db.session.add(new_user)
        db.session.commit()

        flash('Sign up successful', 'success')
        return redirect(url_for('login'))

    flash_errors(form)
    return render_template('profile.html', form=form)
예제 #4
0
def create_member():
    form = CreateUser()
    if form.validate_on_submit():
        error = register_member(form, dba, discord_user_datas)
        if error:
            flash(error, "message_error")
        else:
            flash(f"Le membre {form.username.data} a bien été enregistré")
            return redirect(url_for('create_member'))
    return render_template(f'admin/create_member.html', form=form)
예제 #5
0
파일: views.py 프로젝트: Smashman/mods.tf
    def index(self):
        form = CreateUser()

        if form.validate_on_submit():
            user = new_user(form.profile_url.data)
            if not isinstance(user, str):
                flash("User created. ID: {}".format(user.account_id),
                      'success')
            else:
                flash("User create failed. Reason: {}".format(user), 'danger')

        return self.render('admin/create_user.html', form=form)
예제 #6
0
파일: views.py 프로젝트: Smashman/mods.tf
    def index(self):
        form = CreateUser()

        if form.validate_on_submit():
            user = new_user(form.profile_url.data)
            if not isinstance(user, str):
                flash("User created. ID: {}".format(user.account_id), 'success')
            else:
                flash("User create failed. Reason: {}".format(user), 'danger')

        return self.render(
                'admin/create_user.html',
                form=form
            )
예제 #7
0
def register():
    form = CreateUser()
    if form.validate_on_submit():
        if User.query.filter_by(email=form.email.data).first():
            flash("This email is already exist. Please use another email.")
            return redirect(url_for("register"))
        new_user = User(name=form.name.data,
                        email=form.email.data,
                        password=generate_password_hash(form.password.data,
                                                        method='pbkdf2:sha256',
                                                        salt_length=8))
        db.session.add(new_user)
        db.session.commit()
        return redirect("/")
    return render_template("register.html", form=form)
예제 #8
0
파일: main.py 프로젝트: Python-ape/TestBlog
def register():
    form = CreateUser()
    if form.validate_on_submit():
        # First check if the email already exists in the database
        if User.query.filter_by(email=form.email.data).first():
            flash("That email already exists")
            return redirect(url_for('login'))
        hash_and_salted_password = generate_password_hash(
            form.password.data, method='pbkdf2:sha256', salt_length=8)
        new_user = User(name=form.name.data,
                        email=form.email.data,
                        password=hash_and_salted_password)
        db.session.add(new_user)
        db.session.commit()
        login_user(new_user)
        return redirect(url_for('get_all_posts'))
    return render_template("register.html",
                           form=form,
                           current_user=current_user)
예제 #9
0
def register():
    """show form to create user"""

    form = CreateUser()

    if form.validate_on_submit():
        username = form.username.data
        password = form.password.data
        email = form.email.data
        first_name = form.first_name.data
        last_name = form.last_name.data

        new_user = User.register(username, password, email, first_name,
                                 last_name)

        db.session.add(new_user)
        db.session.commit()

        session["username"] = username
        return redirect(f"/users/{new_user.username}")
    else:
        return render_template("register-user-form.html", form=form)
예제 #10
0
def dashboard_pi_create(request):
    context = RequestContext(request)

    if request.method == "POST":
        form = CreateUser(request.POST)

        if form.is_valid():
            form.clean_username()
            form.clean()
            new_user = form.save()
            new_user.save()

            g = Group.objects.get(name='Principal_Investigator')
            print(g)
            g.user_set.add(new_user)

            return HttpResponseRedirect(reverse('dashboard_pi_details', args=[new_user.id]))
    else:
        form = CreateUser()

    context_dict = {'form' : form}
    return  render_to_response('dashboard/dashboard_pi_create.html',context_dict,context)
예제 #11
0
def user():
    form = CreateUser(request.form)
    if request.method == 'POST':
        email = request.form['email']
        name = request.form['name']
        password = request.form['password']

        try:
            user = User(email=email, name=name,
                            password=password)
            db.session.add(user)
            db.session.commit()
        except:
            print('Something wrong!')

    return render_template('create_user.html', form=form)
예제 #12
0
def Login():
    form = CreateUser()  # importado do arquivo de forms
    if form.validate_on_submit():
        create_new_user(form.username.data, form.password.data) # create_new_user importado do arquivo de cadastro / inserts
    return render_template('Login.html', form=form)
예제 #13
0
def new_account():
    form = CreateUser()
    if form.validate_on_submit():
        create_new_account(form.name.data, form.password.data) 
    return render_template('createUser.html', form=form)