From b6be827d14fee4214b2d7849f278b7a9612e0cd4 Mon Sep 17 00:00:00 2001 From: Chris Giacofei Date: Fri, 21 Jun 2024 07:22:50 -0400 Subject: [PATCH] Getting interface ready for modals. --- beer/templates/beer/recipe.html | 106 ++++++++++++++------ beer/templates/beer/update_fermentable.html | 14 +++ beer/templates/beer/update_hop.html | 14 +++ beer/urls.py | 5 +- beer/views.py | 22 +++- config/settings.py | 1 + requirements.txt | 1 + run.sh | 2 + templates/base.html | 36 +++---- 9 files changed, 153 insertions(+), 48 deletions(-) create mode 100644 beer/templates/beer/update_fermentable.html create mode 100644 beer/templates/beer/update_hop.html diff --git a/beer/templates/beer/recipe.html b/beer/templates/beer/recipe.html index 4dd9d86..80c86d1 100644 --- a/beer/templates/beer/recipe.html +++ b/beer/templates/beer/recipe.html @@ -10,6 +10,11 @@ input, label { .container-beer { background: {{ recipe.srm_hex }}; } + +p.smaller { +font-size: .8em; +} + {% endblock %} {% block title %}Recipes{% endblock %} @@ -33,8 +38,14 @@ input, label {
- -
Equipment: {{ recipe.equipment.name }}
+
+
{{ recipe.equipment.name }}
+
+ + + +
+
-
Fermentables ({{ fermentable_weight|floatformat:2 }} lbs)
- +
+
Fermentables ({{ fermentable_weight|floatformat:2 }} lbs)
+
+ + + +
+
+ +
+ + + {% for f in recipe.recipefermentable_set.all %} - +
+

+ Pre-Boil Gravity: {{ recipe.pre_boil_sg }}
+ Original Gravity: {{ recipe.original_sg }}
+ Color: {{ recipe.srm|floatformat:0 }} SRM +

+
{{ f.quantity|floatformat:2 }} lb {{ f.fermentable.name }}
{{ f.fermentable.get_fermentable_type_display }} {{ f.srm }} SRM @@ -78,11 +106,7 @@ input, label { {% endfor %}
-

- Pre-Boil Gravity: {{ recipe.pre_boil_sg }}
- Original Gravity: {{ recipe.original_sg }}
- Color: {{ recipe.srm|floatformat:0 }} SRM -

+
@@ -90,11 +114,24 @@ input, label {
-
Hops ({{ hop_weight|floatformat:2 }} oz)
- +
+
Hops ({{ hop_weight|floatformat:2 }} oz)
+
+ + +
+
+
+ {% for h in recipe.recipehop_set.all %} - +
+

+ Total IBU: {{ recipe.ibu_tinseth|floatformat:1 }}
+ BU/GU: {{ recipe.bu_gu|floatformat:2 }}
+ RBR: {{ recipe.rbr|floatformat:2 }} +

+
{{ h.quantity|floatformat:2 }} oz {{ h.hop.name }} {{ h.hop.alpha|floatformat:1 }} %
{{ h.hop.get_hop_type_display }} {{ h.ibu_tinseth|floatformat:1 }} IBU @@ -103,11 +140,7 @@ input, label { {% endfor %}
-

- Total IBU: {{ recipe.ibu_tinseth|floatformat:1 }}
- BU/GU: {{ recipe.bu_gu|floatformat:2 }}
- RBR: {{ recipe.rbr|floatformat:2 }} -

+
@@ -118,7 +151,12 @@ input, label {
-
Misc.
+
+
Misc.
+
+ +
+
{% for m in recipe.recipemisc_set.all %} @@ -131,7 +169,12 @@ input, label {
-
Yeast
+
+
Yeast
+
+ +
+
{% for y in recipe.recipeyeast_set.all %} @@ -149,7 +192,13 @@ input, label {
-
Mash Profile {{ recipe.mash.name }}
+
+
Mash Profile: {{ recipe.mash.name }}
+
+ + +
+
{% for step in recipe.mash.mashstep_set.all %} @@ -165,14 +214,13 @@ input, label {
-
Fermentation Profile
-
- - - - - -
+
+
Fermentation Profile
+
+ + +
+
diff --git a/beer/templates/beer/update_fermentable.html b/beer/templates/beer/update_fermentable.html new file mode 100644 index 0000000..8d252a1 --- /dev/null +++ b/beer/templates/beer/update_fermentable.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} +{% load mathfilters %} +{% load funcs %} +{% load static %} + + + +{% block title %}Recipes{% endblock %} + +{% block jumbotron %}{{ data.name }}{% endblock %} + +{% block jumbotronsub %} +{{ data.potential }} +{% endblock %} diff --git a/beer/templates/beer/update_hop.html b/beer/templates/beer/update_hop.html new file mode 100644 index 0000000..33aa161 --- /dev/null +++ b/beer/templates/beer/update_hop.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} +{% load mathfilters %} +{% load funcs %} +{% load static %} + + + +{% block title %}Recipes{% endblock %} + +{% block jumbotron %}{{ data.name }}{% endblock %} + +{% block jumbotronsub %} +{{ data.alpha }} % +{% endblock %} diff --git a/beer/urls.py b/beer/urls.py index 0fdd92f..60d8936 100644 --- a/beer/urls.py +++ b/beer/urls.py @@ -1,10 +1,13 @@ from django.urls import path from django.conf import settings from django.conf.urls.static import static -from .views import home, view_recipe +from .views import home, view_recipe, update_ferm, update_hop urlpatterns = [ path('', home, name='home'), path('recipes//', view_recipe, name='recipe'), + path('ingredients/fermentables/', + update_ferm, name='update_fermentable'), + path('ingredients/hops/', update_hop, name='update_hop'), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/beer/views.py b/beer/views.py index e542e88..7cd3cd2 100644 --- a/beer/views.py +++ b/beer/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render, get_object_or_404 -from .models import UserProfile, Recipe, Batch +from .models import UserProfile, Recipe, Batch, Fermentable, Hop from .extras import get_batches import json @@ -51,3 +51,23 @@ def view_recipe(request, recipe_id): } return render(request, 'beer/recipe.html', context) + + +def update_ferm(request, ferm_id): + fermentable = get_object_or_404(Fermentable, pk=ferm_id) + + context = { + 'data': fermentable, + } + + return render(request, 'beer/update_fermentable.html', context) + + +def update_hop(request, hop_id): + hop = get_object_or_404(Hop, pk=hop_id) + + context = { + 'data': hop, + } + + return render(request, 'beer/update_hop.html', context) diff --git a/config/settings.py b/config/settings.py index 56aa657..46503d2 100644 --- a/config/settings.py +++ b/config/settings.py @@ -37,6 +37,7 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'django.contrib.sites', 'django.contrib.flatpages', + 'fontawesomefree', 'mathfilters', 'yeast.apps.YeastLabConfig', 'beer.apps.BeerConfig', diff --git a/requirements.txt b/requirements.txt index 7a3df76..ac1c761 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ django-cryptography-django5==2.2 django-mathfilters==1.0.0 docutils==0.21.2 environs==11.0.0 +fontawesomefree==6.5.1 gunicorn==22.0.0 pip-chill==1.0.3 psycopg2-binary==2.9.9 diff --git a/run.sh b/run.sh index 9aabcc7..6d3fb2f 100755 --- a/run.sh +++ b/run.sh @@ -1,6 +1,8 @@ #! /usr/bin/env bash source .env/bin/activate +find -name "*.py" -not -name "manage.py" -not -path "./.env/*" -not -path "*/migrations/*" -exec python -m flake8 {} \; + pip install --upgrade -r requirements.txt > /dev/null python manage.py makemigrations python manage.py migrate diff --git a/templates/base.html b/templates/base.html index 61b152b..907a6bd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -6,7 +6,9 @@ - + {% load static %} + + @@ -15,14 +17,14 @@ {% block script %}{% endblock %} - + -
- -
+
-
+

{% block jumbotron %}{% endblock %}

@@ -96,8 +98,8 @@

- {% block content %}{% endblock %} -
+ {% block content %}{% endblock %} +
{% block endscript %}{% endblock %}