Ejemplo n.º 1
0
def setup_db():
    users = []
    questions = []
    answers = []

    for _ in range(100):
        user = User(internet.user_name(), "1")
        users.append(user)

    session.add_all(users)
    session.commit()

    for _ in range(10):
        question = Question(lorem.paragraph(2), lorem.paragraphs(10))
        question.author = choice(users)
        questions.append(question)

    session.add_all(questions)
    session.commit()

    for q in questions:
        for _ in range(choice(range(10))):
            answer = Answer(lorem.sentence(10))
            answer.author = choice(users)
            answer.question = q
            answers.append(answer)

    for a in answers:
        for u in users:
            rating = AnswerRating(choice([1, -1]))
            rating.user = u
            a.ratings.append(rating)

    session.add_all(answers)
    session.commit()
Ejemplo n.º 2
0
def create_card():
    return {
        "name":
        name.find_name(),
        "username":
        internet.user_name(),
        "email":
        internet.email(),
        "address": {
            "streetA": address.street_name(),
            "streetB": address.street_address(),
            "streetC": address.street_address(True),
            "streetD": address.secondary_address(),
            "city": address.city(),
            "ukCounty": address.uk_county(),
            "ukCountry": address.uk_country(),
            "zipcode": address.zip_code()
        },
        "phone":
        phone_number.phone_number(),
        "website":
        internet.domain_name(),
        "company": {
            "name": company.company_name(),
            "catchPhrase": company.catch_phrase(),
            "bs": company.bs()
        },
        "posts": [{
            "words": lorem.words(),
            "sentence": lorem.sentence(),
            "sentences": lorem.sentences(),
            "paragraph": lorem.paragraph()
        }, {
            "words": lorem.words(),
            "sentence": lorem.sentence(),
            "sentences": lorem.sentences(),
            "paragraph": lorem.paragraph()
        }, {
            "words": lorem.words(),
            "sentence": lorem.sentence(),
            "sentences": lorem.sentences(),
            "paragraph": lorem.paragraph()
        }]
    }
Ejemplo n.º 3
0
def user_card():
    return {
        "name": name.find_name(),
        "username": internet.user_name(),
        "email": internet.email(),
        "address": {
            "street": address.street_name(),
            "suite": address.secondary_address(),
            "city": address.city(),
            "zipcode": address.zip_code()
        },
        "phone": phone_number.phone_number(),
        "website": internet.domain_name(),
        "company": {
            "name": company.company_name(),
            "catchPhrase": company.catch_phrase(),
            "bs": company.bs()
        }
    }
Ejemplo n.º 4
0
def get_badge_name():
    n = internet.user_name()[0:15]
    n = n.replace('-', ' ')
    n = n.replace('.', ' ')
    n = n.replace('_', ' ')
    return n