From 2eafeb7ed8285fad16f0a3df02b59005f229b65b Mon Sep 17 00:00:00 2001 From: Mike Crute Date: Fri, 1 Jan 2010 20:45:15 -0500 Subject: Addining initial admin interface. --- .hgignore | 3 ++ greenbox/recipe/models.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++- greenbox/settings.py | 42 +++++++--------------------- greenbox/urls.py | 6 ++-- 4 files changed, 85 insertions(+), 36 deletions(-) create mode 100644 .hgignore diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..dee9ae3 --- /dev/null +++ b/.hgignore @@ -0,0 +1,3 @@ +glob:*.pyc +glob:*.db +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 @@ +from django.contrib import admin +from django.contrib.admin import ModelAdmin, TabularInline from django.db import models +from django.db.models import CharField, IntegerField, TextField, FloatField +from django.db.models import ForeignKey -# Create your models here. + +class Unit(models.Model): + + name = CharField(max_length=100) + abbreviation = CharField(max_length=10, blank=True, null=True) + + def __unicode__(self): + return "{0} ({1})".format(self.name, self.abbreviation) + + +class Recipe(models.Model): + + title = CharField(max_length=100) + description = TextField(blank=True, null=True) + servings = IntegerField(blank=True, null=True) + instructions = TextField() + oven_temp = IntegerField(blank=True, null=True) + cook_time = IntegerField(blank=True, null=True) + prep_time = IntegerField(blank=True, null=True) + + + def __unicode__(self): + return self.title + + +class Ingredient(models.Model): + + name = CharField(max_length=100, unique=True) + + def __unicode__(self): + return self.name + + +class RecipeIngredient(models.Model): + + ingredient = ForeignKey(Ingredient) + units = ForeignKey(Unit) + quantity = FloatField() + recipe = ForeignKey(Recipe) + + +class UnitAdmin(ModelAdmin): + + list_display = ('abbreviation', 'name') + + +class IngredientInline(TabularInline): + + model = RecipeIngredient + + +class RecipeAdmin(ModelAdmin): + + list_display = ('title',) + inlines = (IngredientInline,) + + +class IngredientAdmin(ModelAdmin): + + list_display = ('name',) + + +admin.site.register(Unit, UnitAdmin) +admin.site.register(Ingredient, IngredientAdmin) +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 @@ -# Django settings for greenbox project. - +SITE_ID = 1 +USE_I18N = False DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( - # ('Your Name', 'your_email@domain.com'), + ('Mike Crute', 'mcrute@gmail.com'), ) MANAGERS = ADMINS -DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. -DATABASE_NAME = '' # Or path to database file if using sqlite3. -DATABASE_USER = '' # Not used with sqlite3. -DATABASE_PASSWORD = '' # Not used with sqlite3. -DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. -DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. - -# Local time zone for this installation. Choices can be found here: -# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name -# although not all choices may be available on all operating systems. -# If running in a Windows environment this must be set to the same as your -# system time zone. -TIME_ZONE = 'America/Chicago' +DATABASE_ENGINE = 'sqlite3' +DATABASE_NAME = 'greenbox.db' -# Language code for this installation. All choices can be found here: -# http://www.i18nguy.com/unicode/language-identifiers.html +TIME_ZONE = 'America/New_York' LANGUAGE_CODE = 'en-us' - -SITE_ID = 1 - -# If you set this to False, Django will make some optimizations so as not -# to load the internationalization machinery. -USE_I18N = True +ROOT_URLCONF = 'greenbox.urls' # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" @@ -45,16 +28,13 @@ MEDIA_URL = '' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/", "/media/". -ADMIN_MEDIA_PREFIX = '/media/' +ADMIN_MEDIA_PREFIX = '/recipe/media/' -# Make this unique, and don't share it with anybody. SECRET_KEY = 'zki4e4!80ar7^1w6f_c2u^5#=r(7#4%0u^3il^@__#3zf^u+f)' -# List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', -# 'django.template.loaders.eggs.load_template_source', ) MIDDLEWARE_CLASSES = ( @@ -63,12 +43,8 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.auth.middleware.AuthenticationMiddleware', ) -ROOT_URLCONF = 'greenbox.urls' - TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". - # Always use forward slashes, even on Windows. - # Don't forget to use absolute paths, not relative paths. ) INSTALLED_APPS = ( @@ -76,4 +52,6 @@ INSTALLED_APPS = ( 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', + 'django.contrib.admin', + 'greenbox.recipe', ) 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 @@ from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: -# from django.contrib import admin -# admin.autodiscover() +from django.contrib import admin +admin.autodiscover() urlpatterns = patterns('', # Example: @@ -13,5 +13,5 @@ urlpatterns = patterns('', # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: - # (r'^admin/', include(admin.site.urls)), + (r'^recipe/admin/', include(admin.site.urls)), ) -- cgit v1.2.3