<commit_before><commit_msg>adding new templatetags satchmo_product<commit_after>from django.template import Library, Node
from satchmo.product.models import Category
from satchmo.shop.templatetags import get_filter_args

register = Library()

def product_images(product, args=""):
    args, kwargs = get_filter_args(args, 
        keywords=('include_main', 'maximum'), 
        boolargs=('include_main'),
        intargs=('maximum'),
        stripquotes=True)

    q = product.productimage_set
    if kwargs.get('include_main', True):
        q = q.all()
    else:
        main = product.main_image
        q = q.exclude(id = main.id)
    
    maximum = kwargs.get('maximum', -1)
    if maximum>-1:
        q = list(q)[:maximum]
    
    return q

register.filter('product_images', product_images)
{'fraction_non_alphanumeric': 0.11794228356336262, 'fraction_numerical': 0.002509410288582183, 'mean_word_length': 3.3135135135135134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1680985', 'n_tokens_mistral': 254, 'n_tokens_neox': 248, 'n_words': 53}