root / cloudcms / templatetags / cloudcms_tags.py @ 36d49217
History | View | Annotate | Download (537 Bytes)
1 |
from django import template |
---|---|
2 |
from cloudcmsfaq.models import Question |
3 |
from collections import OrderedDict |
4 |
|
5 |
register = template.Library() |
6 |
|
7 |
@register.filter('get_service_faqs') |
8 |
def get_service_faqs(service): |
9 |
"""
|
10 |
Retrun service faqs grouped by category
|
11 |
"""
|
12 |
grouped = OrderedDict() |
13 |
|
14 |
for q in Question.objects.active().filter(service=service, is_active=True): |
15 |
if q.category not in grouped: |
16 |
grouped[q.category] = [] |
17 |
|
18 |
grouped[q.category].append(q) |
19 |
|
20 |
print grouped
|
21 |
return grouped.iteritems()
|