diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..ce2e222 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/brewtargetData.csv b/src/brewtargetData.csv new file mode 100644 index 0000000..b0455e4 --- /dev/null +++ b/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, diff --git a/src/recibeer/settings.py b/src/recibeer/settings.py index ff19c77..9a1c479 100644 --- a/src/recibeer/settings.py +++ b/src/recibeer/settings.py @@ -37,6 +37,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'recipes', ] MIDDLEWARE = [ diff --git a/src/recipes/.DS_Store b/src/recipes/.DS_Store new file mode 100644 index 0000000..56886aa Binary files /dev/null and b/src/recipes/.DS_Store differ diff --git a/src/recipes/__init__.py b/src/recipes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/recipes/admin.py b/src/recipes/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/src/recipes/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/src/recipes/apps.py b/src/recipes/apps.py new file mode 100644 index 0000000..076e356 --- /dev/null +++ b/src/recipes/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class RecipesConfig(AppConfig): + name = 'recipes' diff --git a/src/recipes/management/.DS_Store b/src/recipes/management/.DS_Store new file mode 100755 index 0000000..1d89579 Binary files /dev/null and b/src/recipes/management/.DS_Store differ diff --git a/src/recipes/management/__init__.py b/src/recipes/management/__init__.py new file mode 100755 index 0000000..e69de29 diff --git a/src/recipes/management/commands/.DS_Store b/src/recipes/management/commands/.DS_Store new file mode 100755 index 0000000..e80e932 Binary files /dev/null and b/src/recipes/management/commands/.DS_Store differ diff --git a/src/recipes/management/commands/__init__.py b/src/recipes/management/commands/__init__.py new file mode 100755 index 0000000..e69de29 diff --git a/src/recipes/management/commands/load_recipe_data.py b/src/recipes/management/commands/load_recipe_data.py new file mode 100755 index 0000000..aa5f47b --- /dev/null +++ b/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() diff --git a/src/recipes/migrations/0001_initial.py b/src/recipes/migrations/0001_initial.py new file mode 100644 index 0000000..19c10a1 --- /dev/null +++ b/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()), + ], + ), + ] diff --git a/src/recipes/migrations/__init__.py b/src/recipes/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/recipes/models.py b/src/recipes/models.py new file mode 100644 index 0000000..43e6074 --- /dev/null +++ b/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() diff --git a/src/recipes/tests.py b/src/recipes/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/src/recipes/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/src/recipes/views.py b/src/recipes/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/src/recipes/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here.