예제 #1
0
def index():
    form = RegisterForm()
    print(form.email)
    print(form.password.validators[0].__dict__)
    print(form.validate_on_submit())
    
    if form.validate_on_submit():
        user = register_user(registration_form=form)
        # current_app.secManager.user_datastore.create_user(first_name= 'pepe',email=form.email.data, password=hash_password(form.password.data))
        # user_datastore.create_user(first_name= 'pepe',email=form.email.data, password=hash_password(form.password.data), username=form.username.data)
        db.session.commit()
        msg = Message("Hello",
            recipients=[form.email.data],
            body = 'el cuerpo del mensaje'
            )
        
        with mail.connect() as conn:
            conn.send(msg)

        return render_template('main',form=form,user=user)
    return register()
예제 #2
0
    def post(self):
        """
        Registers a user.
        JSON params - username (string), password (string)
        Returns - form with inline errors if error, authentication response otherwise.
        """
        data = get_data()
        if data is not None:
            form = self.form_class(MultiDict(data))
        else:
            form = self.form_class()

        if form.validate_on_submit():
            user = register_user(**form.to_dict())
            form.user = user

            if not _security.confirmable or _security.login_without_confirmation:
                after_this_request(_commit)
                login_user(user)

            # This returns the response and the status code.  See function.
            return authentication_response(form)

        return form.as_json(), 400
예제 #3
0
    def post(self):
        """
        Registers a user.
        JSON params - username (string), password (string)
        Returns - form with inline errors if error, authentication response otherwise.
        """
        data = get_data()
        if data is not None:
            form = self.form_class(MultiDict(data))
        else:
            form = self.form_class()

        if form.validate_on_submit():
            user = register_user(**form.to_dict())
            form.user = user

            if not _security.confirmable or _security.login_without_confirmation:
                after_this_request(_commit)
                login_user(user)

            # This returns the response and the status code.  See function.
            return authentication_response(form)

        return form.as_json(), 400
예제 #4
0
파일: app.py 프로젝트: YoongD/simbonsa
def register_users():

    register_user_form = RegisterForm()

    if request.method == 'POST':
        if register_user_form.validate_on_submit():
            user = register_user(**register_user_form.to_dict())
            user.sex = request.form['mf']
            user.grade = request.form['grade']
            if request.form.get('volun1', None):
                user.volun1 = 1
            else:
                user.volun1 = 0

            if request.form.get('volun2', None):
                user.volun2 = 1
            else:
                user.volun2 = 0

            if request.form.get('volun3', None):
                user.volun3 = 1
            else:
                user.volun3 = 0

            if request.form.get('volun4', None):
                user.volun4 = 1
            else:
                user.volun4 = 0

            if request.form.get('volun5', None):
                user.volun5 = 1
            else:
                user.volun5 = 0

            if request.form.get('volun6', None):
                user.volun6 = 1
            else:
                user.volun6 = 0

            if request.form.get('volun7', None):
                user.volun7 = 1
            else:
                user.volun7 = 0

            if request.form.get('volun8', None):
                user.volun8 = 1
            else:
                user.volun8 = 0

            if request.form.get('volun9', None):
                user.volun9 = 1
            else:
                user.volun9 = 0

            if request.form.get('volun10', None):
                user.volun10 = 1
            else:
                user.volun10 = 0
            if request.form.get('volun11', None):
                user.volun11 = 1
            else:
                user.volun11 = 0
            if request.form.get('volun12', None):
                user.volun12 = 1
            else:
                user.volun12 = 0
            if request.form.get('volun13', None):
                user.volun13 = 1
            else:
                user.volun13 = 0
            if request.form.get('volun14', None):
                user.volun14 = 1
            else:
                user.volun14 = 0
            if request.form.get('volun15', None):
                user.volun15 = 1
            else:
                user.volun15 = 0
            if request.form.get('volun16', None):
                user.volun16 = 1
            else:
                user.volun16 = 0
            if request.form.get('volun17', None):
                user.volun17 = 1
            else:
                user.volun17 = 0
            if request.form.get('volun18', None):
                user.volun18 = 1
            else:
                user.volun18 = 0
            if request.form.get('volun19', None):
                user.volun19 = 1
            else:
                user.volun19 = 0
            if request.form.get('volun20', None):
                user.volun20 = 1
            else:
                user.volun20 = 0

            user.prefer_bloc1 = request.form['category']
            user.prefer_sloc1 = request.form['choices']
            user.prefer_bloc2 = request.form['category1']
            user.prefer_sloc2 = request.form['choices1']
            user.prefer_bloc3 = request.form['category2']
            user.prefer_sloc3 = request.form['choices2']

            register_user_form.user = user
            db.session.commit()
            return redirect(url_for('index'))  # register가 완성되면 초기페이지로
        else:
            flash(register_user_form.errors, 'info')
            return render_template("register.html",
                                   register_user_form=register_user_form,
                                   **_ctx('register'))
    else:
        return render_template("register.html",
                               register_user_form=register_user_form)
예제 #5
0
def register_users():
    register_user_form = RegisterForm()

    if request.method == 'POST':
        if register_user_form.validate_on_submit():
            user = register_user(**register_user_form.to_dict())
            user.sex = request.form['mf']
            user.grade = request.form['grade']

            # if request.form.get('volun1', None):
            #     user.volun1 = 1
            # else:
            #     user.volun1 = 0
            #
            # if request.form.get('volun2', None):
            #     user.volun2 = 1
            # else:
            #     user.volun2 = 0
            #
            # if request.form.get('volun3', None):
            #     user.volun3 = 1
            # else:
            #     user.volun3 = 0
            #
            # if request.form.get('volun4', None):
            #     user.volun4 = 1
            # else:
            #     user.volun4 = 0
            #
            # if request.form.get('volun5', None):
            #     user.volun5 = 1
            # else:
            #     user.volun5 = 0
            #
            # if request.form.get('volun6', None):
            #     user.volun6 = 1
            # else:
            #     user.volun6 = 0
            #
            # if request.form.get('volun7', None):
            #     user.volun7 = 1
            # else:
            #     user.volun7 = 0
            #
            # if request.form.get('volun8', None):
            #     user.volun8 = 1
            # else:
            #     user.volun8 = 0
            #
            # if request.form.get('volun9', None):
            #     user.volun9 = 1
            # else:
            #     user.volun9 = 0
            #
            # if request.form.get('volun10', None):
            #     user.volun10 = 1
            # else:
            #     user.volun10 = 0
            # if request.form.get('volun11', None):
            #     user.volun11 = 1
            # else:
            #     user.volun11 = 0
            # if request.form.get('volun12', None):
            #     user.volun12 = 1
            # else:
            #     user.volun12 = 0
            # if request.form.get('volun13', None):
            #     user.volun13 = 1
            # else:
            #     user.volun13 = 0
            # if request.form.get('volun14', None):
            #     user.volun14 = 1
            # else:
            #     user.volun14 = 0
            # if request.form.get('volun15', None):
            #     user.volun15 = 1
            # else:
            #     user.volun15= 0
            # if request.form.get('volun16', None):
            #     user.volun16 = 1
            # else:
            #     user.volun16 = 0
            # if request.form.get('volun17', None):
            #     user.volun17 = 1
            # else:
            #     user.volun17 = 0
            # if request.form.get('volun18', None):
            #     user.volun18 = 1
            # else:
            #     user.volun18 = 0
            # if request.form.get('volun19', None):
            #     user.volun19 = 1
            # else:
            #     user.volun19 = 0
            # if request.form.get('volun20', None):
            #     user.volun20 = 1
            # else:
            #     user.volun20 = 0

            volun1 = 1 if request.form.get('volun1', None) else 0
            volun2 = 1 if request.form.get('volun2', None) else 0
            volun3 = 1 if request.form.get('volun3', None) else 0
            volun4 = 1 if request.form.get('volun4', None) else 0
            volun5 = 1 if request.form.get('volun5', None) else 0
            volun6 = 1 if request.form.get('volun6', None) else 0
            volun7 = 1 if request.form.get('volun7', None) else 0
            volun8 = 1 if request.form.get('volun8', None) else 0
            volun9 = 1 if request.form.get('volun9', None) else 0
            volun10 = 1 if request.form.get('volun10', None) else 0
            volun11 = 1 if request.form.get('volun11', None) else 0
            volun12 = 1 if request.form.get('volun12', None) else 0
            volun13 = 1 if request.form.get('volun13', None) else 0
            volun14 = 1 if request.form.get('volun14', None) else 0
            volun15 = 1 if request.form.get('volun15', None) else 0
            volun16 = 1 if request.form.get('volun16', None) else 0
            volun17 = 1 if request.form.get('volun17', None) else 0
            volun18 = 1 if request.form.get('volun18', None) else 0
            volun19 = 1 if request.form.get('volun19', None) else 0
            volun20 = 1 if request.form.get('volun20', None) else 0
            volun21 = 1 if request.form.get('volun21', None) else 0
            volun22 = 1 if request.form.get('volun22', None) else 0

            recruit1 = 1 if request.form.get('recruit1', None) else 0
            recruit2 = 1 if request.form.get('recruit2', None) else 0
            recruit3 = 1 if request.form.get('recruit3', None) else 0
            recruit4 = 1 if request.form.get('recruit4', None) else 0
            recruit5 = 1 if request.form.get('recruit5', None) else 0
            recruit6 = 1 if request.form.get('recruit6', None) else 0
            recruit7 = 1 if request.form.get('recruit7', None) else 0
            recruit8 = 1 if request.form.get('recruit8', None) else 0
            recruit9 = 1 if request.form.get('recruit9', None) else 0
            recruit10 = 1 if request.form.get('recruit10', None) else 0
            recruit11 = 1 if request.form.get('recruit11', None) else 0

            temp_category = User_category()
            temp_category.id = user.id
            temp_category.category_life = volun1
            temp_category.category_world = volun2
            temp_category.category_environment = volun3
            temp_category.category_human = volun4
            temp_category.category_disaster = volun5
            temp_category.category_country = volun6
            temp_category.category_home = volun7
            temp_category.category_medic = volun8
            temp_category.category_education = volun9
            temp_category.category_administration = volun10
            temp_category.category_consulting = volun11
            temp_category.category_culture = volun12
            temp_category.category_physical = volun13
            temp_category.category_history = volun14
            temp_category.category_circles = volun15
            temp_category.category_travel = volun16
            temp_category.category_marketing = volun17
            temp_category.category_social = volun18
            temp_category.category_plan = volun19
            temp_category.category_language = volun20
            temp_category.category_scene = volun21
            temp_category.category_etc = volun22
            temp_category.recruit_disabled = recruit1
            temp_category.recruit_oldman = recruit2
            temp_category.recruit_foreigner = recruit3
            temp_category.recruit_homeless = recruit4
            temp_category.recruit_multiculture = recruit5
            temp_category.recruit_worker = recruit6
            temp_category.recruit_baby = recruit7
            temp_category.recruit_women = recruit8
            temp_category.recruit_zzokbang = recruit9
            temp_category.recruit_teenager = recruit10
            temp_category.recruit_nation = recruit11

            user.prefer_bloc1 = request.form['category']
            user.prefer_sloc1 = request.form['choices']
            user.prefer_bloc2 = request.form['category1']
            user.prefer_sloc2 = request.form['choices1']
            user.prefer_bloc3 = request.form['category2']
            user.prefer_sloc3 = request.form['choices2']

            user.university = request.form['university']
            user.majoring = request.form['majoring']

            register_user_form.user = user
            db.session.add(temp_category)
            db.session.commit()

            global univer, major
            major = ""
            univer = ""
            return user_detail()
#            return redirect(url_for('user_detail'))  # register가 완성되면 초기페이지로
        else:
            flash(register_user_form.errors, 'info')
            return render_template("register.html",
                                   register_user_form=register_user_form,
                                   **_ctx('register'))
    else:
        return render_template("register.html",
                               register_user_form=register_user_form,
                               univer=univer,
                               major=major)