Пример #1
0
def register():
    title = 'Kekambas Blog | REGISTER'
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        username= form.username.data
        email= form.email.data
        password= form.password.data
        # print(username, email, password)
        # create a new instance of User
        new_user= User(username, email, password)
        # add new instance of our database
        db.session.add(new_user)
        # commit database
        db.session.commit()
        # Send email to new user
        msg= Message(f'Welcome, {username}', [email])
        msg.body = 'Thank you for signing up for the Kekembas blog. I hope you enjoy our app!'
        msg.html = '<p> Thank you so much for signing up for the Kekemnbas blog. I hope you enjoy our app </p>'
        # send email

        mail.send(msg)

        flash('Welcome aboard!', 'success')
        return redirect(url_for("hello_world"))
    return render_template('register.html', title = title, form=form)
Пример #2
0
def register():
    title = ddb + "register"
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        username = form.username.data
        email = form.email.data
        password = form.password.data
        phone = form.phone.data
        address = form.address.data
        city = form.city.data
        zipcode = form.zipcode.data
        # admin = form.admin.data
        # print(username, email, password)

        # create new instance of User
        new_user = User(username, email, password,phone, address, city, zipcode)
        # add new instance to our database
        db.session.add(new_user)
        # commit database
        db.session.commit()

        # send email to new user
        msg = Message(f"Welcome, {username}", [email])
        msg.body = 'Thank you for signing up for the most glorious death of your bugs. I hope you enjoy your new carnage!'
        msg.html = "<p>Thanks you so much for signing up for the Dale's Dead Bugs service. Where we do buggin right! We may, or may not, be in Liberia!</p>"

        mail.send(msg) 

        flash("It may be a crack in your internet, or the Chinese are making their move!", "success")
        return redirect(url_for('index'))
    return render_template('register.html', title=title, form=form)
Пример #3
0
def myInfoUpdate(user_id):
    title = ddb + "Update My Info"
    myinfo = User.query.get_or_404(user_id)
    update_info = UserInfoForm()

    if myinfo.id != current_user.id:
        flash("You cannot update another users info")
        return redirect(url_for('myinfo'))

    if request.method == 'POST' and update_info.validate():
        username = update_info.username.data
        email = update_info.email.data
        password = update_info.password.data
        phone = update_info.phone.data
        address = update_info.address.data
        city = update_info.city.data
        zipcode = update_info.zipcode.data

        myinfo.username = username
        myinfo.email = email
        myinfo.password = generate_password_hash(password)
        myinfo.phone = phone
        myinfo.address = address
        myinfo.city = city
        myinfo.zipcode = zipcode

        db.session.commit()

        flash("You have successfully updated your info")
        return redirect(url_for('myinfo', user_id=current_user.id))
    return render_template('myInfoUpdate.html', title=title, form=update_info)
Пример #4
0
def register():
    title = "Virtual Tour Mates | REGISTER"
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        username = form.username.data
        email = form.email.data
        password = form.password.data
        # print(username, email, password)
        
        # create a new instance of User
        new_user = User(username, email, password)
        # add new instance to our database
        db.session.add(new_user)
        # commit database
        db.session.commit()

        # Send email to new user
        msg = Message(f'Welcome, {username}', [email])
        msg.body = "Thank you for signing up for the Virtual Tour Mates. I hope you enjoy our app!"
        msg.html = "<p>Thank you so much for signing up for the Virtual Tour Mates. I hope you enjoy our app!</p>"

        mail.send(msg)

        flash("You have succesfully signed up!", "success")
        return redirect(url_for('index'))
    return render_template('register.html', title=title, form=form)
def register():
    title = 'REGISTER'
    form = UserInfoForm()
    if request.method == 'POST' and form.validate_on_submit():
        username = form.username.data
        email = form.email.data
        password = form.password.data
        existing_user = User.query.filter((User.username == username)
                                          | (User.email == email)).all()
        if existing_user:
            flash('That username or email already exists. Please try again',
                  'danger')
            return redirect(url_for('register'))

        new_user = User(username, email, password)
        db.session.add(new_user)
        db.session.commit()

        flash(f'Thank you {username} for registering!', 'success')

        msg = Message(f'Thank you, {username}', recipients=[email])
        msg.body = f'Dear {username}, thank you so much for signing up for this super cool app. I hope you enjoy and also you look super good today!'
        mail.send(msg)

        return redirect(url_for('index'))

    return render_template('register.html', title=title, form=form)
Пример #6
0
def register():
    form = UserInfoForm()
    context = {'form': form}
    if request.method == 'POST' and form.validate():

        # Get Information
        username = form.username.data
        email = form.email.data
        password = form.password.data

        print(username, email, password)

        # Create new instance of User
        new_user = User(username, email, password)

        # Add user to db
        db.session.add(new_user)
        db.session.commit()

        # flash success message
        flash("You have successfully registered", 'success')

        # Flask Email Sender
        msg = Message(f'Thanks for signing up, {username}!',
                      recipients=[email])
        msg.body = ('Congrats on signing up! I hope you enjoy our site!!')
        msg.html = ('<h1>Welcome to Our Site</h1>'
                    '<p>This will be super cool!</p>')

        mail.send(msg)

        return redirect(url_for('index'))
    return render_template('register.html', **context)
Пример #7
0
def register():
    title = 'REGISTER'
    form = UserInfoForm()
    if request.method == 'POST' and form.validate_on_submit():
        username = form.username.data
        email = form.email.data
        password = form.password.data
        # print(username, email, password)
        # Check if username/email already exists
        existing_user = User.query.filter((User.username == username)
                                          | (User.email == email)).all()
        if existing_user:
            flash('That username or email already exists. Please try again',
                  'danger')
            return redirect(url_for('register'))

        new_user = User(username, email, password)
        db.session.add(new_user)
        db.session.commit()

        flash(f'Thank you {username} for registering!', 'success')
        return redirect(url_for('index'))

        login_user(user)
    return render_template('register.html', title=title, form=form)
Пример #8
0
def manage_registration():

    # It's a bit ugly to catch 'Other' affiliation here, but this mean not having to overwite
    # any of Flask-User's code for managing users
    # Note - user can ONLY set the temp_custom_affiliation from the register form
    # So this should only happen once
    if current_user.temp_custom_affiliation:
        current_user.affiliation = current_user.temp_custom_affiliation
        current_user.temp_custom_affiliation = None
        db.session.add(current_user)
        db.session.commit()

    form = UserInfoForm(obj=current_user)

    if form.validate_on_submit():
        form.populate_obj(current_user)
        db.session.add(current_user)
        db.session.commit()
        flash('Changes saved', 'success')
        return redirect(url_for('manage_registration'))

    u = User.query.all()
    n_dinner = [x.intends_dinner for x in u].count(True)
    return render_template('manage_registration.html',
                           form=form,
                           n_dinner=n_dinner)
Пример #9
0
def register():
    title = 'Kekembas blog | REGISTER'
    form = UserInfoForm()
    

    if request.method == 'POST' and form.validate():
        username = form.username.data
        email = form.email.data
        password = form.password.data

        print(username,email, password)
        
        #create a new instance of User
        new_user = User(username,email,password)
        #add new instance of use
        db.session.add(new_user)
        #commit database
        db.session.commit()

        #SEND EMAIL TO NEW USER
        msg = Message(f"welcome, {username}", [email])
        msg.body = 'Thank you for siging up for the kekembas blog. I hope you enjoy our blog!'
        msg.html = '<p>Thank you so much for signing up for out blog!</p>'
        
        mail.send(msg)

        flash("You have succesfully signed up!", "success")
        return redirect(url_for('index'))

    return render_template('register.html', title=title,form=form)
Пример #10
0
def register():
    title = "Meridian Meditations | Register"
    form = UserInfoForm()
    if request.methods == 'POST' and form.validate():
        username = form.username.data
        password = form.password.data
        email = form.email.data
        new_user = User(username, email, password)
        db.session.add(new_user)
        db.session.commit()
        flash("Thank you for signing up. Now you can track your meditation history!", "success")
        return redirect(url_for('welcome'))
    return render_template('register.html', title=title, form=form)

# def login():
#     title = "Meridian Meditations | LOGIN"
#     form = LoginForm()
#     if request.methods == 'POST' and form.validate():
#         username = form.username.data
#         password = form.password.data

#         user = User.query.filter_by(username=username).first()

#         if user is None or not check_password_hash(user.password, password):
#             flash("Incorrect Email/Password. Please try again", 'danger')
#             return redirect(url_for('register'))
        
#         login_user(user, remember=form.remember_me.data)
#         flash("You have successfully logged in!", 'success')
#         next_page = request.args.get('next')
#         if next_page:
#             return redirect(url_for('home'))

#     return render_template('register.html', title=title, form=form)


# @app.route('/logout')
# def logout():
#     logout_user()
#     flash("You have succesfully logged out", 'primary')
#     return redirect(url_for('home'))

# # @app.route('/createMcard')
# # @app.route('/createMcard.html', methods=['GET', 'POST'])
# # def createMcard():
# #     title = "Meridian Meditions | Get My Meditation"
# #     form = CreateMcardForm()
# #     if request.method == 'POST' and form.validate():
# #         climate = form.climate.data
# #         taste = form.taste.data
# #         emotions = form.emotions.data
# #           mcard = Mcard()
# #         db.session.commit()
      
         
# #        return render_template("mcards.html", form=form)

    
Пример #11
0
def signup():
    title = "GecMonitor | Sign Up"
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        first_name = form.first_name.data
        last_name = form.last_name.data
        email = form.email.data
        password = form.password.data
        new_user = User(first_name, last_name, email, password)
        db.session.add(new_user)
        db.session.commit()
        flash("You have successfully signed up!", "success")
        return redirect(url_for('index'))
    return render_template('signup.html', title=title, form=form)
Пример #12
0
def register():
    Form = UserInfoForm()
    if request.method == 'POST' and Form.validate():
        username = Form.username.data
        email = Form.email.data
        address = Form.address.data
        phone = Form.phone.data
        password = Form.password.data
        new_user = User(username, email, password, address, phone)
        db.session.add(new_user)
        db.session.commit()
        flash('You have made an account', 'success')
        return render_template('index.html', title='Lucky | Home')
        print(username,email,password)
    return render_template('register.html', title='Lucky | Register', form=UserInfoForm())
Пример #13
0
def register():
    form = UserInfoForm()

    context = {'form': form}
    if request.method == 'POST' and form.validate():

        username = form.username.data
        email = form.email.data
        password = form.password.data

        new_user = User(username, email, password)
        db.session.add(new_user)
        db.session.commit()

        flash("You have successfully registered", 'success')

        return redirect(url_for('index'))
    return render_template('register.html', **context)
Пример #14
0
def register():
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():  # should be ==
        # Get Information
        username = str(form.username.data)
        password = str(form.password.data)
        email = str(form.email.data)
        print("\n", username, password, email)
        # Create an instance of User
        user = User(username, email, password)
        # Open and insert into database
        db.session.add(user)
        # Save info into database
        db.session.commit()

        # Flask Email Sender

    return render_template('register.html', form=form)
Пример #15
0
def register():
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        # Get Information
        id = User.id
        username = form.username.data
        email = form.email.data
        password = form.password.data
        print("\n", username, email, password)
        # Create an instance of User
        user = User(username, email, password)
        # Open and insert into database
        db.session.add(user)
        # Save info into database
        db.session.commit()

        # Flask Email Sender
        return redirect(url_for('login'))
    return render_template('register.html', form=form)
Пример #16
0
def register():
    title = "Phonebook | REGISTER"
    form = UserInfoForm()
    if request.method == "POST" and form.validate():
        username= form.username.data
        password= form.password.data
        email = form.email.data
        phone= form.phone.data

        new_user=User(username, email, phone, password)
        db.session.add(new_user)
        db.session.commit()

        welcome = Message(f'Welcome, {username}', [email])
        welcome.html = '<p>Thank you for signing up! Your phone is now in our phonebook</p>'
        mail.send(welcome)
        flash ("You have added your entry", "success")
        return redirect(url_for("index"))
    return render_template('registerphone.html', title= title, form=form)
Пример #17
0
def register(request):
    registered = False

    if request.method == "POST":
        user_form = UserForm(request.POST)
        details_form = UserInfoForm(request.POST)

        if user_form.is_valid() and details_form.is_valid():
            user = user_form.save()
            user.set_password(user.password)
            user.save()

            details = details_form.save(commit=False)
            details.user = user
            details.save()

            registered = True

        else:
            print(user_form.errors, details_form.errors)

    else:
        user_form = UserForm()
        details_form = UserInfoForm()

    return render(
        request, 'register.html', {
            'user_form': user_form,
            'details_form': details_form,
            'registered': registered
        })
Пример #18
0
def register(request):
    user = request.user
    if user.is_authenticated:
        logout(request)
        return redirect(to='infomanage')
    if request.method == 'POST':
        form = UserInfoForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            user_exist = User.objects.filter(username=username)
            if user_exist:
                messages.add_message(request, messages.ERROR, "用户名已存在,请更换!")
                return redirect(to='register')
            else:
                password = form.cleaned_data['password']
                User.objects.create_user(username=username, password=password)
                try:
                    acc = User.objects.get(username=username)
                    user = UserInfo()
                    user.account = acc
                    user.sex = form.cleaned_data['sex']
                    user.name = form.cleaned_data['username']
                    user.job = form.cleaned_data['job']

                    num = UserInfo.objects.order_by(
                        'job_num').reverse().all()[0].job_num
                    user.job_num = num + 1

                    user.save()
                    str = "注冊成功!"
                    messages.add_message(request, messages.ERROR, str)

                except:
                    print('error')
                    pass
                return redirect(to='login')

    elif request.method == 'GET':
        form = UserInfoForm
        return render(request, 'register.html', {'form': form})
Пример #19
0
def register(request):
    if request.method == 'POST':
        form = UserInfoForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            user_exist = User.objects.filter(username=username)
            if user_exist:
                messages.add_message(request, messages.ERROR, "用户名已存在,请更换!")
                return redirect(to='register')
            else:
                user = UserInfo()
                user.username = form.cleaned_data['username']
                user.password = form.cleaned_data['password']
                user.sex = form.cleaned_data['sex']
                user.job = form.cleaned_data['job']
                user.job_num = form.cleaned_data['job_num']
                user.save()
                login(request, user)
                return redirect(to='infomanage')

    elif request.method == 'GET':
        form = UserInfoForm
        return render(request, 'register.html', {'form': form})