added stuff
This commit is contained in:
parent
6d6b65b767
commit
e7580fe660
0
mofca/__init__.py
Normal file
0
mofca/__init__.py
Normal file
11
mofca/manage.py
Normal file
11
mofca/manage.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env python
|
||||
from django.core.management import execute_manager
|
||||
try:
|
||||
import settings # Assumed to be in the same directory.
|
||||
except ImportError:
|
||||
import sys
|
||||
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
execute_manager(settings)
|
0
mofca/recipes/__init__.py
Normal file
0
mofca/recipes/__init__.py
Normal file
101
mofca/recipes/admin.py
Executable file
101
mofca/recipes/admin.py
Executable file
|
@ -0,0 +1,101 @@
|
|||
from django.contrib import admin
|
||||
from models import *
|
||||
|
||||
class OtherIngredientInline(admin.StackedInline):
|
||||
model = OtherIngredient
|
||||
extra = 5
|
||||
|
||||
class AlternativeNameInline(admin.StackedInline):
|
||||
model = AlternativeName
|
||||
extra = 3
|
||||
|
||||
class TokriImageInline(admin.StackedInline):
|
||||
model = TokriImage
|
||||
extra = 3
|
||||
|
||||
class VegetableLinkInline(admin.StackedInline):
|
||||
model = VegetableLink
|
||||
extra = 2
|
||||
|
||||
class RecipeTokriInline(admin.TabularInline):
|
||||
model = Recipe.tokri_ingredients.through
|
||||
|
||||
class RecipeAdmin(admin.ModelAdmin):
|
||||
inlines = [RecipeTokriInline, OtherIngredientInline]
|
||||
prepopulated_fields = {'slug': ('title',)}
|
||||
|
||||
class TokriAdmin(admin.ModelAdmin):
|
||||
inlines = [AlternativeNameInline, TokriImageInline, VegetableLinkInline]
|
||||
prepopulated_fields = {'slug': ('name',)}
|
||||
|
||||
admin.site.register(Recipe, RecipeAdmin)
|
||||
admin.site.register(TokriVegetable, TokriAdmin)
|
||||
admin.site.register(Season)
|
||||
admin.site.register(Language)
|
||||
admin.site.register(VegetableType)
|
||||
|
||||
|
||||
'''
|
||||
#class NicknameInline(admin.StackedInline):
|
||||
# model = Nickname
|
||||
# extra = 3
|
||||
|
||||
#class LinkInlineModelAdmin(admin.InlineModelAdmin):
|
||||
# pass
|
||||
|
||||
#class LinkInline(LinkInlineModelAdmin):
|
||||
# model = Link
|
||||
# extra = 3
|
||||
|
||||
class ProfileInline(admin.StackedInline):
|
||||
model = Person
|
||||
extra = 1
|
||||
|
||||
class PerformanceAdmin(admin.ModelAdmin):
|
||||
filter_horizontal = ('links', 'images')
|
||||
|
||||
class EventAdmin(admin.ModelAdmin):
|
||||
filter_horizontal = ('links',)
|
||||
|
||||
class ProfileAdmin(admin.ModelAdmin):
|
||||
filter_horizontal = ('links', 'files', 'images',)
|
||||
# inlines = [NicknameInline]
|
||||
# inlines = [LinkInline]
|
||||
|
||||
class VenueAdmin(admin.ModelAdmin):
|
||||
ordering = ('name',)
|
||||
prepopulated_fields = {'slug': ('name',)}
|
||||
filter_horizontal = ('links', 'images')
|
||||
|
||||
class TheatreGroupAdmin(admin.ModelAdmin):
|
||||
prepopulated_fields = {'slug': ('name',)}
|
||||
filter_horizontal = ('links', 'files', 'images')
|
||||
|
||||
class ProductionAdmin(admin.ModelAdmin):
|
||||
prepopulated_fields = {'slug': ('title',)}
|
||||
filter_horizontal = ('links', 'files', 'images',)
|
||||
inlines = [ProfileInline]
|
||||
|
||||
class ScriptAdmin(admin.ModelAdmin):
|
||||
filter_horizontal = ('links', 'downloads')
|
||||
|
||||
|
||||
#admin.site.register(Nickname3)
|
||||
#admin.site.register(Nickname2)
|
||||
admin.site.register(Performance, PerformanceAdmin)
|
||||
admin.site.register(Event, EventAdmin)
|
||||
admin.site.register(Location)
|
||||
admin.site.register(ProfileProfile)
|
||||
admin.site.register(ProfileGroup)
|
||||
admin.site.register(Script, ScriptAdmin)
|
||||
admin.site.register(Production, ProductionAdmin)
|
||||
admin.site.register(Image)
|
||||
admin.site.register(File)
|
||||
admin.site.register(Link)
|
||||
admin.site.register(RandomQuote)
|
||||
admin.site.register(ProfileProduction)
|
||||
admin.site.register(Nickname)
|
||||
admin.site.register(TheatreGroup, TheatreGroupAdmin)
|
||||
admin.site.register(Venue, VenueAdmin)
|
||||
admin.site.register(Profile, ProfileAdmin)
|
||||
'''
|
106
mofca/recipes/models.py
Normal file
106
mofca/recipes/models.py
Normal file
|
@ -0,0 +1,106 @@
|
|||
from django.db import models
|
||||
|
||||
class Recipe(models.Model):
|
||||
title = models.CharField(max_length=255)
|
||||
slug = models.SlugField()
|
||||
description = models.TextField(blank=True)
|
||||
tokri_ingredients = models.ManyToManyField("TokriVegetable", through='RecipeTokri')
|
||||
preparation = models.TextField(blank=True)
|
||||
serves = models.IntegerField(null=True, help_text="Serves approximately how many people?", blank=True)
|
||||
preparation_time = models.IntegerField(null=True, help_text="Approximate time to make, in minutes", blank=True)
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
|
||||
class TokriVegetable(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
types = models.ManyToManyField("VegetableType", blank=True)
|
||||
slug = models.SlugField()
|
||||
description = models.TextField(blank=True)
|
||||
main_image = models.ImageField(upload_to='veggie_main_images', null=True)
|
||||
season = models.ForeignKey("Season", null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
class VegetableType(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
description = models.TextField(blank=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class VegetableLink(models.Model):
|
||||
url = models.URLField()
|
||||
caption = models.CharField(max_length=512, blank=True)
|
||||
vegetable = models.ForeignKey(TokriVegetable)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.url
|
||||
|
||||
MONTH_CHOICES = (
|
||||
('Jan', 'January'),
|
||||
('Feb', 'February'),
|
||||
('Mar', 'March'),
|
||||
('Apr', 'April'),
|
||||
('May', 'May'),
|
||||
('Jun', 'June'),
|
||||
('Jul', 'July'),
|
||||
('Aug', 'August'),
|
||||
('Sep', 'September'),
|
||||
('Oct', 'October'),
|
||||
('Nov', 'November'),
|
||||
('Dec', 'December'),
|
||||
)
|
||||
|
||||
class Season(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
start_month = models.CharField(max_length=5, choices=MONTH_CHOICES)
|
||||
end_month = models.CharField(max_length=5, choices=MONTH_CHOICES)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
class RecipeTokri(models.Model):
|
||||
recipe = models.ForeignKey(Recipe)
|
||||
tokri_ingredient = models.ForeignKey(TokriVegetable)
|
||||
amount = models.CharField(max_length=255, blank=True)
|
||||
|
||||
|
||||
class AlternativeName(models.Model):
|
||||
ingredient = models.ForeignKey(TokriVegetable)
|
||||
name_roman = models.CharField(max_length=255)
|
||||
name_unicode = models.CharField(max_length=255)
|
||||
language = models.ForeignKey("Language", null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name_roman
|
||||
|
||||
|
||||
class Language(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
lang_code = models.CharField(max_length=4)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class OtherIngredient(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
amount = models.CharField(max_length=255)
|
||||
recipe = models.ForeignKey(Recipe)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
class TokriImage(models.Model):
|
||||
ingredient = models.ForeignKey(TokriVegetable)
|
||||
image = models.ImageField(upload_to='veggie_images')
|
||||
caption = models.CharField(max_length=512, blank=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.caption
|
||||
# Create your models here.
|
23
mofca/recipes/tests.py
Normal file
23
mofca/recipes/tests.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
"""
|
||||
This file demonstrates two different styles of tests (one doctest and one
|
||||
unittest). These will both pass when you run "manage.py test".
|
||||
|
||||
Replace these with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.failUnlessEqual(1 + 1, 2)
|
||||
|
||||
__test__ = {"doctest": """
|
||||
Another way to test that 1 + 1 is equal to 2.
|
||||
|
||||
>>> 1 + 1 == 2
|
||||
True
|
||||
"""}
|
||||
|
5
mofca/recipes/views.py
Normal file
5
mofca/recipes/views.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Create your views here.
|
||||
from django.http import HttpResponseRedirect
|
||||
|
||||
def index(request):
|
||||
return HttpResponseRedirect("http://blog.mofca.in")
|
109
mofca/settings.py
Normal file
109
mofca/settings.py
Normal file
|
@ -0,0 +1,109 @@
|
|||
# Django settings for mofca project.
|
||||
import os
|
||||
from os.path import join
|
||||
|
||||
PROJECT_ROOT = os.path.dirname(__file__)
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
ADMINS = (
|
||||
# ('Your Name', 'your_email@domain.com'),
|
||||
)
|
||||
|
||||
MANAGERS = ADMINS
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
||||
'NAME': 'mofca', # Or path to database file if using sqlite3.
|
||||
'USER': 'root', # Not used with sqlite3.
|
||||
'PASSWORD': '', # Not used with sqlite3.
|
||||
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
|
||||
'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.
|
||||
# On Unix systems, a value of None will cause Django to use the same
|
||||
# timezone as the operating system.
|
||||
# If running in a Windows environment this must be set to the same as your
|
||||
# system time zone.
|
||||
TIME_ZONE = 'America/Chicago'
|
||||
|
||||
# Language code for this installation. All choices can be found here:
|
||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
||||
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
|
||||
|
||||
# If you set this to False, Django will not format dates, numbers and
|
||||
# calendars according to the current locale
|
||||
USE_L10N = True
|
||||
|
||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||
# Example: "/home/media/media.lawrence.com/"
|
||||
MEDIA_ROOT = join(PROJECT_ROOT, 'static')
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash if there is a path component (optional in other cases).
|
||||
# Examples: "http://media.lawrence.com", "http://example.com/media/"
|
||||
MEDIA_URL = '/static/'
|
||||
|
||||
# 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/'
|
||||
|
||||
# Make this unique, and don't share it with anybody.
|
||||
SECRET_KEY = 'asdkhfoq839861874scvliayw3o87623rv'
|
||||
|
||||
|
||||
# List of callables that know how to import templates from various sources.
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
# 'django.template.loaders.eggs.Loader',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'mofca.urls'
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
join(PROJECT_ROOT, "templates"),
|
||||
# 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 = (
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'django_extensions',
|
||||
'recipes',
|
||||
# Uncomment the next line to enable the admin:
|
||||
'django.contrib.admin',
|
||||
# Uncomment the next line to enable admin documentation:
|
||||
'django.contrib.admindocs',
|
||||
)
|
||||
|
||||
try:
|
||||
from local_settings import *
|
||||
except:
|
||||
pass
|
16
mofca/urls.py
Normal file
16
mofca/urls.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from django.conf.urls.defaults import *
|
||||
|
||||
# Uncomment the next two lines to enable the admin:
|
||||
from django.contrib import admin
|
||||
admin.autodiscover()
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# Example:
|
||||
# (r'^mofca/', include('mofca.foo.urls')),
|
||||
(r'^$', 'recipes.views.index'),
|
||||
# Uncomment the admin/doc line below to enable admin documentation:
|
||||
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
||||
# Uncomment the next line to enable the admin:
|
||||
(r'^admin/', include(admin.site.urls)),
|
||||
)
|
Loading…
Reference in New Issue
Block a user