Commit 7e4c7031 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Limit possible events for pizzas to future or today

parent 4b621377
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