Add migration and books

This commit is contained in:
gabatxo1312
2026-01-28 00:38:24 +01:00
parent 30be91390b
commit 4cd32831c1
19 changed files with 805 additions and 231 deletions
+68 -38
View File
@@ -1,49 +1,79 @@
{% extends "base.html" %}
{% import "components/typography.html" as typography %}
{% import "components/cards.html" as cards %}
{% block main %}
{{ typography::heading("Editer La petite derniere") }}
{{ typography::heading("Editer") }}
<form>
<div class="mb-3">
<label class="form-label">Name</label>
<input type="text" class="form-control" value="La petite derniere">
</div>
{% call cards::card() %}
<form method="post" action="/books/{{ book.id }}">
<div class="mb-3">
<label class="form-label" for="title">Name</label>
<input type="text" name="title" class="form-control" value="{{ book.title }}" required>
</div>
<div class="mb-3">
<label class="form-label">Author(s)</label>
<input type="text" class="form-control" value="Fatima Daas">
</div>
<div class="mb-3">
<label for="authors" class="form-label">Author(s)</label>
<input type="text" name="authors" class="form-control" value="{{ book.authors }}" required>
</div>
<div class="mb-3">
<label class="form-label">Owner</label>
<select class="form-control">
<option selected>Jean</option>
<option>Simon</option>
</select>
</div>
<div class="mb-3">
<label for="owner_id" class="form-label">Owner</label>
<select name="owner_id" class="form-control" required>
{% for user in users %}
{% if book.owner_id == user.id %}
<option value="{{ user.id }}" selected>{{ user.name }}</option>
{% else %}
<option value="{{ user.id }}">{{ user.name }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="mb-3">
<label class="form-label">Current Holder</label>
<select class="form-control">
<option></option>
<option>Jean</option>
<option selected>Simon</option>
</select>
</div>
<div class="mb-3">
<label for="current_holder_id" class="form-label">Current Holder</label>
<select class="form-control" name="current_holder_id">
<option></option>
{% match book.current_holder_id %}
{% when Some with (current_holder_id) %}
{% for user in users %}
{% if *current_holder_id == user.id %}
<option value="{{ user.id }}" selected>{{ user.name }}</option>
{% else %}
<option value="{{ user.id }}">{{ user.name }}</option>
{% endif %}
{% endfor %}
{% when None %}
{% for user in users %}
<option value="{{ user.id }}">{{ user.name }}</option>
{% endfor %}
{% endmatch %}
</select>
</div>
<div class="mb-3">
<label class="form-label">Description</label>
<textarea class="form-control">dsjfskdljf</textarea>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
{% match book.description %}
{% when Some with (description) %}
<textarea name="description" class="form-control">{{ description }}</textarea>
{% when None %}
<textarea name="description" class="form-control"></textarea>
{% endmatch %}
</div>
<div class="mb-3">
<label class="form-label">Comment</label>
<textarea class="form-control">sdsfjsdkfjsdklfj</textarea>
</div>
<div class="mb-3">
<label class="form-label" for="comment">Comment</label>
{% match book.comment %}
{% when Some with (comment) %}
<textarea name="comment" class="form-control">{{ comment }}</textarea>
{% when None %}
<textarea name="comment" class="form-control"></textarea>
{% endmatch %}
</div>
<div class="mt-4 text-center">
<input type="submit" value="Create book" class="btn btn-success">
</div>
</form>
{% endblock %}
<div class="mt-4 text-center">
<input type="submit" value="Edit book" class="btn btn-success">
</div>
</form>
{% endcall %}
{% endblock %}
+43 -38
View File
@@ -1,49 +1,54 @@
{% extends "base.html" %}
{% import "components/typography.html" as typography %}
{% import "components/cards.html" as cards %}
{% block main %}
{{ typography::heading("New book") }}
{{ typography::heading("New book") }}
<form>
<div class="mb-3">
<label class="form-label">Name</label>
<input type="text" class="form-control">
</div>
{% call cards::card() %}
<form method="post" action="/books">
<div class="mb-3">
<label for="title" class="form-label">Name</label>
<input type="text" name="title" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">Author(s)</label>
<input type="text" class="form-control">
</div>
<div class="mb-3">
<label for="authors" class="form-label">Author(s)</label>
<input type="text" name="authors" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">Owner</label>
<select class="form-control">
<option>Jean</option>
<option>Simon</option>
</select>
</div>
<div class="mb-3">
<label for="owner_id" class="form-label">Owner</label>
<select name="owner_id" class="form-control" required>
{% for user in users %}
<option value="{{ user.id }}">{{ user.name }}</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label class="form-label">Current Holder</label>
<select class="form-control">
<option></option>
<option>Jean</option>
<option>Simon</option>
</select>
</div>
<div class="mb-3">
<label for="current_holder_id" class="form-label">Current Holder</label>
<select name="current_holder_id" class="form-control">
<option></option>
{% for user in users %}
<option value="{{ user.id }}">{{ user.name }}</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label class="form-label">Description</label>
<textarea class="form-control"></textarea>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea name="description" class="form-control"></textarea>
</div>
<div class="mb-3">
<label class="form-label">Comment</label>
<textarea class="form-control"></textarea>
</div>
<div class="mb-3">
<label for="comment" class="form-label">Comment</label>
<textarea name="comment" class="form-control"></textarea>
</div>
<div class="mt-4 text-center">
<input type="submit" value="Create book" class="btn btn-success">
</div>
</form>
{% endblock %}
<div class="mt-4 text-center">
<input type="submit" value="Create book" class="btn btn-success">
</div>
</form>
{% endcall %}
{% endblock %}
+34 -22
View File
@@ -2,30 +2,42 @@
{% import "components/typography.html" as typography %}
{% import "components/dropdown.html" as dropdown %}
{% import "components/fields.html" as fields %}
{% import "components/cards.html" as cards %}
{% block main %}
{% call typography::heading("La petite derniere") %}
{{ dropdown::dropdown_button("Actions", [("Edit", "/books/1/edit"), ("Delete", "/books/1")]) }}
{% endcall %}
{{ typography::book_heading(book.title, book, show = false) }}
<div class="mt-4">
<h5 class="mt-4 fw-bold">Book details</h5>
{{ fields::field("Name", "La petite derniere") }}
{{ fields::field("Authors", "Fatima Daas") }}
{{ fields::field("Authors", "Je mappelle Fatima Daas. Je suis la mazoziya, la petite dernière. Celle à laquelle on ne
sest pas préparé. Française dorigine algérienne. Musulmane pratiquante. Clichoise qui passe plus de trois heures par
jour dans les transports. Une touriste. Une banlieusarde qui observe les comportements parisiens. Je suis une
menteuse, une pécheresse. Adolescente, je suis une élève instable. Adulte, je suis hyper-inadaptée. J’écris des
histoires pour éviter de vivre la mienne. Jai fait quatre ans de thérapie. Cest ma plus longue relation. Lamour,
c’était tabou à la maison, les marques de tendresse, la sexualité aussi. Je me croyais polyamoureuse. Lorsque Nina a
débarqué dans ma vie, je ne savais plus du tout ce dont javais besoin et ce quil me manquait. Je mappelle Fatima
Daas. Je ne sais pas si je porte bien mon prénom.") }}
{% call cards::card() %}
<div class="mt-4">
<h5 class="mt-4 fw-bold">Book details</h5>
{{ fields::field("Name", book.title) }}
{{ fields::field("Authors", book.authors) }}
<h5 class="mt-50px fw-bold">User Details</h5>
{{ fields::field("Owner", "Jean") }}
{{ fields::field("Current Holder", "Pierre") }}
{% match book.description %}
{% when Some with (description) %}
{{ fields::field("Description", description) }}
{% when None %}
{{ fields::field("Description", "-") }}
{% endmatch %}
<h5 class="mt-50px fw-bold">More Informations</h5>
{{ fields::field("Comment", "J'adore ce livre ca parle de plein de choses !") }}
</div>
{% endblock %}
<h5 class="mt-50px fw-bold">User Details</h5>
{{ fields::field("Owner", owner.name) }}
{% match current_holder %}
{% when Some with (current_holder) %}
{{ fields::field("Current Holder", current_holder.name) }}
{% when None %}
{{ fields::field("Current Holder", "-") }}
{% endmatch %}
<h5 class="mt-50px fw-bold">More Informations</h5>
{% match book.comment %}
{% when Some with (comment) %}
{{ fields::field("Comment", comment) }}
{% when None %}
{{ fields::field("Comment", "-") }}
{% endmatch %}
</div>
{% endcall %}
{% endblock %}