diff options
| -rw-r--r-- | chimere/models.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/chimere/models.py b/chimere/models.py index 35da9a0..99fa073 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -184,15 +184,19 @@ class SubCategory(models.Model): subcategories = subcategories.filter(id__in=sub_ids) selected_cats = [subcat.pk for subcat in area.default_subcategories.all()] - for sub_category in subcategories: + for sub_category in subcategories.order_by('order'): if sub_category.category not in sub_categories: sub_categories[sub_category.category] = [] if sub_category.id in selected_cats: sub_category.selected = True sub_category.category.selected = True sub_categories[sub_category.category].append(sub_category) - return [(category, sub_cats) for category, sub_cats \ - in sub_categories.items()] + + subcategories = [(cat, subcats) \ + for cat, subcats in sub_categories.items()] + get_cat_order = lambda cat_tuple: cat_tuple[0].order + subcategories = sorted(subcategories, key=get_cat_order) + return subcategories IMPORTERS = {'KML':KMLManager, 'OSM':OSMManager, |
