Commit be913327 authored by Ilham Maulana's avatar Ilham Maulana 💻

feat: rrefactor

parent 977acecd
from django import forms
from .models import Book
"""
title = models.CharField(max_length=150)
author = models.CharField(max_length=50)
publish_date = models.DateTimeField()
rating = models.IntegerField(
default=0, validators=[MaxValueValidator(5), MinValueValidator(0)]
)
isbn = models.CharField(max_length=15, default="xxxxxxxxx-x")
description = models.CharField(max_length=255, blank=True, null=True)
cover_image = models.ImageField(upload_to="uploads", blank=True, null=True)
category = models.ManyToManyField(Category, blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
"""
class BookForm(forms.ModelForm):
class Meta:
......@@ -23,12 +8,6 @@ class BookForm(forms.ModelForm):
fields = "__all__"
widgets = {
"cover_image": forms.FileInput(
attrs={
"placeholder": "Cover Image",
"class": "form-control",
}
),
"title": forms.TextInput(
attrs={
"placeholder": "Title",
......@@ -41,16 +20,21 @@ class BookForm(forms.ModelForm):
"class": "form-control",
}
),
"publish_date": forms.TextInput(
attrs={
"type": "datetime-local",
"class": "form-control",
}
),
"isbn": forms.TextInput(
attrs={
"placeholder": "ISBN",
"class": "form-control",
}
),
"rating": forms.TextInput(
"cover_image": forms.FileInput(
attrs={
"type": "number",
"placeholder": "Rating",
"placeholder": "Cover Image",
"class": "form-control",
}
),
......@@ -59,15 +43,16 @@ class BookForm(forms.ModelForm):
"class": "form-control",
}
),
"description": forms.Textarea(
"rating": forms.TextInput(
attrs={
"placeholder": "Description",
"type": "number",
"placeholder": "Rating",
"class": "form-control",
}
),
"publish_date": forms.TextInput(
"description": forms.Textarea(
attrs={
"type": "number",
"placeholder": "Description",
"class": "form-control",
}
),
......
......@@ -20,9 +20,15 @@
/>
<div class="col">
<h1 class="h2 row">{{ book.title }}</h1>
<p class="h5 row">{{ book.description }}</p>
<p class="h5 row">Stock: {{ book.stock }}</p>
<p class="row badge text-bg-secondary">{{ book.category.name }}</p>
<div class="row d-flex flex-collumn gap-2">
<span class="row">Author: {{ book.author }}</span>
<span class="row">Rating: {{ book.rating }}</span>
<time class="row">Published Date: {{ book.publish_date }}</time>
<div/>
<p class="fs-5 row text-secondary">{{ book.description }}</p>
<p class="row badge text-bg-secondary">{% if book.category.name is None %}uncategories {% else %}{{book.category.name}}{% endif %}</p>
<time datetime="{{ book.created_at }}" class="row fs-6"
>Created at: {{ book.created_at }}</time
>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment