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

Commit

Permalink
fix bug 854432: can't change order of cases in suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Dawson committed Mar 25, 2013
1 parent 287b757 commit fd20505
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion moztrap/model/execution/api.py
Expand Up @@ -307,7 +307,7 @@ class Meta:
"created_by",
).prefetch_related(
"runsuites",
)
).distinct().order_by("runsuites__order")
list_allowed_methods = ['get']
fields = ["id", "name", "created_by"]
filtering = {
Expand Down
3 changes: 0 additions & 3 deletions moztrap/view/manage/runs/forms.py
Expand Up @@ -142,9 +142,6 @@ def __init__(self, *args, **kwargs):
isf.readonly = True
# can't change suites of an active run either
sf.readonly = True
# self.initial["suites"] = list(
# self.instance.suites.values_list(
# "name", flat=True).order_by("runsuites__order"))
else:
# regardless, can't switch to different product entirely
pvf.queryset = pvf.queryset.filter(
Expand Down
9 changes: 5 additions & 4 deletions moztrap/view/manage/suites/forms.py
Expand Up @@ -47,7 +47,7 @@ def clean_cases(self):
Make sure all the ids for the cases are valid and populate
self.cleaned_data with the real objects.
"""
# convert them to case objects, but loses order.
# fetch the case objects in one query, but loses order.
cases = dict((unicode(x.id), x) for x in
model.Case.objects.filter(pk__in=self.cleaned_data["cases"]))

Expand All @@ -61,8 +61,9 @@ def clean_cases(self):
clean_cases.append(case)

# if number is different, then add this to changed data
if len(self.cleaned_data["cases"]) is not len(clean_cases):
self.changed_data.append("cases")
if (self.initial["cases"] != self.cleaned_data["cases"] or
len(self.cleaned_data["cases"]) is not len(clean_cases)):
self.changed_data.append("cases")

return clean_cases
except KeyError as e:
Expand Down Expand Up @@ -97,7 +98,7 @@ def __init__(self, *args, **kwargs):
super(EditSuiteForm, self).__init__(*args, **kwargs)

self.initial["cases"] = list(
self.instance.cases.values_list("id", flat=True))
self.instance.cases.values_list("id", flat=True).order_by("suitecases__order"))

# for suites with cases in them, product is readonly and case options
# are filtered to that product
Expand Down

0 comments on commit fd20505

Please sign in to comment.