add: reading date and release date

This commit is contained in:
starnakin 2024-08-06 13:12:55 +02:00
parent e1d4e4f683
commit a6b0eb17e7
3 changed files with 9 additions and 3 deletions

View File

@ -1,10 +1,12 @@
class Book: class Book:
def __init__(self, name: str, description: str, image: str, review: str) -> None: def __init__(self, name: str, description: str, image: str, review: str, release_date: str, reading_date: str) -> None:
self.name: str = name self.name: str = name
self.description: str = description self.description: str = description
self.image: str = image self.image: str = image
self.review: str = review self.review: str = review
self.release_date: str = release_date
self.reading_date: str = reading_date
def to_html(self) -> str: def to_html(self) -> str:
return f""" return f"""
@ -13,7 +15,9 @@ class Book:
<td class="namedesc-div"> <td class="namedesc-div">
<p class="name">{self.name}</p> <p class="name">{self.name}</p>
<p class="description">{self.description}</p> <p class="description">{self.description}</p>
<p class="release-date">{self.release_date}</p>
</td> </td>
<td class="review-div">{self.review}</td> <td class="review-div">{self.review}</td>
<td class="reading-date">{self.reading_date}</td>
</tr> </tr>
""" """

View File

@ -4,7 +4,9 @@
"name": "1984", "name": "1984",
"description": "1984 est un roman dystopique de l'écrivain britannique George Orwell. Publié le 8 juin 1949 par Secker & Warburg, il s'agit du neuvième et dernier livre d'Orwell achevé de son vivant", "description": "1984 est un roman dystopique de l'écrivain britannique George Orwell. Publié le 8 juin 1949 par Secker & Warburg, il s'agit du neuvième et dernier livre d'Orwell achevé de son vivant",
"image": "1984.jpg", "image": "1984.jpg",
"review": "ct pas mal" "review": "ct pas mal",
"reading_date": "08/2024",
"release_date": "08/06/1949"
} }
] ]
} }

View File

@ -15,7 +15,7 @@ books = data['books']
html = "" html = ""
for book_data in books: for book_data in books:
book = Book(book_data["name"], book_data["description"], book_data["image"], book_data["review"]) book = Book(book_data["name"], book_data["description"], book_data["image"], book_data["review"], book_data["release_date"], book_data["reading_date"])
html += book.to_html() html += book.to_html()
f = open("cast.html") f = open("cast.html")