示例#1
0
 def post(self):
     data=request.get_json()
     user=UserDetail(user_email=data['user_email'],user_name=data['user_name'])
     print(user)
     db_session.add(user)
     db_session.commit()
     print(user)
     return {'Message':'Success'}
示例#2
0
    def post(self):
        name = self.request.get('username')
        password = self.request.get('password')
        verify = self.request.get('verify')
        email = self.request.get('email')
        Name_Error = ''
        Password_Error = ''
        Name_color = 'has-success'
        Password_color = 'has-success'
        if name and password and password == verify:
            val = check_if_user_exist(name, password)
            if val == 1:
                salt = make_salt()
                self.response.headers.add_header(
                    'Set-Cookie', 'user-id={}; Path=/'.format(
                        make_pw_hash(name, password, salt)))
                password_hash = make_pw_hash(name, password, salt)
                user = UserDetail(name=name,
                                  password=password_hash,
                                  email=email)
                key = user.put()
                memcache.set('LOGGED_IN',
                             [name, '/logout', password_hash, key])

                referer = self.get_cookie('referer')
                if referer:
                    self.set_cookie('referer', '')
                    self.redirect(str(referer))
                    return
                self.redirect("/blog")
            else:
                Name_Error = 'User already exist'
                Name_color = 'has-error'
                Password_color = 'has-error'
        else:
            if not name:
                Name_Error = 'Please enter name'
                Name_color = 'has-error'
            if password and not password == verify:
                Password_Error = 'Your password do not match'
                Password_color = 'has-error'
            if not password:
                Password_Error = "Enter valid password"
                Password_color = 'has-error'
        self.render('form.html',
                    name=name,
                    email=email,
                    Name_Error=Name_Error,
                    Password_Error=Password_Error,
                    Name_color=Name_color,
                    Password_color=Password_color)
示例#3
0
def add_detail():
    if current_user.get_role() == '1':
        form = DetailForm()
        if form.validate_on_submit():
            _detail = UserDetail(form.name.data, form.street.data,
                                 form.city.data, form.phone.data,
                                 form.website.data, date.today(),
                                 current_user.get_id())
            _detail.date = datetime.now()
            db.session.add(_detail)
            db.session.commit()
            flash(u'Your details were submitted succsessfully.')
            return redirect(url_for('index'))
        return render_template('add_detail.html', form=form)
    return redirect(url_for('index'))
示例#4
0
def signup():
    try:
        data = request.get_json()
        if all(keys in data for keys in SIGNUP_LST):
            if data['email'].endswith('@fleetstudio.com'):
                sess = Session()
                user_exists = sess.query(UserDetail).filter_by(
                    email=data['email'].lower()).first()
                if not user_exists:
                    sess = Session()
                    new_user = UserDetail(name=data['username'].upper(), passwd=data['password'], \
                                        email=data['email'].lower(), phone=data['phone'])
                    sess.add(new_user)
                    sess.commit()
                    user_name = new_user.name
                    sess.close()
                    return jsonify({
                        "status":
                        201,
                        "result":
                        f"User {user_name} has been created successfully."
                    })
                else:
                    sess.close()
                    return jsonify({
                        "status":
                        200,
                        "result":
                        f"User {user_exists.name} Already Exists. Please Login...."
                    })
            else:
                return jsonify({
                    "status": 200,
                    "result": "Enter a Valid Email-ID"
                })
        else:
            return jsonify({"status": 400, "result": "Error in JSON format"})
    except Exception as exception:
        return jsonify({"status": 500, "result": exception})
示例#5
0
def register_user_details():
    """ Registers a new user details to Xena's UserDetail model.

    :return : Render the common post platform template.
    """

    if request.method == 'POST':
        data = request.form  # access form data from request.
        user_detail = UserDetail(
            user_detail_id=data['user_id'],
            age=data['age'],
            first_name=data['firstname'],
            last_name=data['lastname'],
            address=data['address'],
            contact_num=data['contact_num']
        )
        user_detail.create()  # add details for the specified user.

        return redirect(
            url_for(
                'get_common_posts'
            )
        )
示例#6
0
文件: mock.py 项目: v1ckxy/MSN
 def _add_user(self, email):
     u = User(gen_uuid(), email, True, UserStatus(email))
     self._user_by_uuid[u.uuid] = u
     self._user_by_email[u.email] = u
     self._detail_by_uuid[u.uuid] = UserDetail({})