Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
case selection fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Dawson committed Apr 8, 2013
1 parent 2e343b2 commit 935abca
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions moztrap/model/library/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db.models import Max
from django.db.models import Max, Count
from tastypie import http, fields
from tastypie.exceptions import ImmediateHttpResponse
from tastypie.resources import ModelResource, ALL, ALL_WITH_RELATIONS
Expand Down Expand Up @@ -340,12 +340,13 @@ class CaseSelectionResource(BaseSelectionResource):
class Meta:
# versions=None exclude is just in case a ``case`` exists with no
# case versions.
queryset = Case.objects.all().exclude(versions=None).select_related(
"product",
).prefetch_related(
"versions__tags",
).annotate(
order=Max("suitecases__order"),
queryset = Case.objects.all().annotate(
order=Max("suitecases__order"),
version_count=Count("versions"),
).exclude(version_count=0).select_related(
"product",
).prefetch_related(
"versions__tags",
).order_by("order")

list_allowed_methods = ['get']
Expand Down

0 comments on commit 935abca

Please sign in to comment.