예제 #1
0
    def setUp(self):
        super().setUp()
        db.create_all()

        admin_role = Role(name='admin')
        self.user = User(
            username='******',
            email='*****@*****.**',
            password_hash=
            'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
            enabled=True)
        self.admin = User(
            username='******',
            email='*****@*****.**',
            password_hash=
            'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
            enabled=True,
            roles=[admin_role])
        self.try_add_entities([
            self.user, self.admin, admin_role,
            Currency(code='USD', rate=0.5),
            Currency(code='RUR', rate=0.5),
            Country(id='c1', name='country1'),
            Product(id='0000', name='Test product', price=10, weight=10)
        ])
예제 #2
0
    def setUp(self):
        super().setUp()
        db.create_all()

        admin_role = Role(id=10, name='admin')
        self.try_add_entities([
            User(
                id=0,
                username='******',
                email='*****@*****.**',
                password_hash=
                'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
                enabled=True,
                roles=[admin_role]),
            User(
                id=10,
                username='******',
                email='*****@*****.**',
                password_hash=
                'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
                enabled=True),
            User(
                id=20,
                username='******',
                email='*****@*****.**',
                password_hash=
                'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
                enabled=True), admin_role,
            Currency()
        ])
예제 #3
0
파일: test_api.py 프로젝트: ralfeus/order
    def setUp(self):
        super().setUp()
        self.maxDiff = None

        db.create_all()
        admin_role = Role(id=10, name='admin')
        self.admin = User(
            id=0,
            username='******',
            email='*****@*****.**',
            password_hash=
            'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
            enabled=True,
            roles=[admin_role])
        self.user = User(
            id=10,
            username='******',
            email='*****@*****.**',
            password_hash=
            'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
            enabled=True)
        self.try_add_entities([
            admin_role, self.user, self.admin,
            User(
                id=20,
                username='******',
                email='*****@*****.**',
                password_hash=
                'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
                enabled=True),
            Order(id='test-api-admin-2', user_id=20)
        ])
예제 #4
0
 def setUp(self):
     super().setUp()
     db.create_all()
     
     admin_role = Role(id=10, name='admin')
     self.user = User(id=10, username='******', email='*****@*****.**',
             password_hash='pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576', 
             enabled=True)
     self.admin = User(username='******', email='*****@*****.**',
             password_hash='pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
             enabled=True, roles=[admin_role])
     self.try_add_entities([ self.user, self.admin, admin_role ])
예제 #5
0
 def setUp(self):
     super().setUp()
     db.create_all()
     
     admin_role = Role(name='admin')
     self.user = User(username='******', email='*****@*****.**',
         password_hash='pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576', 
         enabled=True)
     self.admin = User(username='******', email='*****@*****.**',
         password_hash='pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
         enabled=True, roles=[admin_role])
     self.try_add_entities([
         self.user, self.admin, admin_role,
         Currency(code='USD', rate=0.5),
         Currency(code='RUR', rate=0.5)
     ])
예제 #6
0
 def setUp(self):
     super().setUp()
     db.create_all()
     
     admin_role = Role(id=10, name='admin')
     self.try_add_entities([
         User(username='******', email='*****@*****.**',
             password_hash='pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
             enabled=True, roles=[admin_role]),
         User(id=10, username='******', email='*****@*****.**',
             password_hash='pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576', 
             enabled=True),
         admin_role,
         Country(id='c1', name='country1'),
         Currency(code='USD', rate=0.5),
         Product(id='SHIPPING', name='Shipping', weight=0, available=False,
             synchronize=False, separate_shipping=False, purchase=False)
     ])
예제 #7
0
 def setUp(self):
     super().setUp()
     db.create_all()
     admin_role = Role(name='admin')
     self.user = User(
         username='******' + str(__name__),
         email='*****@*****.**',
         password_hash=
         'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
         enabled=True)
     self.admin = User(
         username='******' + str(__name__),
         email='*****@*****.**',
         password_hash=
         'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
         enabled=True,
         roles=[admin_role])
     self.try_add_entities([self.admin, self.user, admin_role])
예제 #8
0
 def setUp(self):
     super().setUp()
     db.create_all()
     self.user = User(
         username='******',
         email='*****@*****.**',
         password_hash=
         'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
         enabled=True)
     self.try_add_entities([
         self.user,
         User(
             username='******',
             email='*****@*****.**',
             password_hash=
             'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
             enabled=False)
     ])
예제 #9
0
def reset_password(token):
    if current_user.is_authenticated:
        return redirect(url_for('users.home'))
    user = User.verify_reset_password_token(token)
    if not user:
        return redirect(url_for('static_views.index'))
    form = ResetPasswordForm()
    if form.validate_on_submit():
        user.set_password(form.password.data)
        user.commit()
        flash('Your password has been reset.')
        return redirect(url_for('static_views.login'))
    return render_template('reset-password.html', form=form)
예제 #10
0
 def setUp(self):
     super().setUp()
     db.create_all()
     self.user = User(
         id=100,
         username='******',
         email='*****@*****.**',
         password_hash=
         'pbkdf2:sha256:150000$bwYY0rIO$320d11e791b3a0f1d0742038ceebf879b8182898cbefee7bf0e55b9c9e9e5576',
         enabled=True)
     try:
         entities = [
             self.user,
             Country(id='c1', name='country1'),
             Currency(code='USD', name='US Dollar', rate=1),
             Currency(code='RUR', name='Russian rouble', rate=1),
             Country(id='c2', name='country2'),
             Shipping(id=1, name='Shipping1'),
             Shipping(id=2, name='Shipping2'),
             Shipping(id=3, name='Shipping3'),
             DHL(),
             ShippingRate(id=1,
                          shipping_method_id=1,
                          destination='c1',
                          weight=100,
                          rate=100),
             ShippingRate(id=5,
                          shipping_method_id=2,
                          destination='c1',
                          weight=200,
                          rate=110),
             ShippingRate(id=2,
                          shipping_method_id=2,
                          destination='c2',
                          weight=100,
                          rate=100),
             ShippingRate(id=3,
                          shipping_method_id=2,
                          destination='c2',
                          weight=1000,
                          rate=150),
             ShippingRate(id=4,
                          shipping_method_id=3,
                          destination='c2',
                          weight=2000,
                          rate=160)
         ]
         db.session.add_all(entities)
         db.session.commit()
     except:
         db.session.rollback()
예제 #11
0
 def create_users(self, count=100):
     queue = []
     # First build a list of specific users.
     for first, last in self.default_users:
         u = self._create_users(first, last, first.lower())
         queue.append(u)
     # Second build a list of random users.
     i = 0
     while i < count:
         u = self._create_users()
         queue.append(u)
         i += 1
     for r in queue:
         user = User(**r)
         user.set_password('testing')
         db.session.add(user)
         t = (r.get('first_name'), r.get('last_name'))
         if t in self.default_users:
             setattr(self, user.first_name.lower(), user)
         try:
             db.session.commit()
         except IntegrityError:
             db.session.rollback()
예제 #12
0
파일: api.py 프로젝트: ralfeus/order
def create_user():
    '''Creates new user'''
    with UserValidator(request) as validator:
        if not validator.validate():
            return jsonify({
                'data': [],
                'error':
                "Couldn't create a user",
                'fieldErrors': [{
                    'name': message.split(':')[0],
                    'status': message.split(':')[1]
                } for message in validator.errors]
            }), 400
    payload = request.get_json()
    user = User(username=payload['username'],
                email=payload['email'],
                phone=payload['phone'],
                atomy_id=payload['atomy_id'],
                enabled=True)
    user.set_password(payload['password'])
    db.session.add(user)
    db.session.commit()
    return jsonify({'data': [user.to_dict()]})
예제 #13
0
파일: api.py 프로젝트: ralfeus/order
def get_user():
    '''Returns list of products in JSON'''
    user_query = User.query
    return jsonify(User.get_user(user_query))