Statistics
| Branch: | Tag: | Revision:

root / cloudcms / templatetags / cloudcms_tags.py @ 60441a7f

History | View | Annotate | Download (490 Bytes)

1
from django import template
2
from cloudcmsfaq.models import Question
3

    
4
register = template.Library()
5

    
6
@register.filter('get_service_faqs')
7
def get_service_faqs(service):
8
    """
9
    Retrun service faqs grouped by category
10
    """
11
    grouped = {}
12

    
13
    for q in Question.objects.active().filter(service=service, is_active=True):
14
        if q.category not in grouped:
15
            grouped[q.category] = []
16

    
17
        grouped[q.category].append(q)
18

    
19
    print grouped
20
    return grouped.iteritems()