From c3634141a3222a639a5bec2621f72dcdf50fc891 Mon Sep 17 00:00:00 2001 From: Chris Giacofei Date: Fri, 7 Jun 2024 07:54:23 -0400 Subject: [PATCH 1/2] Basic outline of yeast sample page. None of the controls do anything yet. --- beer/models.py | 6 ++ templates/base.html | 23 +++-- yeast/templates/yeast/sample.html | 160 +++++++++++++++++++++++++----- yeast/views.py | 10 +- 4 files changed, 162 insertions(+), 37 deletions(-) diff --git a/beer/models.py b/beer/models.py index 4507e1e..9a6420e 100644 --- a/beer/models.py +++ b/beer/models.py @@ -1,6 +1,8 @@ from django.db import models from django.utils import timezone +from config.extras import BREWFATHER_APP_ROOT + import logging logger = logging.getLogger('django') @@ -18,6 +20,10 @@ class Batch(CustomModel): brewfather_name = models.CharField(max_length=500, default='name') recipe = models.ForeignKey('BatchRecipe', on_delete=models.CASCADE, default=1) + @property + def brewfather_url(self): + return '{}/tabs/batches/batch/{}'.format(BREWFATHER_APP_ROOT, self.brewfather_id) + def __str__(self): # Return a string that represents the instance return 'BF #{num}: {name}'.format(name=self.brewfather_name, num=self.brewfather_num) diff --git a/templates/base.html b/templates/base.html index 24d81b8..61b152b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -8,12 +8,12 @@ - - + + + + + + {% block script %}{% endblock %} @@ -90,8 +99,6 @@ {% block content %}{% endblock %} - - {% block endscript %}{% endblock %} diff --git a/yeast/templates/yeast/sample.html b/yeast/templates/yeast/sample.html index babf62c..0d40cb2 100644 --- a/yeast/templates/yeast/sample.html +++ b/yeast/templates/yeast/sample.html @@ -2,33 +2,143 @@ {% load mathfilters %} {% block title %}Yeast Samples{% endblock %} -{% block jumbotron %}Yeast Sample:{% endblock %} -{% block jumbotronsub %}{{ sample.id }}{% endblock %} +{% block style %} +.table td.fit, +.table th.fit { + white-space: nowrap; + width: 1%; +} +{% endblock %} + +{% block jumbotron %}Yeast Sample{% endblock %} +{% block jumbotronsub %} + + + + + + + + + + + + +
{{ batch.strain.manufacturer.name }} {{ batch.strain.name }}{{ sample.id }}
Batch Source{{ batch.get_source_display }} + {% if batch.source_batch %} + from #{{ batch.beer_num }}: {{ batch.beer_name }}
+ {% endif %} +
Production Date{{ sample.batch.production_date }}
Storage + {{ sample.storage }} + {% if sample.pitched %} + (Pitched #{{ sample.pitched_batch.brewfather_num }}: {{ sample.pitched_batch.brewfather_name }}) + {% endif %} +
+{% endblock %} {% block content %} -
+ +
-

{{ batch.strain.name }}

- Batch Source: {{ batch.get_source_display }} - {% if batch.source_batch %} - from #{{ batch.beer_num }}: {{ batch.beer_name }} - {% endif %}
- Production Date: {{ sample.batch.production_date }}
+
+ + + +
+
+ + +
+ + + + +
+

+ +
+
+ Propogate Yeast Sample +
+ + +
New samples will be automatically created
+
+
+ + +
How will samples be stored?
+
+ +
+
+ +
+

+ +
+
+ Pitch Yeast Sample +
+ + +
Select batch of beer sample is pitched into.
+
+
+ + +
+ +
+
+ +
+
+ +
+ + + +
+ {% if batch.remaining_samples %}

Other Remaining Batch Samples

+
    + {% for s in batch.remaining_samples|dictsort:"storage.name" %} + {% if s.id != sample.id %} +
  • {{ s.id }} - {{ s.storage.name }} for {{ s.age }} days, {{ s.viability|mul:100|floatformat:1 }}%
  • + {% endif %} + {% endfor %} +
+ {% endif %} + {% if batch.used_samples %}

Other Samples Used

+
    + {% for s in batch.used_samples %} + {% if s.id != sample.id %} +
  • {{ s.id }}
  • + {% endif %} + {% endfor %} +
+ {% endif %} +
+ +
+
+ -

- {% if batch.remaining_samples %}

Batch Samples Remaining

- - {% endif %} - {% if batch.used_samples %}

Batch Samples Used

- - {% endif %} -
{% endblock %} diff --git a/yeast/views.py b/yeast/views.py index d8b2f10..26ddcba 100644 --- a/yeast/views.py +++ b/yeast/views.py @@ -6,7 +6,7 @@ from django.urls import reverse from django.http import JsonResponse from django.contrib.auth.decorators import login_required -from yeast.models import Yeast, Batch, Strain +from yeast.models import Yeast, Batch, Strain, Storage from config.extras import AveryLabel from yeast.forms import BatchAddForm, StrainAddForm @@ -21,10 +21,12 @@ class BatchListView(ListView): model = Batch def sample(request, yeast_id): - sample = get_object_or_404(Yeast, pk=yeast_id) - sample_batch = get_object_or_404(Batch, pk=sample.batch_id) - return render(request, 'yeast/sample.html', {'sample': sample, 'batch':sample_batch}) + return render(request, 'yeast/sample.html', { + 'sample': sample, + 'batch': get_object_or_404(Batch, pk=sample.batch_id), + 'storage': list(Storage.objects.all()), + }) # @login_required # def get_batches(request): From 74e8a3135a1158b60ed4887348f0f9d904194a65 Mon Sep 17 00:00:00 2001 From: Chris Giacofei Date: Fri, 7 Jun 2024 08:53:43 -0400 Subject: [PATCH 2/2] Modify admin page a bit. --- equipment/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/equipment/admin.py b/equipment/admin.py index 955f65c..0beb037 100644 --- a/equipment/admin.py +++ b/equipment/admin.py @@ -39,8 +39,8 @@ class MaintenanceAdmin(admin.ModelAdmin): class EquipmentAdmin(admin.ModelAdmin): readonly_fields = ('id',) - list_display = ['id', 'state', 'equipment_type', 'keg_type', 'state'] - list_editable = ['state', 'equipment_type', 'keg_type', 'state'] + list_display = ['id', 'equipment_type', 'keg_type', 'state'] + list_editable = ['state', 'state'] @admin.register(KegType) class KegTypeAdmin(admin.ModelAdmin):