Exemple #1
0
def create_publishers(num):
    publishers = []
    for i in range(num):
        publisher = Publisher()
        publisher.name = fake.name()
        publisher.founded = fake.date()
        publisher.location = fake.address()
        publishers.append(publisher)
    return publishers
Exemple #2
0
def create_book(num):
    books = []
    publishers = Publisher.objects()
    subscribers = Subscriber.objects()
    for i in range(num):
        book = Book()
        book.title = fake.sentence(nb_words=4)
        book.author.append(fake.name())
        book.pages = fake.pyint(min_value=100, max_value=600)
        book.publish_date = fake.date()
        book.publisher = random.choices(publishers)[0]
        borrow = Borrow()
        borrow.subscriber = random.choices(subscribers)[0]
        borrow.start = fake.date_object()
        borrow.end = borrow.start + datetime.timedelta(
            days=random.randint(14, 60))
        book.borrowing_history.append(borrow)
        books.append(book)
    return books
Exemple #3
0
def create_publisher(name, founded, location):
    publisher = Publisher(name=name, founded=founded, location=location).save()
    return publisher
Exemple #4
0
def get_publisher(publisher):
    publisher = Publisher.objects(id=publisher).first()
    return publisher
Exemple #5
0
def list_publisher():
    publisher = Publisher.objects()
    return publisher