added shoppinglist items for one of things in the shopping list
This commit is contained in:
parent
e55a312771
commit
2ea523b97a
|
@ -1,6 +1,7 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import PantryItem, PantryItemLine, Unit, Category, Location
|
||||
from .models import ShoppingListItem
|
||||
|
||||
|
||||
class PantryItemInLine(admin.TabularInline):
|
||||
|
@ -13,6 +14,7 @@ class LocationInLine(admin.TabularInline):
|
|||
model = Location
|
||||
extra = 1
|
||||
|
||||
|
||||
def upper_case_name(obj):
|
||||
return obj.name.upper()
|
||||
upper_case_name.short_description = 'Name'
|
||||
|
@ -81,7 +83,18 @@ class PantryItemAdmin(admin.ModelAdmin):
|
|||
'info',
|
||||
)
|
||||
|
||||
|
||||
class ShoppingListItemAdmin(PantryItemAdmin):
|
||||
|
||||
inlines = []
|
||||
fields = (
|
||||
'name',
|
||||
('min_quantity', 'unit'),
|
||||
'info',
|
||||
)
|
||||
|
||||
admin.site.register(PantryItem, PantryItemAdmin)
|
||||
admin.site.register(ShoppingListItem, ShoppingListItemAdmin)
|
||||
admin.site.register(PantryItemLine, PantryItemLineAdmin)
|
||||
admin.site.register(Unit, AutocompleteAdmin)
|
||||
admin.site.register(Category, AutocompleteAdmin)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 2.1.2 on 2018-10-09 10:32
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('inventory', '0017_auto_20181007_1108'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='pantryitem',
|
||||
name='category',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='inventory.Category'),
|
||||
),
|
||||
]
|
|
@ -1,4 +1,5 @@
|
|||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
class Category(models.Model):
|
||||
|
@ -49,8 +50,8 @@ class Location(models.Model):
|
|||
|
||||
class PantryItem(models.Model):
|
||||
"""A think you keep in your pantry """
|
||||
category = models.ForeignKey(Category, on_delete=models.PROTECT)
|
||||
min_quantity = models.IntegerField(default=1) #, decimal_places=3, max_digits=32)
|
||||
category = models.ForeignKey(Category, on_delete=models.PROTECT, null=True, blank=True)
|
||||
min_quantity = models.IntegerField(default=1)
|
||||
# some things don't have a fixed expiry date, like legumes or garlic, we can specify a default expiration for
|
||||
# this.
|
||||
# if expiry duration is set the expiration date for a pantryitemline will be set to now + duration on save
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
<li>
|
||||
{{ pi|title }} (We have
|
||||
{{ pi.total_quantity }} {{pi.unit}} but we want at least
|
||||
{{ pi.min_quantity }} {{pi.unit }} in {{ pi.location}})
|
||||
{{ pi.min_quantity }} {{pi.unit }} in {{ pi.location}} ({{pi.info}}))
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<a href="{% url 'admin:inventory_shoppinglistitem_add' %}">Add one off item to shoppinglist</a>
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#requirements.txt
|
||||
Django==2.1
|
||||
gunicorn
|
Loading…
Reference in New Issue