diff options
author | Mike Crute <mcrute@gmail.com> | 2010-01-01 20:45:15 -0500 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2010-01-01 20:45:15 -0500 |
commit | 2eafeb7ed8285fad16f0a3df02b59005f229b65b (patch) | |
tree | 791f5704b29f8a63f5c15c041338b1c2a0e1377d | |
parent | 5cc2dc378241de31d59d61c74511c25cd5dc7b1a (diff) | |
download | greenbox-2eafeb7ed8285fad16f0a3df02b59005f229b65b.tar.bz2 greenbox-2eafeb7ed8285fad16f0a3df02b59005f229b65b.tar.xz greenbox-2eafeb7ed8285fad16f0a3df02b59005f229b65b.zip |
Addining initial admin interface.
-rw-r--r-- | .hgignore | 3 | ||||
-rwxr-xr-x | greenbox/recipe/models.py | 70 | ||||
-rwxr-xr-x | greenbox/settings.py | 42 | ||||
-rwxr-xr-x | greenbox/urls.py | 6 |
4 files changed, 85 insertions, 36 deletions
diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..dee9ae3 --- /dev/null +++ b/.hgignore | |||
@@ -0,0 +1,3 @@ | |||
1 | glob:*.pyc | ||
2 | glob:*.db | ||
3 | nohup.out | ||
diff --git a/greenbox/recipe/models.py b/greenbox/recipe/models.py index 71a8362..1c23eda 100755 --- a/greenbox/recipe/models.py +++ b/greenbox/recipe/models.py | |||
@@ -1,3 +1,71 @@ | |||
1 | from django.contrib import admin | ||
2 | from django.contrib.admin import ModelAdmin, TabularInline | ||
1 | from django.db import models | 3 | from django.db import models |
4 | from django.db.models import CharField, IntegerField, TextField, FloatField | ||
5 | from django.db.models import ForeignKey | ||
2 | 6 | ||
3 | # Create your models here. | 7 | |
8 | class Unit(models.Model): | ||
9 | |||
10 | name = CharField(max_length=100) | ||
11 | abbreviation = CharField(max_length=10, blank=True, null=True) | ||
12 | |||
13 | def __unicode__(self): | ||
14 | return "{0} ({1})".format(self.name, self.abbreviation) | ||
15 | |||
16 | |||
17 | class Recipe(models.Model): | ||
18 | |||
19 | title = CharField(max_length=100) | ||
20 | description = TextField(blank=True, null=True) | ||
21 | servings = IntegerField(blank=True, null=True) | ||
22 | instructions = TextField() | ||
23 | oven_temp = IntegerField(blank=True, null=True) | ||
24 | cook_time = IntegerField(blank=True, null=True) | ||
25 | prep_time = IntegerField(blank=True, null=True) | ||
26 | |||
27 | |||
28 | def __unicode__(self): | ||
29 | return self.title | ||
30 | |||
31 | |||
32 | class Ingredient(models.Model): | ||
33 | |||
34 | name = CharField(max_length=100, unique=True) | ||
35 | |||
36 | def __unicode__(self): | ||
37 | return self.name | ||
38 | |||
39 | |||
40 | class RecipeIngredient(models.Model): | ||
41 | |||
42 | ingredient = ForeignKey(Ingredient) | ||
43 | units = ForeignKey(Unit) | ||
44 | quantity = FloatField() | ||
45 | recipe = ForeignKey(Recipe) | ||
46 | |||
47 | |||
48 | class UnitAdmin(ModelAdmin): | ||
49 | |||
50 | list_display = ('abbreviation', 'name') | ||
51 | |||
52 | |||
53 | class IngredientInline(TabularInline): | ||
54 | |||
55 | model = RecipeIngredient | ||
56 | |||
57 | |||
58 | class RecipeAdmin(ModelAdmin): | ||
59 | |||
60 | list_display = ('title',) | ||
61 | inlines = (IngredientInline,) | ||
62 | |||
63 | |||
64 | class IngredientAdmin(ModelAdmin): | ||
65 | |||
66 | list_display = ('name',) | ||
67 | |||
68 | |||
69 | admin.site.register(Unit, UnitAdmin) | ||
70 | admin.site.register(Ingredient, IngredientAdmin) | ||
71 | admin.site.register(Recipe, RecipeAdmin) | ||
diff --git a/greenbox/settings.py b/greenbox/settings.py index 6dd5f42..1c9d387 100755 --- a/greenbox/settings.py +++ b/greenbox/settings.py | |||
@@ -1,37 +1,20 @@ | |||
1 | # Django settings for greenbox project. | 1 | SITE_ID = 1 |
2 | 2 | USE_I18N = False | |
3 | DEBUG = True | 3 | DEBUG = True |
4 | TEMPLATE_DEBUG = DEBUG | 4 | TEMPLATE_DEBUG = DEBUG |
5 | 5 | ||
6 | ADMINS = ( | 6 | ADMINS = ( |
7 | # ('Your Name', 'your_email@domain.com'), | 7 | ('Mike Crute', 'mcrute@gmail.com'), |
8 | ) | 8 | ) |
9 | 9 | ||
10 | MANAGERS = ADMINS | 10 | MANAGERS = ADMINS |
11 | 11 | ||
12 | DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | 12 | DATABASE_ENGINE = 'sqlite3' |
13 | DATABASE_NAME = '' # Or path to database file if using sqlite3. | 13 | DATABASE_NAME = 'greenbox.db' |
14 | DATABASE_USER = '' # Not used with sqlite3. | ||
15 | DATABASE_PASSWORD = '' # Not used with sqlite3. | ||
16 | DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. | ||
17 | DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. | ||
18 | |||
19 | # Local time zone for this installation. Choices can be found here: | ||
20 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | ||
21 | # although not all choices may be available on all operating systems. | ||
22 | # If running in a Windows environment this must be set to the same as your | ||
23 | # system time zone. | ||
24 | TIME_ZONE = 'America/Chicago' | ||
25 | 14 | ||
26 | # Language code for this installation. All choices can be found here: | 15 | TIME_ZONE = 'America/New_York' |
27 | # http://www.i18nguy.com/unicode/language-identifiers.html | ||
28 | LANGUAGE_CODE = 'en-us' | 16 | LANGUAGE_CODE = 'en-us' |
29 | 17 | ROOT_URLCONF = 'greenbox.urls' | |
30 | SITE_ID = 1 | ||
31 | |||
32 | # If you set this to False, Django will make some optimizations so as not | ||
33 | # to load the internationalization machinery. | ||
34 | USE_I18N = True | ||
35 | 18 | ||
36 | # Absolute path to the directory that holds media. | 19 | # Absolute path to the directory that holds media. |
37 | # Example: "/home/media/media.lawrence.com/" | 20 | # Example: "/home/media/media.lawrence.com/" |
@@ -45,16 +28,13 @@ MEDIA_URL = '' | |||
45 | # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a | 28 | # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a |
46 | # trailing slash. | 29 | # trailing slash. |
47 | # Examples: "http://foo.com/media/", "/media/". | 30 | # Examples: "http://foo.com/media/", "/media/". |
48 | ADMIN_MEDIA_PREFIX = '/media/' | 31 | ADMIN_MEDIA_PREFIX = '/recipe/media/' |
49 | 32 | ||
50 | # Make this unique, and don't share it with anybody. | ||
51 | SECRET_KEY = 'zki4e4!80ar7^1w6f_c2u^5#=r(7#4%0u^3il^@__#3zf^u+f)' | 33 | SECRET_KEY = 'zki4e4!80ar7^1w6f_c2u^5#=r(7#4%0u^3il^@__#3zf^u+f)' |
52 | 34 | ||
53 | # List of callables that know how to import templates from various sources. | ||
54 | TEMPLATE_LOADERS = ( | 35 | TEMPLATE_LOADERS = ( |
55 | 'django.template.loaders.filesystem.load_template_source', | 36 | 'django.template.loaders.filesystem.load_template_source', |
56 | 'django.template.loaders.app_directories.load_template_source', | 37 | 'django.template.loaders.app_directories.load_template_source', |
57 | # 'django.template.loaders.eggs.load_template_source', | ||
58 | ) | 38 | ) |
59 | 39 | ||
60 | MIDDLEWARE_CLASSES = ( | 40 | MIDDLEWARE_CLASSES = ( |
@@ -63,12 +43,8 @@ MIDDLEWARE_CLASSES = ( | |||
63 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | 43 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
64 | ) | 44 | ) |
65 | 45 | ||
66 | ROOT_URLCONF = 'greenbox.urls' | ||
67 | |||
68 | TEMPLATE_DIRS = ( | 46 | TEMPLATE_DIRS = ( |
69 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | 47 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". |
70 | # Always use forward slashes, even on Windows. | ||
71 | # Don't forget to use absolute paths, not relative paths. | ||
72 | ) | 48 | ) |
73 | 49 | ||
74 | INSTALLED_APPS = ( | 50 | INSTALLED_APPS = ( |
@@ -76,4 +52,6 @@ INSTALLED_APPS = ( | |||
76 | 'django.contrib.contenttypes', | 52 | 'django.contrib.contenttypes', |
77 | 'django.contrib.sessions', | 53 | 'django.contrib.sessions', |
78 | 'django.contrib.sites', | 54 | 'django.contrib.sites', |
55 | 'django.contrib.admin', | ||
56 | 'greenbox.recipe', | ||
79 | ) | 57 | ) |
diff --git a/greenbox/urls.py b/greenbox/urls.py index b015f5e..683a1da 100755 --- a/greenbox/urls.py +++ b/greenbox/urls.py | |||
@@ -1,8 +1,8 @@ | |||
1 | from django.conf.urls.defaults import * | 1 | from django.conf.urls.defaults import * |
2 | 2 | ||
3 | # Uncomment the next two lines to enable the admin: | 3 | # Uncomment the next two lines to enable the admin: |
4 | # from django.contrib import admin | 4 | from django.contrib import admin |
5 | # admin.autodiscover() | 5 | admin.autodiscover() |
6 | 6 | ||
7 | urlpatterns = patterns('', | 7 | urlpatterns = patterns('', |
8 | # Example: | 8 | # Example: |
@@ -13,5 +13,5 @@ urlpatterns = patterns('', | |||
13 | # (r'^admin/doc/', include('django.contrib.admindocs.urls')), | 13 | # (r'^admin/doc/', include('django.contrib.admindocs.urls')), |
14 | 14 | ||
15 | # Uncomment the next line to enable the admin: | 15 | # Uncomment the next line to enable the admin: |
16 | # (r'^admin/', include(admin.site.urls)), | 16 | (r'^recipe/admin/', include(admin.site.urls)), |
17 | ) | 17 | ) |