misc: add |done filter (#54351)

This commit is contained in:
Frédéric Péters 2021-05-30 21:44:10 +02:00
parent d7214c5dab
commit 57544f2059
2 changed files with 10 additions and 0 deletions

View File

@ -1430,6 +1430,11 @@ def test_lazy_formdata_queryset_filter(pub, variable_test_data):
assert LazyFormData(formdata).objects.pending().count == 7
assert LazyFormData(formdata).objects.pending().filter_by('foo_foo').apply_filter_value('foo').count == 0
# test |done
context = pub.substitutions.get_context_variables(mode='lazy')
tmpl = Template('{{form_objects|done|count}}')
assert tmpl.render(context) == '4'
# test |filter_by_number
context = pub.substitutions.get_context_variables(mode='lazy')
tmpl = Template('{{form_objects|filter_by_number:"%s"|count}}' % finished_formdata.get_display_id())

View File

@ -649,6 +649,11 @@ def pending(queryset):
return queryset.pending()
@register.filter
def done(queryset):
return queryset.done()
@register.filter
def objects(forms_source, slug):
if hasattr(slug, 'get_value'):