diff options
| author | Caine <caine@jihakuz.xyz> | 2026-04-01 22:48:28 +0100 |
|---|---|---|
| committer | Caine <caine@jihakuz.xyz> | 2026-04-01 22:48:28 +0100 |
| commit | 5c6f7ead8f23ac76d6650858d1e06d4afb6a2efe (patch) | |
| tree | 32741d68101e2a4d301f38d83de74e97349c8fcd /kitchen | |
| parent | 40cc3de3e4d017f9241eecb35cd7854e9aec48fe (diff) | |
Configure settings: add kitchen app, DRF, timezone, allowed hosts
Diffstat (limited to 'kitchen')
| -rw-r--r-- | kitchen/__init__.py | 0 | ||||
| -rw-r--r-- | kitchen/admin.py | 122 | ||||
| -rw-r--r-- | kitchen/apps.py | 6 | ||||
| -rw-r--r-- | kitchen/migrations/__init__.py | 0 | ||||
| -rw-r--r-- | kitchen/tests.py | 3 | ||||
| -rw-r--r-- | kitchen/views.py | 3 |
6 files changed, 134 insertions, 0 deletions
diff --git a/kitchen/__init__.py b/kitchen/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/kitchen/__init__.py diff --git a/kitchen/admin.py b/kitchen/admin.py new file mode 100644 index 0000000..661c931 --- /dev/null +++ b/kitchen/admin.py @@ -0,0 +1,122 @@ +from django.contrib import admin +from .models import ( + Tag, + Ingredient, + PantryItem, + MetaRecipe, + Slot, + SlotOption, + MetaRecipeBase, + Recipe, + RecipeIngredient, + CookLog, + ShoppingListItem, +) + + +@admin.register(Tag) +class TagAdmin(admin.ModelAdmin): + list_display = ["name"] + search_fields = ["name"] + + +@admin.register(Ingredient) +class IngredientAdmin(admin.ModelAdmin): + list_display = ["name", "default_unit", "shelf_life_days", "tag_list"] + list_filter = ["tags"] + search_fields = ["name", "aliases"] + filter_horizontal = ["tags"] + + def tag_list(self, obj): + return ", ".join(t.name for t in obj.tags.all()) + + tag_list.short_description = "Tags" + + +@admin.register(PantryItem) +class PantryItemAdmin(admin.ModelAdmin): + list_display = [ + "ingredient", + "quantity", + "unit", + "location", + "stored_date", + "expiry_date", + "is_staple", + ] + list_filter = ["location", "is_staple"] + search_fields = ["ingredient__name"] + list_editable = ["quantity"] + + +# --- Meta-Recipe inlines --- + + +class SlotOptionInline(admin.TabularInline): + model = SlotOption + extra = 1 + autocomplete_fields = ["ingredient"] + + +class SlotInline(admin.TabularInline): + model = Slot + extra = 1 + show_change_link = True # Link to slot detail to manage options + + +class MetaRecipeBaseInline(admin.TabularInline): + model = MetaRecipeBase + extra = 1 + autocomplete_fields = ["ingredient"] + + +@admin.register(MetaRecipe) +class MetaRecipeAdmin(admin.ModelAdmin): + list_display = ["name", "default_servings", "prep_time_mins", "cook_time_mins", "gear_needed"] + search_fields = ["name"] + inlines = [SlotInline, MetaRecipeBaseInline] + + +@admin.register(Slot) +class SlotAdmin(admin.ModelAdmin): + list_display = ["meta_recipe", "name", "required", "max_choices", "option_count"] + list_filter = ["meta_recipe", "required"] + inlines = [SlotOptionInline] + + def option_count(self, obj): + return obj.options.count() + + option_count.short_description = "Options" + + +# --- Fixed Recipe inlines --- + + +class RecipeIngredientInline(admin.TabularInline): + model = RecipeIngredient + extra = 1 + autocomplete_fields = ["ingredient"] + + +@admin.register(Recipe) +class RecipeAdmin(admin.ModelAdmin): + list_display = ["name", "servings", "prep_time_mins", "cook_time_mins", "source_url"] + search_fields = ["name"] + inlines = [RecipeIngredientInline] + + +# --- Cook Log & Shopping --- + + +@admin.register(CookLog) +class CookLogAdmin(admin.ModelAdmin): + list_display = ["date", "meta_recipe", "recipe", "servings"] + list_filter = ["date"] + date_hierarchy = "date" + + +@admin.register(ShoppingListItem) +class ShoppingListItemAdmin(admin.ModelAdmin): + list_display = ["__str__", "quantity", "unit", "reason", "added_date", "checked"] + list_filter = ["checked"] + list_editable = ["checked"] diff --git a/kitchen/apps.py b/kitchen/apps.py new file mode 100644 index 0000000..674f34b --- /dev/null +++ b/kitchen/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class KitchenConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'kitchen' diff --git a/kitchen/migrations/__init__.py b/kitchen/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/kitchen/migrations/__init__.py diff --git a/kitchen/tests.py b/kitchen/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/kitchen/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/kitchen/views.py b/kitchen/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/kitchen/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. |
