summaryrefslogtreecommitdiff
path: root/recipe/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'recipe/models.py')
-rw-r--r--recipe/models.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/recipe/models.py b/recipe/models.py
index fc611a3..1db7f42 100644
--- a/recipe/models.py
+++ b/recipe/models.py
@@ -1,5 +1,4 @@
1from django.db import models 1from django.db import models
2from django.db.models import fields
3 2
4 3
5class Unit(models.Model): 4class Unit(models.Model):
@@ -7,8 +6,14 @@ class Unit(models.Model):
7 class Meta: 6 class Meta:
8 ordering = ('name',) 7 ordering = ('name',)
9 8
10 name = fields.CharField(max_length=100) 9 name = models.CharField(max_length=100)
11 abbreviation = fields.CharField(max_length=10, blank=True, null=True) 10 abbreviation = models.CharField(max_length=10, blank=True, null=True)
11 grams = models.DecimalField(max_digits=10, decimal_places=10,
12 blank=True, null=True,
13 help_text="Conversion from this unit to grams (dry measure)")
14 liters = models.DecimalField(max_digits=10, decimal_places=10,
15 blank=True, null=True,
16 help_text="Conversion from this unit to liters (liquid measure)")
12 17
13 def __unicode__(self): 18 def __unicode__(self):
14 return "{0} ({1})".format(self.name, self.abbreviation) 19 return "{0} ({1})".format(self.name, self.abbreviation)
@@ -19,14 +24,14 @@ class Recipe(models.Model):
19 class Meta: 24 class Meta:
20 ordering = ('title',) 25 ordering = ('title',)
21 26
22 title = fields.CharField(max_length=100) 27 title = models.CharField(max_length=100)
23 slug = fields.SlugField(max_length=150) 28 slug = models.SlugField(max_length=150)
24 description = fields.TextField(blank=True, null=True) 29 description = models.TextField(blank=True, null=True)
25 servings = fields.IntegerField(blank=True, null=True) 30 servings = models.IntegerField(blank=True, null=True)
26 instructions = fields.TextField() 31 instructions = models.TextField()
27 oven_temp = fields.IntegerField(blank=True, null=True) 32 oven_temp = models.IntegerField(blank=True, null=True)
28 cook_time = fields.IntegerField(blank=True, null=True, help_text="In minutes") 33 cook_time = models.IntegerField(blank=True, null=True, help_text="In minutes")
29 prep_time = fields.IntegerField(blank=True, null=True, help_text="In minutes") 34 prep_time = models.IntegerField(blank=True, null=True, help_text="In minutes")
30 35
31 def __unicode__(self): 36 def __unicode__(self):
32 return self.title 37 return self.title
@@ -37,7 +42,7 @@ class Ingredient(models.Model):
37 class Meta: 42 class Meta:
38 ordering = ('name',) 43 ordering = ('name',)
39 44
40 name = fields.CharField(max_length=100, unique=True) 45 name = models.CharField(max_length=100, unique=True)
41 46
42 def __unicode__(self): 47 def __unicode__(self):
43 return self.name 48 return self.name
@@ -47,7 +52,7 @@ class RecipeIngredient(models.Model):
47 52
48 ingredient = models.ForeignKey(Ingredient) 53 ingredient = models.ForeignKey(Ingredient)
49 units = models.ForeignKey(Unit) 54 units = models.ForeignKey(Unit)
50 quantity = fields.FloatField() 55 quantity = models.FloatField()
51 recipe = models.ForeignKey(Recipe) 56 recipe = models.ForeignKey(Recipe)
52 57
53 def __unicode__(self): 58 def __unicode__(self):