Beispiel #1
0
    def ycp_signup(self):
        form = YCPRegistrationForm()
        if request.method == 'POST':
            email = session['email']
            try:
                if not any(char in form.password.data
                           for char in string.printable):
                    raise TypeError
                user = User.sign_up(form.username.data, form.password.data,
                                    form.confirm_password.data, email)
                login_user(user)
                return redirect(url_for('IndexView:get'))
            except IntegrityError:
                flash(Markup(f'<b>{form.username.data}</b> is taken'))
            except ValueError as e:
                flash(str(e))
            except TypeError:
                flash(
                    Markup('''<p>Password <b>MUST</b> have at least:</p> 
                                    <ul>
                                        <li>1 Number Character</li>
                                        <li>1 Symbol Character</li>
                                        <li>1 UpperCase character</li>
                                        <li>1 LowerCase character</li>
                                    </ul>'''))
            except Exception as e:
                flash(str(e))

        return render_template('signup.html',
                               form=form,
                               submit_url=url_for('UserView:ycp_signup'))
    def signup(self):
        msg = ''
        form = RegistrationForm()
        if form.validate_on_submit:
            # email = request.form['email']
            option = form.user_types.data
            user = None
            try:
                user = User(username=form.username.data, password=form.password.data, name=form.username.data, is_admin=False)
                user.can_post_provided = (option == 'faculty' or option == 'company')
                user.can_post_solicited = (option == 'faculty' or option == 'student')
                user.sign_up()
                login_user(user, remember=True)
                msg = f"Welcome to the YCP Database {user.name}!"
                return redirect(url_for('IndexView:get'))
            except Exception as e:
                msg = e           
                return render_template('signup.html', msg=str(e), form=form)

        return render_template('signup.html', form=form)
Beispiel #3
0
    def company_signup(self):
        form = CompanyRegistrationForm()
        if request.method == 'POST':
            email = session['email']
            try:
                if not any(char in form.password.data
                           for char in string.printable):
                    raise TypeError
                user = User.sign_up(form.username.data,
                                    form.password.data,
                                    form.confirm_password.data,
                                    email,
                                    bio=form.bio.data,
                                    contact_info=form.contact.data,
                                    name=form.name.data)
                flash(
                    "Welcome to YCP Project Database! Your account requires a review. We'll let you know when you can sign in"
                )
                return redirect(url_for('IndexView:get'))
            except IntegrityError:
                flash(Markup(f'<b>{form.username.data}</b> is taken'))
            except ValueError as e:
                flash(str(e))
            except TypeError:
                flash(
                    Markup('''<p>Password <b>MUST</b> have at least:</p> 
                                    <ul>
                                        <li>1 Number Character</li>
                                        <li>1 Symbol Character</li>
                                        <li>1 UpperCase character</li>
                                        <li>1 LowerCase character</li>
                                    </ul>'''))
            except Exception as e:
                flash(str(e))

        return render_template('signup.html',
                               form=form,
                               submit_url=url_for('UserView:company_signup'))