update editor
[redakcja.git] / apps / forms_builder / forms / templatetags / forms_builder_stats.py
1 from __future__ import unicode_literals
2 from django import template
3 from forms_builder.forms.models import Form
4 from forms_builder.forms.forms import EntriesForm
5
6 register = template.Library()
7
8 @register.assignment_tag(takes_context=True)
9 def form_count(context, form=None, id=None, slug=None, **kwargs):
10     if id is not None:
11         form = Form.objects.get(pk=id)
12     elif slug is not None:
13         form = Form.objects.get(slug=slug)
14     ef = EntriesForm(form, context.get('request', None), data=kwargs)
15     return sum(1 for i in ef.rows())
16
17
18 @register.assignment_tag(name='set')
19 def set_tag(sth):
20     return sth