<commit_before>'''
This file is part of Habitam.

Habitam is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as 
published by the Free Software Foundation, either version 3 of 
the License, or (at your option) any later version.

Habitam is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public
License along with Habitam. If not, see 
<http://www.gnu.org/licenses/>.
    
Created on Apr 20, 2013

@author: <NAME>
'''
from django import template
from habitam.settings import PENALTY_START_DAYS

register = template.Library()

@register.assignment_tag
def capability(entity_cls, user_license, cn):
    m = getattr(entity_cls, cn)
    return m(user_license)

@register.assignment_tag
def operation_amount(account, doc, service):
    if doc == None or doc.total_amount == None:
        return 0
    if doc.src == account and not doc.type == 'collection':
        return doc.total_amount * -1
    return doc.total_amount

@register.assignment_tag
def operation_other_party(account, doc):
    if doc.src == account:
        return doc.billed.name
    return doc.src.name

@register.assignment_tag
def available_list_months(building, user_license):
    return building.available_list_months(user_license.months_back)        

@register.simple_tag
def field_class(field):
    css_class = ''
    if field.name.startswith('consumption_undeclared_ap_'):
        css_class = css_class + 'stick-to-next '
    return css_class

@register.assignment_tag
def list_downloaded(building, month):
    return building.list_downloaded(month) 

@register.simple_tag
def op_amount_class(account, doc, service):
    if doc.type == 'collection' and service != None:
        return ''
    amount = doc.total_amount
    if doc.src == account:
        amount = amount * -1
    if amount < 0:
        return 'negative_balance'
    return 'positive_balance'

@register.simple_tag
def op_class(doc, service):
    if doc.type == 'collection' and service != None:
        return 'collection'
    return ''

@register.filter
def penalty_collect(building):<commit_msg>tag fixes<commit_after>'''
This file is part of Habitam.

Habitam is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as 
published by the Free Software Foundation, either version 3 of 
the License, or (at your option) any later version.

Habitam is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public
License along with Habitam. If not, see 
<http://www.gnu.org/licenses/>.
    
Created on Apr 20, 2013

@author: <NAME>
'''
from django import template
from habitam.settings import PENALTY_START_DAYS

register = template.Library()

@register.assignment_tag
def capability(entity_cls, user_license, cn):
    m = getattr(entity_cls, cn)
    return m(user_license)

@register.assignment_tag
def operation_amount(account, doc, service):
    if doc == None or doc.total_amount == None:
        return 0
    if doc.src == account and not doc.type == 'collection':
        return doc.total_amount * -1
    return doc.total_amount

@register.assignment_tag
def operation_other_party(account, doc):
    if doc.src == account:
        return doc.billed.name
    return doc.src.name

@register.assignment_tag
def available_list_months(building, user_license):
    return building.available_list_months(user_license.months_back)        

@register.simple_tag
def field_class(field):
    css_class = ''
    if field.name.startswith('consumption_undeclared_ap_'):
        css_class = css_class + 'stick-to-next '
    return css_class

@register.assignment_tag
def list_downloaded(building, month):
    return building.list_downloaded(month) 

@register.simple_tag
def op_amount_class(account, doc, service):
    if doc.type == 'collection' and service != None:
        return ''
    amount = doc.total_amount
    if amount == None:
        return 'positive_balance'
    if doc.src == account:
        amount = amount * -1
    if amount < 0:
        return 'negative_balance'
    return 'positive_balance'

@register.simple_tag
def op_class(doc, service):
    if doc.type == 'collection' and service != None:
        return 'collection'
    return ''

@register.filter
def penalty_collect(building):
{'fraction_non_alphanumeric': 0.08193944526783824, 'fraction_numerical': 0.004658056320135507, 'mean_word_length': 3.8401639344262297, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5546804', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1370, 'n_words': 475}