Add beginnings of a shopping app

This commit is contained in:
Maximilian Friedersdorff 2024-06-30 12:57:29 +01:00
parent bfa660f53c
commit 1ce10bf254
9 changed files with 51 additions and 0 deletions

View file

@ -44,6 +44,7 @@ INSTALLED_APPS = [
"reinheit.apps.styles",
"reinheit.apps.ingredients",
"reinheit.apps.user",
"reinheit.apps.shopping",
]
MIDDLEWARE = [

View file

@ -6,5 +6,6 @@ urlpatterns = [
path("", RedirectView.as_view(url="/brews/")),
path("admin/", admin.site.urls),
path("brews/", include(("reinheit.apps.brew.urls", "brew"), namespace="brews")),
path("shopping/", include(("reinheit.apps.shopping.urls", "shopping"), namespace="shopping")),
path("oidc/", include("oauth2_authcodeflow.urls")),
]

View file

View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class ShoppingConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "reinheit.apps.shopping"

View file

@ -0,0 +1,34 @@
from django.db import models
# Create your models here.
class Item(models.Model):
name = models.CharField(max_length=255)
def __str__(self):
return self.name
class Recipe(models.Model):
class TimeRequired(models.IntegerChoices):
LOW = 1, "Low"
MEDIUM = 2, "Medium"
HIGH = 3, "High"
name = models.CharField(max_length=255)
ingredients = models.ManyToManyField(Item)
time_required = models.PositiveIntegerField(choices=TimeRequired)
def __str__(self):
return self.name
class ShoppingList(models.Model):
date = models.DateField()
meals = models.ManyToManyField(Recipe)
other = models.ManyToManyField(Item)
def __str__(self):
return f"List for {self.date}"

View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.