Skip to content

Commit

Permalink
Merge pull request #300 from RyanNoelk/dev
Browse files Browse the repository at this point in the history
Dev to Master
  • Loading branch information
RyanNoelk authored Dec 15, 2017
2 parents aac23b4 + f14f579 commit 5e26fcd
Show file tree
Hide file tree
Showing 202 changed files with 9,048 additions and 9,063 deletions.
4 changes: 4 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM python:2.7
ENV PYTHONUNBUFFERED 1

COPY base/prod-entrypoint.sh /startup/
RUN chmod +x /startup/prod-entrypoint.sh

RUN mkdir /code
WORKDIR /code
ADD base/requirements.txt /code/requirements.txt
Expand Down
8 changes: 8 additions & 0 deletions api/base/prod-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh

# Update the DB if it needs it and compile static files.
/code/manage.py migrate --no-input
/code/manage.py collectstatic --no-input

# Start up gunicorn
/code/base/gunicorn_start.sh
9 changes: 1 addition & 8 deletions api/base/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,4 @@ pytz==2016.10

# graphene-django==1.3
git+https://github.com/graphql-python/graphene-django.git@2929d0866c800ae6efa8d35bb40548940a70c31f
git+git://github.com/RyanNoelk/[email protected]

# Will need these once I start supporting metric mesurments
sympy==0.7.6.1
measurement==1.8.0
# Will neeed to add comments for this
# https://github.com/coddingtonbear/django-measurement

graphene==1.4.1
8 changes: 7 additions & 1 deletion api/base/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,13 @@
'rest_framework.authentication.SessionAuthentication'
),
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 100
'PAGE_SIZE': 100,
'DEFAULT_THROTTLE_CLASSES': (
'rest_framework.throttling.AnonRateThrottle',
),
'DEFAULT_THROTTLE_RATES': {
'anon': '100/hour',
}
}

# We don't want the API to serve static in production.
Expand Down
74 changes: 0 additions & 74 deletions api/v1/fixtures/direction_data.json

This file was deleted.

9 changes: 5 additions & 4 deletions api/v1/fixtures/recipe_data.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
[
{
"pk": 1,
"model": "recipe.recipe",
"model": "recipe.recipe",
"fields": {
"info": "This chili is requested every winter by friends and family. I have been making this chili every since I was a small child and learned from my grandma",
"directions": "Brown the ground pork and ground sirlion in a medium pan. Add a teaspoon of sereano pepper while browning the meat. Season with kosher salt and pepper.\nChop the onion, bell pepper and one Serrano pepper and place them in a large pot.\nOpen up and drain both cans of kidney beans and add them to the large pot.\nOpen up both cans of stewed chili style tomatoes and add them to the pot.\nDrain the grease away from the browned meat and add the meat to the pot.\nPour in the tomato juice over the meat mixture.\nAdd kosher salt, black pepper, two table spoons of chili powder, and two teaspoons of ground cumin. Stir well.\nCook slowly over medium low heat for an hour. If it starts to bubble turn down the heat. Taste during the cooking process to check the seasoning add more to taste.",
"cuisine": 1,
"author": 1,
"title": "Tasty Chili",
"course": 2,
"servings": 8,
"rating": 3,
"update_date": "2011-05-21 07:35:32",
"pub_date": "2011-05-21 07:35:32",
"slug": "tasty-chili",
"update_date": "2011-05-21 07:35:32",
"pub_date": "2011-05-21 07:35:32",
"slug": "tasty-chili",
"prep_time": 60,
"cook_time": 60
}
Expand Down
8 changes: 0 additions & 8 deletions api/v1/ingredient/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

from django.db import models
from django.utils.translation import ugettext_lazy as _
from measurement.measures import Volume

from v1.recipe.models import Recipe
from .utils import mass_to_volume_lookup


class IngredientGroup(models.Model):
Expand Down Expand Up @@ -47,9 +45,3 @@ class Meta:

def __unicode__(self):
return '%s' % self.title

def mass_to_volume(self, mass):
# TODO: Be able to convert from Metric to Imperial (America's Crazy system)
amount = float(mass_to_volume_lookup(mass, 'us_cup'))
#self.quantity = Volume(us_cup=amount)
#self.save()
4 changes: 2 additions & 2 deletions api/v1/ingredient/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class IngredientSerializer(serializers.ModelSerializer):
""" Standard `rest_framework` ModelSerializer """
class Meta:
model = Ingredient
fields = '__all__'
fields = ['id', 'quantity', 'measurement', 'title']


class IngredientGroupSerializer(serializers.ModelSerializer):
Expand All @@ -20,4 +20,4 @@ class IngredientGroupSerializer(serializers.ModelSerializer):

class Meta:
model = IngredientGroup
fields = ['title', 'ingredients']
fields = ['id', 'title', 'ingredients']
32 changes: 0 additions & 32 deletions api/v1/ingredient/utils.py

This file was deleted.

1 change: 1 addition & 0 deletions api/v1/list/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def get_node(cls, id, context, info):
class GroceryItemNode(DjangoObjectType):
class Meta:
model = GroceryItem
filter_fields = ['slug', 'list__id']
interfaces = (graphene.relay.Node, )

@classmethod
Expand Down
26 changes: 26 additions & 0 deletions api/v1/recipe/migrations/0009_auto_20171114_1443.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2017-11-14 20:43
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('recipe', '0008_auto_20170806_2059'),
]

operations = [
migrations.AddField(
model_name='recipe',
name='directions',
field=models.TextField(blank=True, help_text='directions', verbose_name='direction_text'),
),
migrations.AlterField(
model_name='direction',
name='recipe',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='old_directions', to='recipe.Recipe', verbose_name='recipe'),
),
]
27 changes: 27 additions & 0 deletions api/v1/recipe/migrations/0010_auto_20171114_1443.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2017-11-14 20:43
from __future__ import unicode_literals

from django.db import migrations


def create_direction_text(apps, schema_editor):
Recipe = apps.get_model('recipe', 'Recipe')
Direction = apps.get_model('recipe', 'Direction')
for recipe in Recipe.objects.all():
directions = ''
for direction in Direction.objects.filter(recipe=recipe).order_by("step"):
directions += direction.title + "\n"
recipe.directions = directions
recipe.save()


class Migration(migrations.Migration):

dependencies = [
('recipe', '0009_auto_20171114_1443'),
]

operations = [
migrations.RunPython(create_direction_text),
]
22 changes: 22 additions & 0 deletions api/v1/recipe/migrations/0011_auto_20171114_1543.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2017-11-14 21:43
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('recipe', '0010_auto_20171114_1443'),
]

operations = [
migrations.RemoveField(
model_name='direction',
name='recipe',
),
migrations.DeleteModel(
name='Direction',
),
]
22 changes: 2 additions & 20 deletions api/v1/recipe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class Recipe(models.Model):
course = models.ForeignKey(Course, verbose_name=_('course'))
tags = models.ManyToManyField(Tag, verbose_name=_('tag'), blank=True)
subrecipes = models.ManyToManyField('self', verbose_name=_('subrecipes'), through='SubRecipe', symmetrical=False)
info = models.TextField(_('info'), help_text="enter information about the recipe")
info = models.TextField(_('info'), help_text="enter information about the recipe", blank=True)
directions = models.TextField(_('direction_text'), help_text="directions", blank=True)
source = models.CharField(_('course'), max_length=200, blank=True)
prep_time = models.IntegerField(_('prep time'), help_text="enter time in minutes")
cook_time = models.IntegerField(_('cook time'), help_text="enter time in minutes")
Expand All @@ -72,22 +73,3 @@ class SubRecipe(models.Model):

def __unicode__(self):
return '%s' % self.parent_recipe.title


class Direction(models.Model):
"""
Django Model to hold a Direction.
Directions share a many to one relationship.
Meaning each Recipe will have many Directions.
:title: = Title of the Direction (EX: Mix flour with the meat.)
:step: = Order of the Directions (EX: 1)
"""
step = models.IntegerField(_('step'))
title = models.TextField(_('title'))
recipe = models.ForeignKey(Recipe, verbose_name=_('recipe'), related_name='directions', null=True)

class Meta:
ordering = ['step']

def __unicode__(self):
return '%s' % self.title
Loading

0 comments on commit 5e26fcd

Please sign in to comment.