cleanup in camps/
This commit is contained in:
parent
d20a964793
commit
aaa4df27db
|
@ -1,6 +1,4 @@
|
|||
from django.conf import settings
|
||||
from .models import Camp
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
def camp(request):
|
||||
|
|
|
@ -17,10 +17,8 @@ class CampViewMixin(object):
|
|||
if queryset:
|
||||
# check if we have a foreignkey to Camp, filter if so
|
||||
for field in queryset.model._meta.fields:
|
||||
if field.name=="camp" and field.related_model._meta.label == "camps.Camp":
|
||||
if field.name == "camp" and field.related_model._meta.label == "camps.Camp":
|
||||
return queryset.filter(camp=self.camp)
|
||||
|
||||
# Camp relation not found, or queryset is empty, return it unaltered
|
||||
return queryset
|
||||
|
||||
|
||||
|
|
|
@ -2,12 +2,14 @@ from camps.models import Camp
|
|||
from django.utils import timezone
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
def get_current_camp():
|
||||
try:
|
||||
return Camp.objects.get(camp__contains=timezone.now())
|
||||
except Camp.DoesNotExist:
|
||||
return False
|
||||
|
||||
|
||||
class CampPropertyListFilter(admin.SimpleListFilter):
|
||||
"""
|
||||
SimpleListFilter to filter models by camp when camp is
|
||||
|
@ -27,7 +29,6 @@ class CampPropertyListFilter(admin.SimpleListFilter):
|
|||
for camp in unique_camps:
|
||||
yield (camp.slug, camp.title)
|
||||
|
||||
|
||||
def queryset(self, request, queryset):
|
||||
# if self.value() is None return everything
|
||||
if not self.value():
|
||||
|
@ -45,4 +46,3 @@ class CampPropertyListFilter(admin.SimpleListFilter):
|
|||
if item.camp != camp:
|
||||
queryset = queryset.exclude(pk=item.pk)
|
||||
return queryset
|
||||
|
||||
|
|
Loading…
Reference in a new issue