A bunch of progress
This commit is contained in:
parent
34c8bae899
commit
a4e58a5fa4
11 changed files with 130 additions and 18 deletions
|
|
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
|||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"django.contrib.humanize",
|
||||
"django_bootstrap5",
|
||||
"reinheit.apps.brew",
|
||||
"reinheit.apps.styles",
|
||||
|
|
@ -58,7 +59,7 @@ ROOT_URLCONF = "config.urls"
|
|||
TEMPLATES = [
|
||||
{
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": [BASE_DIR/"reinheit"/"templates"],
|
||||
"DIRS": [BASE_DIR / "reinheit" / "templates"],
|
||||
"APP_DIRS": True,
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
|
|
@ -120,6 +121,7 @@ USE_TZ = True
|
|||
# https://docs.djangoproject.com/en/5.0/howto/static-files/
|
||||
|
||||
STATIC_URL = "static/"
|
||||
STATICFILES_DIRS = [BASE_DIR / "reinheit" / "static"]
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
|
||||
|
|
|
|||
|
|
@ -3,6 +3,5 @@ from django.contrib import admin
|
|||
|
||||
urlpatterns = [
|
||||
path("admin/", admin.site.urls),
|
||||
|
||||
path("brews/", include(("reinheit.apps.brew.urls", "brew"), namespace="brews"))
|
||||
path("brews/", include(("reinheit.apps.brew.urls", "brew"), namespace="brews")),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -27,10 +27,18 @@ class Brew(models.Model):
|
|||
|
||||
class Addition(models.Model):
|
||||
ingredient = models.ForeignKey("ingredients.Ingredient", on_delete=models.PROTECT)
|
||||
brew = models.ForeignKey("Brew", on_delete=models.CASCADE)
|
||||
brew = models.ForeignKey("Brew", on_delete=models.CASCADE, related_name="additions")
|
||||
|
||||
mass = models.FloatField(help_text="The mass in kg added")
|
||||
added = models.DateTimeField(null=True)
|
||||
|
||||
@property
|
||||
def unit(self):
|
||||
return "g" if self.mass < 0.5 else "kg"
|
||||
|
||||
@property
|
||||
def humanised_mass(self):
|
||||
return 1000 * self.mass if self.mass < 0.5 else self.mass
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.mass}kg of {self.ingredient} in {self.brew}"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
from django.urls import path
|
||||
|
||||
from .views import BrewListView
|
||||
from .views import BrewListView, BrewView
|
||||
|
||||
urlpatterns = [
|
||||
path("brews/", BrewListView.as_view(), name="list")
|
||||
path("brews/", BrewListView.as_view(), name="list"),
|
||||
path("brews/<int:pk>/", BrewView.as_view(), name="brew"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from django.views.generic import ListView
|
||||
from django.views.generic import ListView, DetailView
|
||||
|
||||
from .models import Brew
|
||||
|
||||
|
|
@ -8,7 +8,9 @@ from .models import Brew
|
|||
class BrewListView(ListView):
|
||||
model = Brew
|
||||
|
||||
|
||||
class BrewView(DetailView):
|
||||
model = Brew
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
print(context)
|
||||
return context
|
||||
return super().get_context_data(ingredients=self.object.additions.all(), **kwargs)
|
||||
|
|
|
|||
BIN
reinheit/static/img/brand.png
Normal file
BIN
reinheit/static/img/brand.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
|
|
@ -1,2 +1,52 @@
|
|||
<html>
|
||||
</html>
|
||||
{% extends 'django_bootstrap5/bootstrap5.html' %}
|
||||
{% load static %}
|
||||
{% block bootstrap5_extra_head %}
|
||||
<link rel="icon" type="image/png" href="{% static 'img/brand.png' %}" />
|
||||
{% endblock %}
|
||||
{% block bootstrap5_title %}Reinheit{% endblock %}
|
||||
{% block bootstrap5_before_content %}
|
||||
{% block nav %}
|
||||
<nav class="navbar bg-body-secondary mb-4">
|
||||
<div class="container justify-content-start">
|
||||
<a class="navbar-brand" href="#">
|
||||
<img src="{% static 'img/brand.png' %}"
|
||||
alt="Brand"
|
||||
width="30"
|
||||
height="24"
|
||||
class="d-inline-block align-text-top">
|
||||
Reinheit
|
||||
</a>
|
||||
<div>
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'brew:list' %}">Brews</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{% endblock nav %}
|
||||
{% endblock %}
|
||||
{% block bootstrap5_content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock bootstrap5_content %}
|
||||
{% block bootstrap5_after_content %}
|
||||
<div class="container">
|
||||
<footer class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
|
||||
<ul class="nav col-md-4">
|
||||
<li class="nav-item">
|
||||
<a href="https://www.flaticon.com/free-icons/beer"
|
||||
class="nav-link px-2 text-muted"
|
||||
title="beer icons">Beer icons created by Freepik - Flaticon</a>
|
||||
</li>
|
||||
</ul>
|
||||
</footer>
|
||||
</div>
|
||||
{% endblock bootstrap5_after_content %}
|
||||
|
|
|
|||
12
reinheit/templates/brew/brew_detail.html
Normal file
12
reinheit/templates/brew/brew_detail.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<h2>{{ object.name }}</h2>
|
||||
<h4>{{ object.style }}</h4>
|
||||
<p>{{ object.notes }}</p>
|
||||
<h3>Ingredients</h3>
|
||||
<ul>
|
||||
{% for ingredient in ingredients %}
|
||||
<li>{{ ingredient.humanised_mass }}{{ ingredient.unit }} of {{ ingredient.ingredient.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock content %}
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
{% include "base.html" %}
|
||||
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
{% for brew in brew_list %}
|
||||
{{ brew }}
|
||||
{% endfor %}
|
||||
|
||||
<ul class="list-group">
|
||||
{% for brew in brew_list %}
|
||||
<li class="list-group-item justify-content-between d-flex">
|
||||
<a class="stretched-link" href="{% url 'brews:brew' pk=brew.pk %}">{{ brew.style }}: {{ brew.name }}</a>
|
||||
<span class="text-secondary">{{ brew.pitch_date }}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock content %}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
django
|
||||
django-bootstrap5
|
||||
djlint
|
||||
|
|
|
|||
|
|
@ -2,11 +2,45 @@
|
|||
# uv pip compile requirements/base.in
|
||||
asgiref==3.8.1
|
||||
# via django
|
||||
click==8.1.7
|
||||
# via djlint
|
||||
colorama==0.4.6
|
||||
# via djlint
|
||||
cssbeautifier==1.15.1
|
||||
# via djlint
|
||||
django==5.0.6
|
||||
# via
|
||||
# -r requirements/base.in
|
||||
# django-bootstrap5
|
||||
django-bootstrap5==24.2
|
||||
# via -r requirements/base.in
|
||||
djlint==1.34.1
|
||||
# via -r requirements/base.in
|
||||
editorconfig==0.12.4
|
||||
# via
|
||||
# cssbeautifier
|
||||
# jsbeautifier
|
||||
html-tag-names==0.1.2
|
||||
# via djlint
|
||||
html-void-elements==0.1.0
|
||||
# via djlint
|
||||
jsbeautifier==1.15.1
|
||||
# via
|
||||
# cssbeautifier
|
||||
# djlint
|
||||
json5==0.9.25
|
||||
# via djlint
|
||||
pathspec==0.12.1
|
||||
# via djlint
|
||||
pyyaml==6.0.1
|
||||
# via djlint
|
||||
regex==2023.12.25
|
||||
# via djlint
|
||||
six==1.16.0
|
||||
# via
|
||||
# cssbeautifier
|
||||
# jsbeautifier
|
||||
sqlparse==0.5.0
|
||||
# via django
|
||||
tqdm==4.66.4
|
||||
# via djlint
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue