diff options
author | Mike Crute <mcrute@gmail.com> | 2010-01-02 12:48:57 -0500 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2010-01-02 12:48:57 -0500 |
commit | 0100adcca74837ad7b2e7f6d5a416113e11e3fdb (patch) | |
tree | 984340a68ad12434c926c18fb368d3a2a68b7f28 | |
parent | 2eafeb7ed8285fad16f0a3df02b59005f229b65b (diff) | |
download | greenbox-0100adcca74837ad7b2e7f6d5a416113e11e3fdb.tar.bz2 greenbox-0100adcca74837ad7b2e7f6d5a416113e11e3fdb.tar.xz greenbox-0100adcca74837ad7b2e7f6d5a416113e11e3fdb.zip |
Adding pretty ordering
-rw-r--r-- | .hgignore | 5 | ||||
-rwxr-xr-x | greenbox/recipe/models.py | 18 |
2 files changed, 20 insertions, 3 deletions
@@ -1,3 +1,4 @@ | |||
1 | glob:*.pyc | 1 | syntax: glob |
2 | glob:*.db | 2 | *.pyc |
3 | *.db | ||
3 | nohup.out | 4 | nohup.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 | ||
8 | class Unit(models.Model): | 8 | class 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 | ||
17 | class Recipe(models.Model): | 20 | class 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 | ||
32 | class Ingredient(models.Model): | 38 | class 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 | ||
48 | class UnitAdmin(ModelAdmin): | 60 | class UnitAdmin(ModelAdmin): |
49 | 61 | ||
50 | list_display = ('abbreviation', 'name') | 62 | list_display = ('name', 'abbreviation') |
63 | ordering = ('name',) | ||
51 | 64 | ||
52 | 65 | ||
53 | class IngredientInline(TabularInline): | 66 | class IngredientInline(TabularInline): |
54 | 67 | ||
55 | model = RecipeIngredient | 68 | model = RecipeIngredient |
69 | extra = 12 | ||
56 | 70 | ||
57 | 71 | ||
58 | class RecipeAdmin(ModelAdmin): | 72 | class 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 | ||
64 | class IngredientAdmin(ModelAdmin): | 79 | class IngredientAdmin(ModelAdmin): |
65 | 80 | ||
66 | list_display = ('name',) | 81 | list_display = ('name',) |
82 | search_fields = ('name',) | ||
67 | 83 | ||
68 | 84 | ||
69 | admin.site.register(Unit, UnitAdmin) | 85 | admin.site.register(Unit, UnitAdmin) |