def reset_db(): db.drop_all() db.create_all() password_1 = hashlib.md5("charisma".encode()).hexdigest() user1 = Users( 'fadzri', 'Charisma Fadzri Triprakoso', '*****@*****.**', password_1, 'jember', '085746363633', 'https://avatars3.githubusercontent.com/u/57993771?s=400&v=4') db.session.add(user1) db.session.commit() password_2 = hashlib.md5("wahyuni".encode()).hexdigest() user2 = Users( 'dwiwahyuni', 'Dwi Umi Wahyuni', '*****@*****.**', password_2, 'Tulungagung', '085749600262', 'https://pbs.twimg.com/profile_images/959677400928862208/4wfFlFCI.jpg') db.session.add(user2) db.session.commit() product1 = Products( "Banpresto Onepiece Stampede Movie", 3, 1000000, "Onepiece", "https://images-na.ssl-images-amazon.com/images/I/511GxF-3htL._SL1000_.jpg", "https://images-na.ssl-images-amazon.com/images/I/51z0wD77tGL._SL1000_.jpg", "https://images-na.ssl-images-amazon.com/images/I/51DdOvafhGL._SL1000_.jpg", "https://images-na.ssl-images-amazon.com/images/I/61Y%2BMTEJbNL._SL1000_.jpg", 1000, "Based on the One Piece: Stampede movie, Monkey D. Luffy joins the DXF series! This figure stands about 6 inches tall and is made of PVC and ABS." ) db.session.add(product1) db.session.commit()
def init_database(): # db.drop.all() db.create_all() salt = uuid.uuid4().hex encoded = ('%s%s' % ('password', salt)).encode('utf-8') hash_pass = hashlib.sha512(encoded).hexdigest() user_internal = Users(full_name="Aisyah Putri Utami", email="*****@*****.**", password=hash_pass, avatar="", status=True, salt=salt) # user_internal = session.query(Users).filter(Users.email=="user_internal").one() # if user_internal is None: # user_internal = Users(full_name="Aisyah Putri Utami", email="*****@*****.**", password=hash_pass, avatar="", status=True, salt=salt) user_noninternal = Users(full_name="aaa", email="*****@*****.**", password=hash_pass, avatar="", status=True, salt=salt) db.session.add(user_internal) db.session.add(user_noninternal) db.session.commit() article = Articles( user_id=1, title="My Cat", text= "Hi, everyone! This is my first post in Medium. Above is my cat. Her name is Lollipop, because she is as sweet as a candy. She’s spoiled, yet so adorable.", image="", image_caption="This is my cat, Lollipop", topic=10, published=True, popular=True, top_article=False, editors_pick=False, ) db.session.add(article) db.session.commit() article_topic = ArticleTopics(topic="Hobbies") db.session.add(article_topic) db.session.commit() yield db db.drop_all()
def init_database(): # create the database and the database table db.create_all() salt = uuid.uuid4().hex encoded = ('%s%s' % ("password", salt)).encode('utf-8') hash_pass = hashlib.sha512(encoded).hexdigest() user_internal1 = Users(username='******', phone_number='085735950340', password=hash_pass, salt=salt, status_internal=True) user_internal2 = Users(username='******', phone_number='085735950342', password=hash_pass, salt=salt, status_internal=True) user_noninternal = Users(username='******', phone_number='085735950341', password=hash_pass, salt=salt, status_internal=False) conversation = Conversations(1, 2) message_group = MessageGroup(1, 1, 'halo') list_group = ListGroup('KITT') member_group = MemberGroup(1, 1) personal_message = PersonalMessages(1, 1, 'tes') status = StatusWA(1, 'status', 'gambar.jpg') db.session.add(user_internal1) db.session.add(user_internal2) db.session.add(user_noninternal) db.session.commit() db.session.add(list_group) db.session.commit() db.session.add(member_group) db.session.commit() db.session.add(message_group) db.session.commit() db.session.add(conversation) db.session.commit() db.session.add(personal_message) db.session.commit() db.session.add(status) db.session.commit() yield db db.drop_all()
def init_database(): db.drop_all() db.create_all() salt = uuid.uuid4().hex encoded = ('%s%s' % ("super_secret_client", salt)).encode('utf-8') hashpass = hashlib.sha512(encoded).hexdigest() encoded2 = ('%s%s' % ("alta123", salt)).encode('utf-8') hashpass2 = hashlib.sha512(encoded2).hexdigest() client_internal = Clients(client_key='internal', client_secret=hashpass, salt=salt, status="True") client_noninternal = Clients(client_key='client1', client_secret=hashpass2, salt=salt, status="False") db.session.add(client_internal) db.session.add(client_noninternal) db.session.commit() user = Users(client_id=1, name='client', age=11, sex='male') db.session.add(user) db.session.commit() yield db db.drop_all()
def post(self): parser = reqparse.RequestParser() parser.add_argument('full_name', location='json') parser.add_argument('username', location='json', required=True) parser.add_argument('password', location='json') parser.add_argument('status', type=bool, location='json') parser.add_argument('email', location='json') parser.add_argument('address', location='json') parser.add_argument('city', location='json') parser.add_argument('telephone', location='json') parser.add_argument('is_deleted', type=bool, location='json') args = parser.parse_args() salt = uuid.uuid4().hex encoded = ('%s%s' % (args['password'], salt)).encode('utf-8') hash_pass = hashlib.sha512(encoded).hexdigest() client = Clients(args['username'], hash_pass, args['status'], salt) db.session.add(client) db.session.flush() user = Users(client.id, args['full_name'], args['email'], args['address'], args['city'], args['telephone'], args['is_deleted']) db.session.add(user) db.session.commit() app.logger.debug('DEBUG: %s', client) app.logger.debug('DEBUG: %s', user) return {'message': 'SUCCESS'}, 200
def init_database(): db.drop_all() db.create_all() salt = uuid.uuid4().hex encoded = ('%s%s' % ('12345', salt)).encode('utf-8') hash_pass = hashlib.sha512(encoded).hexdigest() client_int = Clients(client_key= "altarest", client_secret=hash_pass, status="True", salt=salt) client_noint = Clients(client_key= "alul", client_secret=hash_pass, status="False", salt=salt) db.session.add(client_int) db.session.add(client_noint) db.session.commit() book = Books(title='Judul Buku', isbn="123-456-789", writer="Alul") db.session.add(book) db.session.commit() user = Users (name='Alul', age=23 , sex='Male' , client_id=1 ) db.session.add(user) db.session.commit() rent = Rent(book_id=1, user_id=1) db.session.add(rent) db.session.commit() yield db db.drop_all()
def init_database(): db.drop_all() db.create_all() salt = uuid.uuid4().hex encoded = ('%s%s' % ("password", salt)).encode('utf-8') hash_pass = hashlib.sha512(encoded).hexdigest() user_required = Users(name="shofi", username="******", password=hash_pass, bio="ini shofi", pict_profile="ini pict", pict_bg="ini pict", salt=salt) # user_nonrequired = Users(name="noshofi", username="******", password=hash_pass, bio="ini shofi", pict_profile="ini pict", pict_bg="ini pict", salt=salt, status="false") db.session.add(user_required) # db.session.add(user_nonrequired) db.session.commit() follower = Followers(follower=6, user_id=1) tweet = Tweets(tweet="ini twit", user_id=1) # db.session.add(user) db.session.add(follower) db.session.add(tweet) db.session.commit() yield db
def post(self): parser = reqparse.RequestParser() parser.add_argument('username', location='json', required=True) parser.add_argument('email', location='json', required=True) parser.add_argument('password', location='json', required=True) parser.add_argument('confirm_password', location='json', required=True) args = parser.parse_args() if args['password'] != args['confirm_password']: return {'message': 'Konfirmasi password tidak sesuai'}, 401 else: validation = self.policy.test(args['password']) if validation: list_error = [] for item in validation: split = str(item).split('(') error, num = split[0], split[1][0] list_error.append("{err}(minimum {num})".format(err=error, num=num)) message = "Please check your password: "******"registrasi berhasil, silakan login untuk proses selanjutnya" }, 200, { 'Content-Type': 'application/json' }
def init_database(): db.drop_all() db.create_all() salt = uuid.uuid4().hex encoded = ('%s%s' % ("alta123", salt)).encode('utf-8') hashpass = hashlib.sha512(encoded).hexdigest() encoded2 = ('%s%s' % ("alta123", salt)).encode('utf-8') hashpass2 = hashlib.sha512(encoded2).hexdigest() user_internal = Users(username='******', password=hashpass, email='*****@*****.**', phone='0829718268162', status=True, salt=salt) user_noninternal = Users(username='******', password=hashpass2, email='*****@*****.**', phone='082971868162', status=False, salt=salt) db.session.add(user_internal) db.session.add(user_noninternal) tag = Tags(name='Funny', img_url='facebook.com') db.session.add(tag) db.session.commit() image = Images(img_title='kadal', img_url='facebook.com', deskripsi='aaaa', user_id=1, tag_id=1) db.session.add(image) db.session.commit() komen = Komens(komen='asasa', user_id=1, image_id=1) db.session.add(komen) db.session.commit() yield db db.drop_all()
def init_database(): db.drop_all() db.create_all() salt = uuid.uuid4().hex encode = ('%s%s' % ('password', salt)).encode('utf-8') hash_pass = hashlib.sha512(encode).hexdigest() user = Users(username="******", password=hash_pass, status="user", salt=salt, name="yopi ragil", email="*****@*****.**", no_hp="0812333333", alamat="jombang", avatar="test") usernonInternal = Users(username="******", password=hash_pass, status="admin", salt=salt, name="ragil permana", email="*****@*****.**", no_hp="0812444444", alamat="Malang", avatar="testing") db.session.add(user) db.session.add(usernonInternal) db.session.commit() order = Orders( penjual_id=1, nama_pembeli="Joni", alamat_pembeli="Jl. Tidar, Malang", produk_dipesan="Sikat gigi", harga=10000, status="dikirim", kode_resi="25367718", ) db.session.add(order) db.session.commit() yield db db.drop_all()
def reset_db(): db.drop_all() db.create_all() password = hashlib.md5('Hedyy1'.encode()).hexdigest() user = Users('TEST', password, "hahaha", "hehe", "alamat", 12345, "user") user.image = "lian" db.session.add(user) user = Users('TEST1', password, "hahaha", "hehe", "alamat", 12345, "user") db.session.add(user) agent = Users("Agent", password,"hahaha", "hehe", "alamat", 12345, "agent") agent.image = "bambamb" db.session.add(agent) agent = Users("Agent1", password,"hahaha", "hehe", "alamat", 12345, "agent") db.session.add(agent) seller= Sellers("seller",password,"kuda","ok","ok","ok", 1234,"seller") db.session.add(seller) db.session.commit() product = Products(seller.id,"makanan","makanan",70,100,"wrap",3,True,"sweet") db.session.add(product) db.session.commit()
def reset_db(): db.drop_all() db.create_all() secret = hashlib.md5('FIRST01'.encode()).hexdigest() client = Clients(key='NUMBER01', secret=secret, status=True) db.session.add(client) db.session.commit() user = Users(name='Akira', age=26, sex='Male', client_id=1) db.session.add(user) db.session.commit() book = Books(title='Book01', isbn='123-456-789', writer='Unknown') db.session.add(book) db.session.commit()
def resetDatabase(): db.drop_all() db.create_all() passwordHashed = hashlib.md5("Password1".encode()).hexdigest() recipe = Recipes(1, "name", 1, 1, "beanName", "beanProcess", "beanRoasting", 1, 1, 1, 1) recipe2 = Recipes(2, "name", 1, 1, "beanName", "beanProcess", "beanRoasting", 1, 1, 1, 1) user2 = Users("*****@*****.**", passwordHashed, "name", "photo", "bio") user = Users("*****@*****.**", passwordHashed, "name", "photo", "bio") admin = Users("*****@*****.**", passwordHashed, "name", "photo", "bio") step = Steps(1, 1, 1, "note", 1, 1) step2 = Steps(2, 1, 1, "note", 1, 1) recipeDetail = RecipeDetails(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "note", 2, 92) recipeDetail2 = RecipeDetails(2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "note", 2, 92) bean = Beans(5, "nama11", "photo11", 0.4, 0.2, 0.7, 0.1, 0.8, 0.3, 0.5, 0.2, 0.45, 0.5, "deskripsi", "cupping", "advatage", "disadvantage", "lokasi") # save users to database db.session.add(recipe) db.session.add(recipe2) db.session.add(recipeDetail) db.session.add(recipeDetail2) db.session.add(user2) db.session.add(user) db.session.add(admin) admin.role = 1 db.session.add(step) db.session.add(step2) db.session.add(bean) db.session.commit()
def post(self): parser = reqparse.RequestParser() parser.add_argument('username', location='json', required=True) parser.add_argument('email', location='json', required=True) parser.add_argument('password', location='json', required=True) parser.add_argument('fullname', location='json', required=True) parser.add_argument('address', location='json', required=True) parser.add_argument('contact', location='json', required=True) parser.add_argument('sex', location='json', choices=('F', 'M'), required=True) args = parser.parse_args() salt = uuid.uuid4().hex hs = ('%s%s' % (args['password'], salt)).encode('utf-8') clientsec = hashlib.sha512(hs).hexdigest() args['password'] = clientsec.encode('utf-8') # initiating profil img path img_path = None # initiating role role = 'user' user = Users(args['username'], args['email'], args['password'], salt, img_path, role) db.session.add(user) db.session.flush() bio = Bios(args['fullname'], args['address'], args['contact'], args['sex'], user.id) db.session.add(bio) db.session.commit() app.logger.debug('DEBUG : %s', user) app.logger.debug('DEBUG : %s', bio) rows = [ marshal(user, Users.response_fields), marshal(bio, Bios.response_fields) ] return rows, 200
def post(self): parser = reqparse.RequestParser() parser.add_argument('username', location='json', required=True) parser.add_argument('password', location='json', required=True) parser.add_argument('fullname', location='json', required=True) parser.add_argument('email', location='json', required=True) parser.add_argument('address', location='json', required=True) parser.add_argument('number_phone', location='json', required=True) args = parser.parse_args() validation = self.policy.test(args['password']) if validation: errorList = [] for item in validation: split = str(item).split('(') error, num = split[0], split[1][0] errorList.append("{err}(minimum {num})".format(err=error, num=num)) message = "Please check your password: "******"user" user = Users(args['username'], encrypted, args['fullname'], args['email'], args['address'], args['number_phone'], "user") db.session.add(user) db.session.commit() app.logger.debug('DEBUG : %s', user) return { 'message': "registration success !!!" }, 200, { 'Content-Type': 'application/json' }