summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2010-01-02 12:48:57 -0500
committerMike Crute <mcrute@gmail.com>2010-01-02 12:48:57 -0500
commit0100adcca74837ad7b2e7f6d5a416113e11e3fdb (patch)
tree984340a68ad12434c926c18fb368d3a2a68b7f28
parent2eafeb7ed8285fad16f0a3df02b59005f229b65b (diff)
downloadgreenbox-0100adcca74837ad7b2e7f6d5a416113e11e3fdb.tar.bz2
greenbox-0100adcca74837ad7b2e7f6d5a416113e11e3fdb.tar.xz
greenbox-0100adcca74837ad7b2e7f6d5a416113e11e3fdb.zip
Adding pretty ordering
-rw-r--r--.hgignore5
-rwxr-xr-xgreenbox/recipe/models.py18
2 files changed, 20 insertions, 3 deletions
diff --git a/.hgignore b/.hgignore
index dee9ae3..5ab741f 100644
--- a/.hgignore
+++ b/.hgignore
@@ -1,3 +1,4 @@
1glob:*.pyc 1syntax: glob
2glob:*.db 2*.pyc
3*.db
3nohup.out 4nohup.out
diff --git a/greenbox/recipe/models.py b/greenbox/recipe/models.py
index 1c23eda..0718096 100755
--- a/greenbox/recipe/models.py
+++ b/greenbox/recipe/models.py
@@ -7,6 +7,9 @@ from django.db.models import ForeignKey
7 7
8class Unit(models.Model): 8class Unit(models.Model):
9 9
10 class Meta:
11 ordering = ('name',)
12
10 name = CharField(max_length=100) 13 name = CharField(max_length=100)
11 abbreviation = CharField(max_length=10, blank=True, null=True) 14 abbreviation = CharField(max_length=10, blank=True, null=True)
12 15
@@ -16,6 +19,9 @@ class Unit(models.Model):
16 19
17class Recipe(models.Model): 20class Recipe(models.Model):
18 21
22 class Meta:
23 ordering = ('title',)
24
19 title = CharField(max_length=100) 25 title = CharField(max_length=100)
20 description = TextField(blank=True, null=True) 26 description = TextField(blank=True, null=True)
21 servings = IntegerField(blank=True, null=True) 27 servings = IntegerField(blank=True, null=True)
@@ -31,6 +37,9 @@ class Recipe(models.Model):
31 37
32class Ingredient(models.Model): 38class Ingredient(models.Model):
33 39
40 class Meta:
41 ordering = ('name',)
42
34 name = CharField(max_length=100, unique=True) 43 name = CharField(max_length=100, unique=True)
35 44
36 def __unicode__(self): 45 def __unicode__(self):
@@ -44,26 +53,33 @@ class RecipeIngredient(models.Model):
44 quantity = FloatField() 53 quantity = FloatField()
45 recipe = ForeignKey(Recipe) 54 recipe = ForeignKey(Recipe)
46 55
56 def __unicode__(self):
57 return "{0} in {1}".format(self.ingredient.name, self.recipe.title)
58
47 59
48class UnitAdmin(ModelAdmin): 60class UnitAdmin(ModelAdmin):
49 61
50 list_display = ('abbreviation', 'name') 62 list_display = ('name', 'abbreviation')
63 ordering = ('name',)
51 64
52 65
53class IngredientInline(TabularInline): 66class IngredientInline(TabularInline):
54 67
55 model = RecipeIngredient 68 model = RecipeIngredient
69 extra = 12
56 70
57 71
58class RecipeAdmin(ModelAdmin): 72class RecipeAdmin(ModelAdmin):
59 73
60 list_display = ('title',) 74 list_display = ('title',)
61 inlines = (IngredientInline,) 75 inlines = (IngredientInline,)
76 search_fields = ('title',)
62 77
63 78
64class IngredientAdmin(ModelAdmin): 79class IngredientAdmin(ModelAdmin):
65 80
66 list_display = ('name',) 81 list_display = ('name',)
82 search_fields = ('name',)
67 83
68 84
69admin.site.register(Unit, UnitAdmin) 85admin.site.register(Unit, UnitAdmin)