|
|
|
@ -1,9 +1,12 @@ |
|
|
|
from functools import reduce |
|
|
|
from functools import reduce |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from django.utils.html import strip_tags |
|
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
|
|
|
|
|
|
|
|
|
from django.template import Library |
|
|
|
from django.template import Library |
|
|
|
|
|
|
|
|
|
|
|
from cart.forms import CartAddInlineForm |
|
|
|
from cart.forms import CartAddInlineForm |
|
|
|
|
|
|
|
from products.utils import ProductDesctipionHtmlParser |
|
|
|
|
|
|
|
|
|
|
|
register = Library() |
|
|
|
register = Library() |
|
|
|
|
|
|
|
|
|
|
|
@ -13,15 +16,6 @@ def apply_nds_status(doesNdsInclude): |
|
|
|
return _('Включено') if doesNdsInclude else _('Не включено') |
|
|
|
return _('Включено') if doesNdsInclude else _('Не включено') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.filter |
|
|
|
|
|
|
|
def apply_product_offer_form(product): |
|
|
|
|
|
|
|
initial = { |
|
|
|
|
|
|
|
'offer': product.id, |
|
|
|
|
|
|
|
'amount': 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return CartAddInlineForm(initial=initial) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.filter |
|
|
|
@register.filter |
|
|
|
def apply_query_params(params, doAppend=False): |
|
|
|
def apply_query_params(params, doAppend=False): |
|
|
|
""" |
|
|
|
""" |
|
|
|
@ -56,6 +50,12 @@ def get_item(dictionary, key): |
|
|
|
return dictionary.get(key) |
|
|
|
return dictionary.get(key) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# @TODO: WRONG SOLUTION. REWRITE |
|
|
|
@register.filter |
|
|
|
@register.filter |
|
|
|
def apply_desc_preview(description): |
|
|
|
def apply_desc_preview(description): |
|
|
|
return description |
|
|
|
text = strip_tags(description) |
|
|
|
|
|
|
|
return reduce( |
|
|
|
|
|
|
|
lambda text, line: text + line, |
|
|
|
|
|
|
|
text.split('.')[:3], |
|
|
|
|
|
|
|
"" |
|
|
|
|
|
|
|
) + '...' |
|
|
|
|