def __init__(self, book_number): self.current_letter = None self.current_words = [] self.word_list = [] for lesson_num in Book.book_lesson_numbers(book_number): lesson = Lesson(lesson_num) self.word_list += lesson.words
def getBookDetails(code): result = auth.checkData() if result['auth']: book = Book(code) result['book'] = book.bookO result['author'] = book.authorO return jsonify({'result': result})
def bookByRating(self, rating: int) -> list: bookList = [] #Get avg rating for each book queryStr = "SELECT book.*, AVG(rating.rating) FROM book INNER JOIN rating on book.isbn = rating.book_isbn GROUP BY book.isbn HAVING AVG(rating.rating) >= " + str( rating) + " ORDER BY AVG(rating.rating) DESC " cur = self.mysql.connection.cursor() cur.execute(queryStr) queryResult = cur.fetchone() # loop through results of query while queryResult is not None: # Each result becomes a Book object and is added to list book = Book(queryResult) book.setRating(queryResult[9]) bookList.append(book) queryResult = cur.fetchone() return bookList
def giveTopSellers(self) -> list: bookList = [] queryStr = "SELECT * FROM book ORDER BY copiesSold DESC LIMIT 10" cur = self.mysql.connection.cursor() cur.execute(queryStr) queryResult = cur.fetchone() # loop through results of query while queryResult is not None: # Each result becomes a Book object and is added to list bookList.append(Book(queryResult)) queryResult = cur.fetchone() return bookList
def bookByGenre(self, genre: str) -> list: bookList = [] queryStr = "SELECT * FROM book WHERE genre = '" + genre + "'" cur = self.mysql.connection.cursor() cur.execute(queryStr) queryResult = cur.fetchone() # loop through results of query while queryResult is not None: # Each result becomes a Book object and is added to list bookList.append(Book(queryResult)) queryResult = cur.fetchone() return bookList
def add_book(): if request.method == 'POST': author_name = request.form['author'].split(' ') author = Author.query.filter(Author.firstName == author_name[0] and Author.lastName == author_name[1]).all() print(author) if author: new_book = Book(isbn=request.form.get('isbn'), bookName=request.form.get('name'), idAuthor=author[0].idAuthor, description=request.form.get('description'), price=request.form.get('price'), publisher=request.form.get('publisher'), yearPublished=request.form.get('yearPublished'), copiesSold=request.form.get('copiesSold'), genre=request.form.get('genre')) db.session.add(new_book) db.session.commit() return redirect(url_for('book_list')) else: flash("author not found") return render_template('newbook.html') if request.method == 'GET': return render_template('newbook.html')
from classes.lesson import Lesson from csv_utils.writer import Writer from csv_utils.common import Common from classes.book import Book def print_lessons(filename, lesson_numbers, word_keys=None): path = Common.GENERATED_PATH + filename lessons = [] for lesson_number in lesson_numbers: lesson_number = int( lesson_number ) if lesson_number[0] == "0" in lesson_number else lesson_number lesson = Lesson(lesson_number) lessons.append(lesson) Writer.write_lessons(path, lessons, word_keys) print_lessons("libro1.csv", Book.book_lesson_numbers(1)) print_lessons("libro2.csv", Book.book_lesson_numbers(2)) print_lessons("palabras-l1-a-l24.csv", Book.all_lesson_numbers()) print_lessons("verbos.csv", Book.all_lesson_numbers(), ['VER']) print_lessons("adverbios.csv", Book.all_lesson_numbers(), ['ADV']) print_lessons("adjetivos.csv", Book.all_lesson_numbers(), ['ADJ'])
def __init__(self, lesson_number, extra=False): self.extra = extra self.lesson_number = lesson_number self.book_number = Book.book_number(lesson_number) self.words = ReaderLesson(self.book_number, lesson_number, extra).generate_words() self.max_lenghts = [max([word.pinyin_l for word in self.words]), max([word.chinese_l for word in self.words])]
def __init__(self, lesson_number, extra=False): self.extra = extra self.lesson_number = lesson_number self.book_number = Book.book_number(lesson_number) self.words = ReaderLesson(self.book_number, lesson_number, extra).generate_words()