Browse Source

Added a few objects and some recipe data.

master
mike 6 years ago
parent
commit
c331315a60
Signed by: mike
GPG Key ID: EFBDC90BE2BF394F
  1. BIN
      src/.DS_Store
  2. 30
      src/brewtargetData.csv
  3. 1
      src/recibeer/settings.py
  4. BIN
      src/recipes/.DS_Store
  5. 0
      src/recipes/__init__.py
  6. 3
      src/recipes/admin.py
  7. 5
      src/recipes/apps.py
  8. BIN
      src/recipes/management/.DS_Store
  9. 0
      src/recipes/management/__init__.py
  10. BIN
      src/recipes/management/commands/.DS_Store
  11. 0
      src/recipes/management/commands/__init__.py
  12. 52
      src/recipes/management/commands/load_recipe_data.py
  13. 28
      src/recipes/migrations/0001_initial.py
  14. 0
      src/recipes/migrations/__init__.py
  15. 13
      src/recipes/models.py
  16. 3
      src/recipes/tests.py
  17. 3
      src/recipes/views.py

BIN
src/.DS_Store vendored

Binary file not shown.

30
src/brewtargetData.csv

@ -0,0 +1,30 @@
,title,style,brew type,author,batch size,batch size unit,creation date,notes
,Blonde Ale,Blonde Ale,AG,brewtarget,5,Gal,12/23/12,"Refreshing and easy-drinking beer, this blonde is mildly hopped and approachable."
,California Common,California Common,AG,brewtarget,5,Gal,12/23/12,"This California Common is hopped to be bitter, but not overwhelmingly so. The malt tastes and smells of toast, grain, and caramel, and finishes dry."
,Extra Special Bitter,Extra Special Bitter,AG,brewtarget,5,Gal,12/23/12,"This beer has pronounced caramelly sweetness, contrasted against significant hop bitterness as well as complex toasted aromas."
,Scottish 70 Shilling,Scottish 70 Shilling,AG,brewtarget,5,Gal,12/23/12,
,American Pale Ale,American Pale Ale,AG,brewtarget,5,Gal,12/23/12,
,Nut Brown,Nut Brown,AG,brewtarget,5,Gal,12/23/12,
,Robust Porter,Robust Porter,AG,brewtarget,5,Gal,12/23/12,
,Oatmeal Stout,Oatmeal Stout,AG,brewtarget,5,Gal,12/23/12,
,American IPA,American IPA,AG,brewtarget,5,Gal,12/24/12,
,Weizen,Weizen,AG,brewtarget,5,Gal,12/24/12,
,Saison,Saison,AG,brewtarget,5,Gal,12/24/12,
,Berliner Weisse,Berliner Weisse,AG,brewtarget,5,Gal,12/24/12,
,Belgian Blonde Ale,Belgian Blonde Ale,AG,brewtarget,5,Gal,12/24/12,
,American Barleywine,American Barleywine,AG,brewtarget,5,Gal,12/24/12,
,Rauchbier,Rauchbier,AG,brewtarget,5,Gal,12/24/12,
,Blonde Ale - Extract,Blonde Ale,Ex,brewtarget,5,Gal,1/2/13,
,California Common - Extract,California Common,Ex,brewtarget,5,Gal,1/2/13,
,Extra Special Bitter - Extract,Extra Special Bitter,Ex,brewtarget,5,Gal,1/2/13,
,Scottish 70 Shilling - Extract,Scottish 70 Shilling,Ex,brewtarget,5,Gal,1/2/13,
,American Pale Ale - Extract,American Pale Ale,Ex,brewtarget,5,Gal,1/2/13,
,Nut Brown - Extract,Nut Brown,Ex,brewtarget,5,Gal,1/2/13,
,Robust Porter - Extract,Robust Porter,Ex,brewtarget,5,Gal,1/2/13,
,Oatmeal Stout - Extract,Oatmeal Stout,Ex,brewtarget,5,Gal,1/2/13,
,American IPA - Extract,American IPA,Ex,brewtarget,5,Gal,1/2/13,
,Weizen - Extract,Weizen,Ex,brewtarget,5,Gal,1/2/13,
,Saison - Extract,Saison,Ex,brewtarget,5,Gal,1/2/13,
,Berliner Weisse - Extract,Berliner Weisse,Ex,brewtarget,5,Gal,1/2/13,
,Belgian Blonde Ale - Extract,Belgian Blonde Ale,Ex,brewtarget,5,Gal,1/2/13,
,American Barleywine - Extract,American Barleywine,Ex,brewtarget,5,Gal,1/2/13,
1 title style brew type author batch size batch size unit creation date notes
2 Blonde Ale Blonde Ale AG brewtarget 5 Gal 12/23/12 Refreshing and easy-drinking beer, this blonde is mildly hopped and approachable.
3 California Common California Common AG brewtarget 5 Gal 12/23/12 This California Common is hopped to be bitter, but not overwhelmingly so. The malt tastes and smells of toast, grain, and caramel, and finishes dry.
4 Extra Special Bitter Extra Special Bitter AG brewtarget 5 Gal 12/23/12 This beer has pronounced caramelly sweetness, contrasted against significant hop bitterness as well as complex toasted aromas.
5 Scottish 70 Shilling Scottish 70 Shilling AG brewtarget 5 Gal 12/23/12
6 American Pale Ale American Pale Ale AG brewtarget 5 Gal 12/23/12
7 Nut Brown Nut Brown AG brewtarget 5 Gal 12/23/12
8 Robust Porter Robust Porter AG brewtarget 5 Gal 12/23/12
9 Oatmeal Stout Oatmeal Stout AG brewtarget 5 Gal 12/23/12
10 American IPA American IPA AG brewtarget 5 Gal 12/24/12
11 Weizen Weizen AG brewtarget 5 Gal 12/24/12
12 Saison Saison AG brewtarget 5 Gal 12/24/12
13 Berliner Weisse Berliner Weisse AG brewtarget 5 Gal 12/24/12
14 Belgian Blonde Ale Belgian Blonde Ale AG brewtarget 5 Gal 12/24/12
15 American Barleywine American Barleywine AG brewtarget 5 Gal 12/24/12
16 Rauchbier Rauchbier AG brewtarget 5 Gal 12/24/12
17 Blonde Ale - Extract Blonde Ale Ex brewtarget 5 Gal 1/2/13
18 California Common - Extract California Common Ex brewtarget 5 Gal 1/2/13
19 Extra Special Bitter - Extract Extra Special Bitter Ex brewtarget 5 Gal 1/2/13
20 Scottish 70 Shilling - Extract Scottish 70 Shilling Ex brewtarget 5 Gal 1/2/13
21 American Pale Ale - Extract American Pale Ale Ex brewtarget 5 Gal 1/2/13
22 Nut Brown - Extract Nut Brown Ex brewtarget 5 Gal 1/2/13
23 Robust Porter - Extract Robust Porter Ex brewtarget 5 Gal 1/2/13
24 Oatmeal Stout - Extract Oatmeal Stout Ex brewtarget 5 Gal 1/2/13
25 American IPA - Extract American IPA Ex brewtarget 5 Gal 1/2/13
26 Weizen - Extract Weizen Ex brewtarget 5 Gal 1/2/13
27 Saison - Extract Saison Ex brewtarget 5 Gal 1/2/13
28 Berliner Weisse - Extract Berliner Weisse Ex brewtarget 5 Gal 1/2/13
29 Belgian Blonde Ale - Extract Belgian Blonde Ale Ex brewtarget 5 Gal 1/2/13
30 American Barleywine - Extract American Barleywine Ex brewtarget 5 Gal 1/2/13

1
src/recibeer/settings.py

@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'recipes',
] ]
MIDDLEWARE = [ MIDDLEWARE = [

BIN
src/recipes/.DS_Store vendored

Binary file not shown.

0
src/recipes/__init__.py

3
src/recipes/admin.py

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
src/recipes/apps.py

@ -0,0 +1,5 @@
from django.apps import AppConfig
class RecipesConfig(AppConfig):
name = 'recipes'

BIN
src/recipes/management/.DS_Store vendored

Binary file not shown.

0
src/recipes/management/__init__.py

BIN
src/recipes/management/commands/.DS_Store vendored

Binary file not shown.

0
src/recipes/management/commands/__init__.py

52
src/recipes/management/commands/load_recipe_data.py

@ -0,0 +1,52 @@
from csv import DictReader
from datetime import datetime
from django.core.management import BaseCommand
from recipes.models import Recipe
from pytz import UTC
DATETIME_FORMAT = '%m/%d/%y'
# VACCINES_NAMES = [
# 'Canine Parvo',
# 'Canine Distemper',
# 'Canine Rabies',
# 'Canine Leptospira',
# 'Feline Herpes Virus 1',
# 'Feline Rabies',
# 'Feline Leukemia'
# ]
ALREADY_LOADED_ERROR_MESSAGE = """
If you need to reload the data from the CSV file,
first delete the db.sqlite3 file to destroy the database.
Then, run `python manage.py migrate` for a new empty
database with tables"""
class Command(BaseCommand):
# Show this when the user types help
help = "Loads data from the csv into our model"
def handle(self, *args, **options):
if Recipe.objects.exists():
print('Data already loaded...exiting.')
print(ALREADY_LOADED_ERROR_MESSAGE)
return
print("Creating data")
for row in DictReader(open('./brewtargetData.csv')):
recipe = Recipe()
recipe.name = row['title']
recipe.style = row['style']
recipe.author = row['author']
recipe.notes = row['notes']
recipe.batchSize = row['batch size']
recipe.batchSizeUnit = row['batch size unit']
recipe.brewType = row['brew type']
raw_creation_date = row['creation date']
creation_date = UTC.localize(
datetime.strptime(raw_creation_date, DATETIME_FORMAT))
recipe.creationDate = creation_date
recipe.save()

28
src/recipes/migrations/0001_initial.py

@ -0,0 +1,28 @@
# Generated by Django 3.0.2 on 2020-01-22 22:05
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Recipe',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('style', models.CharField(blank=True, max_length=100, null=True)),
('author', models.CharField(blank=True, max_length=100, null=True)),
('notes', models.TextField(blank=True, null=True)),
('batchSize', models.DecimalField(decimal_places=3, max_digits=8)),
('batchSizeUnit', models.CharField(choices=[('Gal', 'Gallons'), ('L', 'Liters')], max_length=3)),
('brewType', models.CharField(choices=[('Ex', 'Extract'), ('BB', 'Brew in a Bag'), ('AG', 'All Grain')], max_length=2)),
('creationDate', models.DateTimeField()),
],
),
]

0
src/recipes/migrations/__init__.py

13
src/recipes/models.py

@ -0,0 +1,13 @@
from django.db import models
class Recipe(models.Model):
BREW_TYPES = [('Ex', 'Extract'),('BB','Brew in a Bag'),('AG','All Grain')]
VOL_UNITS = [('Gal', 'Gallons'),('L', 'Liters')]
name = models.CharField(max_length=100)
style = models.CharField(max_length=100, null=True, blank=True)
author = models.CharField(max_length=100, null=True, blank=True)
notes = models.TextField(null=True, blank=True)
batchSize = models.DecimalField(decimal_places=3, max_digits=8)
batchSizeUnit = models.CharField(choices=VOL_UNITS, max_length=3)
brewType = models.CharField(choices=BREW_TYPES, max_length=2)
creationDate = models.DateTimeField()

3
src/recipes/tests.py

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
src/recipes/views.py

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.
Loading…
Cancel
Save