Compare commits

...

2 Commits

Author SHA1 Message Date
51f37642eb Needed to fix more reference to batch.
Everything seems to work now.
2024-06-07 13:51:15 -04:00
94810ebf8b Activate virtual environment 2024-06-07 13:41:28 -04:00
3 changed files with 6 additions and 16 deletions

1
run.sh Normal file → Executable file
View File

@ -1,3 +1,4 @@
#! /usr/bin/env bash
source .env/bin/activate
python manage.py runserver 0.0.0.0:9595

View File

@ -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, Propogation, Strain
from yeast.models import Yeast, Propogation, Strain, Storage
from config.extras import AveryLabel
from yeast.forms import BatchAddForm, StrainAddForm
@ -24,21 +24,10 @@ def sample(request, yeast_id):
sample = get_object_or_404(Yeast, pk=yeast_id)
return render(request, 'yeast/sample.html', {
'sample': sample,
'batch': get_object_or_404(Propogation, pk=sample.batch_id),
'batch': get_object_or_404(Propogation, pk=sample.propogation_id),
'storage': list(Storage.objects.all()),
})
# @login_required
# def get_batches(request):
# strains = {}
# for strain in Strain.objects.all():
# batches = [x.id for x in Batch.objects.filter(strain=strain)]
# if batches:
# strains[strain.id] = batches
# return JsonResponse(
# {'data': [strains]})
def get_batch(request):
batch_id = int(request.POST.get('batch'))
re_url = reverse('yeast:batch', kwargs={'batch_id': batch_id})
@ -86,8 +75,8 @@ def batch_labels(request, batch_id):
for sample in to_print:
labels.append({
'id': sample.id,
'title': '{} {}'.format(sample.batch.strain.manufacturer.name, sample.batch.strain.name),
'data': ['ID: {}'.format(sample.id), 'Date: {}'.format(sample.batch.production_date)],
'title': '{} {}'.format(sample.propogation.strain.manufacturer.name, sample.propogation.strain.name),
'data': ['ID: {}'.format(sample.id), 'Date: {}'.format(sample.propogation.production_date)],
'blank': False,
'host': request.get_host(),
'template': 'yeast',
@ -111,4 +100,4 @@ class addStrain(CreateView):
def get_success_url(self):
id = self.object.id #gets id from created object
return reverse('yeast:batches')
return reverse('yeast:batches')