def create_user(): from wsgi import bcrypt schema = UserSchema() result = dict() req_data = request.get_json() if 'email' in req_data.keys(): email = req_data['email'] user = User.query.get(email) if user is None: user = User() user.email = req_data['email'] if 'password' in req_data.keys(): password = req_data['password'] pw_hash = bcrypt.generate_password_hash(password) user.password = pw_hash if 'name' in req_data.keys(): user.name = req_data['name'] else: # TODO 존재하면 있다고 리턴 result['msg'] = 'user exists' return jsonify(result), 400 else: user = schema.load(request.json) db.session.add(user) db.session.commit() result['msg'] = "user created" # result['data'] = schema.dump(user) result['data'] = "OK" return jsonify(result)
from app import app, db from models.song import Song, Comment from models.user import UserSchema from models.category import Category from models.forumtopic import Forumtopic, Forumcomment user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() dav, errors = user_schema.load({ 'username': '******', 'email': 'dav@email', 'password': '******', 'password_confirmation': 'pass' }) if errors: raise Exception(errors) wes, errors = user_schema.load({ 'username': '******', 'email': 'wes@email', 'password': '******', 'password_confirmation': 'pass' }) melancholy = Category(name='Melancholy') erratic = Category(name='Erratic')
from models.task import Task from models.task_component import Component from models.event import Event from models.user import UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() sheema, errors = user_schema.load({ 'username': '******', 'email': 'sheema@email', 'password': '******', 'password_confirmation': 'pass', # 'entries': [breakfast], # 'tasks': [project], # 'events': [friday_drinks] }) if errors: raise Exception(errors) entry_one = Entry( date='2019-07-29', what= 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', image='image-url', user=sheema)
from app import app, db from models.user import UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() admin, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'admin123', 'list': [{ 'name': '200g chopped tomatoes', }, { 'name': '500g minced beef' }] }) if errors: raise Exception(errors) db.session.add(admin) # all_recipes = requests.get('https://api.github.com/events').json() # for each_recipe in all_recipes: # print(each_recipe['actor']['id']) # print(each_recipe['strActor'] + ' ' + each_recipe['idActor']).json()
from app import app, db from models.user import UserSchema from models.salary import Salary from models.category import Category user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() # User Data talha, errors = user_schema.load({ 'username': '******', 'email': 'talha@email', 'password': '******', 'password_confirmation': 'pass' }) if errors: raise Exception(errors) jack, errors = user_schema.load({ 'username': '******', 'email': 'jack@email', 'password': '******', 'password_confirmation': 'pass' }) if errors: raise Exception(errors)
from app import app, db from models.recipe import Recipe from models.user import UserSchema from models.cuisine import Cuisine from models.tags import Tag user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() charlie, errors = user_schema.load({ 'username': '******', 'email': 'charlie@email', 'password': '******', 'password_confirmation': 'pass' }) izzi, errors = user_schema.load({ 'username': '******', 'email': 'izzi@email', 'password': '******', 'password_confirmation': 'pass' }) george, errors = user_schema.load({ 'username': '******', 'email': 'george@email', 'password': '******', 'password_confirmation': 'pass' }) cath, errors = user_schema.load({
from app import app, db from models.haiku import Haiku, Comment from models.user import UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() user, errors = user_schema.load({ 'username': '******', 'email': 'lily@email', 'password': '******', 'password_confirmation': 'pass' }) if errors: raise Exception(errors) kasia = Haiku( name='Kasia', text= 'A start-up starter, \n Plant based and is flourishing, \n Always smiling too', portrait=True) cliff = Haiku( name='Cliff', text= 'From a tiny land,\n He can watch sport all day long,\n The next crypto king?', portrait=True) daniela = Haiku(
from models.post import Post, Postcomment user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() # Users kasia, errors = user_schema.load({ 'username': '******', 'name': 'Kasia Wypychewicz', 'bio': 'I’m driven and enthusiastic professional with business background: I hold MSc in Management from LSE and I have experience launching new cross-border ventures across industries. I’ve always been passionate about technology, what lead me to learn JavaScript, Python and SQL.', 'image': 'https://scontent-lht6-1.xx.fbcdn.net/v/t1.0-9/43131042_1986056701433374_8439025766389252096_n.jpg?_nc_cat=109&_nc_oc=AQm1dJoAUpwOuW_NtuALGYW3oeawi6mo2ZL0a6C5afDj3Sd6RHQji-6TIINxGs1Z-p8XXyla7GI6KHBymNuYDD4C&_nc_ht=scontent-lht6-1.xx&oh=08ca6e4a966aaa3278fe7ca45a21ecba&oe=5DADB840', 'email': 'kasia@email', 'password': '******', 'password_confirmation': 'pass' }) michal, errors = user_schema.load({ 'username': '******', 'name': 'Michal Brucek', 'bio': 'I’m driven and enthusiastic professional with business background: I hold MSc in Management from LSE and I have experience launching new cross-border ventures across industries. I’ve always been passionate about technology, what lead me to learn JavaScript, Python and SQL.', 'image': 'https://media.licdn.com/dms/image/C4D03AQE2EzsNpW8IpQ/profile-displayphoto-shrink_200_200/0?e=1569456000&v=beta&t=qQ4PH64M4VRRUYSaxFv8GDd8WeKTbTBdXRt3t6O-aZM', 'email': 'michal@email', 'password': '******',
from models.synth import Synth from models.drum import Drum from models.beat import Beat from models.synth_setting import SynthSetting from models.poly import Poly from models.poly_beat import PolyBeat with app.app_context(): db.drop_all() db.create_all() user_schema = UserSchema() james, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'passpass' }) if errors: raise Exception(errors) db.session.add(james) dex, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'passpass' })
from app import app, db from models.car import Car, Comment from models.user import UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() # drop all the database tables db.create_all() # create all the database tables user, errors = user_schema.load({ 'username': '******', 'email': 'cliff@email', 'password': '******', 'password_confirmation': 'pass' }) if errors: raise Exception(errors) # create some cars ferrari = Car( make="Ferrari", model="SF90", top_speed="211", engine_type="Hybrid Electric", range="16", production_year="2020", image= "https://www.autocar.co.uk/sites/autocar.co.uk/files/styles/gallery_slide/public/images/car-reviews/first-drives/legacy/ferrari_sf90_stradale_3_0.jpg", blurb=
from models.user import UserSchema # UserSchema rather than the user model, as that has the pass verification on it user_schema = UserSchema() # - Use flask’s app_context() function to: # - Drop all tables in the db # - Create all tables in the db: with app.app_context(): db.drop_all() db.create_all() dan, errors = user_schema.load({ 'username': '******', 'email': 'dani@email', 'password': '******', 'password_confirmation': 'pass' }) seb, errors = user_schema.load({ 'username': '******', 'email': 'seb@email', 'password': '******', 'password_confirmation': 'pass' }) dave, errors = user_schema.load({ 'username': '******', 'email': 'dave@email', 'password': '******', 'password_confirmation': 'pass'
ruby = Skill(skill='Ruby') mentoring = Skill(skill='Mentoring') # USER PROFILES amy_wilson, errors = user_schema.load({ 'username': '******', 'email': 'amy@email', 'password': '******', 'password_confirmation': 'pass', 'name': 'Amy Wilson', 'occupation': 'Junior Software Engineer', 'industry': 'Software Engineering', 'location': 'London, United Kingdom', 'description': 'Currently studying Software Engineering at General Assembly in London. I will be embarking on my career within the tech industry from September 2019', 'image': 'https://i.imgur.com/WCByxUF.jpg' }) if errors: raise Exception(errors) amy_wilson.skills = [software_engineering]
from app import app, db from models.year import Year from models.fact import Fact, Comment from models.user import UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() #USER login sim, errors = user_schema.load({ 'username': '******', 'email': 'sim@email', 'password': '******', 'password_confirmation': 'pass' }) if errors: raise Exception(errors) year1938 = Year( year=1938 ) kindertransport = Fact( name='First refugee children of the Kindertransport arrive in Britain', location='Britain', date_of_fact=datetime.strptime('1938-02-12', '%Y-%m-%d'),
shoes = Category(type='Shoes', logo='assets/high-heels.png') shoes.save() wellbeing = Category(type='Well-being', logo='assets/meditation.png') wellbeing.save() beauty = Category(type='Beauty', logo='assets/make-up.png') beauty.save() electronics = Category(type='Electronics', logo='assets/screen.png') electronics.save() zara, errors = user_schema.load({ 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'password', 'location': '1234, test Lane, Test, SE1 1ER', 'lng': '-0.118092', 'lat': '51.509865', 'business_name': 'Zara', 'logo': 'https://s2.qwant.com/thumbr/0x0/e/c/2cfc32d78af019faaed18632e1db55657c26b39c69c32de0191f26062ef778/Zara_logo_website.png?u=https%3A%2F%2Fwww.waldengalleria.com%2Fwp-content%2Fuploads%2Fsites%2F3%2F2017%2F03%2FZara_logo_website.png&q=0&b=1&p=0&a=1', 'hero_image': 'https://s1.qwant.com/thumbr/0x380/2/d/ba333ce18be0b1fe4daf65b39eb2814bfb250dc9cfb0711d364ec345cd520c/171025-joe-and-the-juice-london.jpg?u=https%3A%2F%2Ftimedotcom.files.wordpress.com%2F2017%2F10%2F171025-joe-and-the-juice-london.jpg&q=0&b=1&p=0&a=1', 'is_merchant': 'True' }) if errors: raise Exception(errors) zara.save() joe_and_the_juice, errors = user_schema.load({ 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'password',
from app import app, db from models.image import ImageModel, Note from models.difficulty import Difficulty from models.user import UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() mia, mia_errors = user_schema.load({ 'username': '******', 'email': 'mia@google', 'password': '******', 'password_confirmation': 'pass' }) if mia_errors: raise Exception(mia_errors) sim, sim_errors = user_schema.load({ 'username': '******', 'email': 'sim@google', 'password': '******', 'password_confirmation': 'pass' }) if sim_errors: raise Exception(sim_errors)
from app import app, db from models.user import UserSchema from models.club import Club, ClubComment from models.event import Event user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() Mark, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'image': '', 'password': '******', 'password_confirmation': 'password' }) if errors: raise Exception(errors) Mark.save() Wendy, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'image': '', 'password': '******', 'password_confirmation': 'password' })
from app import app, db from models.video import Video, Comment, Transaction from models.user import UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() henry, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'pass', 'balance': 200000 }) if errors: raise Exception(errors) thierry, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'pass', 'balance': 150000 }) if errors:
from app import app, db from models.corporation import Corporation from models.service import Service from models.user import User, UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() #Here we use the schema to handle the password & password_confirmation # which does not exist as is in the db. jerem, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'wdiwdiwdi' }) if errors: raise Exception(errors) charly = User(username="******", email="*****@*****.**") linda = User(username="******", email="*****@*****.**") db.session.add(jerem) db.session.add(charly) db.session.add(linda) google = Corporation(name='Google', revenue=120000,
from app import app, db from models.blog import Blog, Comment, Profile from models.user import UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() buse, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'password' }) if errors: raise Exception(errors) db.session.add(buse) buse_profile = Profile(creator=buse, user_id=buse.id) db.session.add(buse_profile) mary, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'password' }) mary_profile = Profile(creator=mary, user_id=mary.id)
user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() ################ USERS ######################## mike, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'bio': 'I have absolutely no pleasure in the stimulants in which I sometimes so madly indulge. It has not been in the pursuit of pleasure that I have periled life and reputation and reason. It has been the desperate attempt to escape from torturing memories, from a sense of insupportable loneliness and a dread of some strange impending doom.', 'password': '******', 'password_confirmation': 'password', 'image': 'http://adam1.scripts.mit.edu/blog/wp-content/uploads/2017/08/MikeMcHargueHeadshotOutdoor.jpg' }) if errors: raise Exception(errors) db.session.add(mike) beth, errors = user_schema.load({ 'username': '******',
from app import app, db from models.product import Product from models.business import Business from models.user import UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() user1, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'password' }) if errors: raise Exception(errors) db.session.add(user1) user2, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'password' }) if errors:
from models.story import Story from models.user import UserSchema user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() gaetano, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'pass', 'image_url': 'https://images-na.ssl-images-amazon.com/images/I/71gvLgqIOdL._UX250_.jpg', 'bio': 'Writing historical novels, several of them have been published. Research and blogging about old Italian Traditions, Shadow Yoga, reading books, travel to historical places.' }) if errors: raise Exception(errors) mapping_my_way, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'pass',
from app import app, db from models.user import UserSchema from models.article import Article from models.message import Message user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() carmen, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'passpass' }) if errors: raise Exception(errors) carmen.save() greg, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'bdizzles' }) if errors: raise Exception(errors) greg.save()
}) api_images = api_images + response.json()['hits'] user_schema = UserSchema() with app.app_context(): db.drop_all() db.create_all() # create new users from api users users = [] for user in api_users: user, errors = user_schema.load({ 'username': user['login']['username'], 'email': user['email'], 'password': '******', 'password_confirmation': 'pass', 'picture': user['picture']['large'] }) if errors: raise Exception(errors) user.save() users.append(user) user_1, errors = user_schema.load({ 'username': '******', 'email': '*****@*****.**', 'password': '******', 'password_confirmation': 'pass' }) if errors: