food-planner/food_planner/admin.py

63 lines
1.6 KiB
Python

# coding=utf-8
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
# Register your models here.
from food_planner.models import Ingredient
from food_planner.models import KitchenUtility
from food_planner.models import MealPlan
from food_planner.models import Pantry
from food_planner.models import Product
from food_planner.models import Profile
from food_planner.models import Recipe
from food_planner.models import RecipeStep
from food_planner.models import StoredIngredient
from food_planner.models import UsedIngredient
from food_planner.models import UsedKitchenUtility
from food_planner.models import Vendor
admin.site.unregister(User)
class ProfileInline(admin.StackedInline):
model = Profile
class RecipeStepsInline(admin.StackedInline):
model = RecipeStep
class IngredientsInline(admin.StackedInline):
model = UsedIngredient
class KitchenUtilitiesInline(admin.StackedInline):
model = UsedKitchenUtility
class StoredIngredientsInline(admin.StackedInline):
model = StoredIngredient
class UserProfileAdmin(UserAdmin):
inlines = [ProfileInline, ]
class RecipeAdmin(admin.ModelAdmin):
inlines = [KitchenUtilitiesInline, IngredientsInline, RecipeStepsInline, ]
class PantryAdmin(admin.ModelAdmin):
inlines = [StoredIngredientsInline, ]
admin.site.register(User, UserProfileAdmin)
admin.site.register(Recipe, RecipeAdmin)
admin.site.register(Ingredient)
admin.site.register(Vendor)
admin.site.register(Pantry, PantryAdmin)
admin.site.register(Product)
admin.site.register(MealPlan)
admin.site.register(KitchenUtility)