Commit 5420e848 authored by Thom Wiggers's avatar Thom Wiggers

Merge branch 'feature/138-events-for-pizza' into 'master'

Limit possible events for pizzas to future or today

Closes #138

See merge request !178
parents 07d802fd 7e4c7031
from django.contrib import admin
from django.urls import reverse
from django.utils import timezone
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
from .models import Order, PizzaEvent, Product
from events.models import Event
admin.site.register(Product)
......@@ -17,6 +19,13 @@ class PizzaEventAdmin(admin.ModelAdmin):
link=reverse('pizzas:orders',
kwargs={'event_pk': obj.pk}))
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "event":
kwargs["queryset"] = Event.objects.filter(
end__gte=timezone.now())
return super(PizzaEventAdmin, self).formfield_for_foreignkey(
db_field, request, **kwargs)
@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment