<commit_before># -*- coding: utf-8 -*-

from Instanssi.common.misc import get_url
from datetime import datetime
from django.conf import settings
from django.core.urlresolvers import reverse
from Instanssi.store.models import TransactionItem
from Instanssi.store.utils.emailer import ReceiptMailer

# Logging related
import logging
logger = logging.getLogger(__name__)


def handle_cancellation(ta):
    if not ta.time_cancelled:
        ta.time_cancelled = datetime.now()
        ta.save()
        logger.info('Store transaction {} cancelled.'.format(ta.id))
    else:
        logger.warn('Attempted to mark store transaction {} as cancelled twice'.format(ta.id))


def handle_pending(ta):
    if ta.time_cancelled:
        logger.warn('Cannot mark store transaction {} pending; is already cancelled.'.format(ta.id))
    elif not ta.time_pending:
        ta.time_pending = datetime.now()
        ta.save()
        logger.info('Store transaction {} paid, pending confirmation.'.format(ta.id))
    else:
        logger.warn('Attempted to mark store transaction {} as pending twice'.format(ta.id))


def handle_payment(ta):
    # Deliver email.
    mailer = ReceiptMailer('"Instanssi" <noreply@' + settings.DOMAIN + '>', ta.email, 'Instanssi.org kuitti')
    mailer.ordernumber(ta.id)
    mailer.firstname(ta.firstname)
    mailer.lastname(ta.lastname)
    mailer.email(ta.email)
    mailer.company(ta.company)
    mailer.mobile(ta.mobile)
    mailer.telephone(ta.telephone)
    mailer.street(ta.street)
    mailer.city(ta.city)
    mailer.postalcode(ta.postalcode)
    mailer.country(ta.country)

    # Add items to email
    for item, purchase_price in ta.get_distinct_storeitems_and_prices():<commit_msg>store: Clean up some deprecated methods and unnecessary imports<commit_after># -*- coding: utf-8 -*-

from Instanssi.common.misc import get_url
from datetime import datetime
from django.conf import settings
from django.core.urlresolvers import reverse
from Instanssi.store.utils.emailer import ReceiptMailer

# Logging related
import logging
logger = logging.getLogger(__name__)


def handle_cancellation(ta):
    if not ta.time_cancelled:
        ta.time_cancelled = datetime.now()
        ta.save()
        logger.info('Store transaction {} cancelled.'.format(ta.id))
    else:
        logger.warning('Attempted to mark store transaction {} as cancelled twice'.format(ta.id))


def handle_pending(ta):
    if ta.time_cancelled:
        logger.warning('Cannot mark store transaction {} pending; is already cancelled.'.format(ta.id))
    elif not ta.time_pending:
        ta.time_pending = datetime.now()
        ta.save()
        logger.info('Store transaction {} paid, pending confirmation.'.format(ta.id))
    else:
        logger.warning('Attempted to mark store transaction {} as pending twice'.format(ta.id))


def handle_payment(ta):
    # Deliver email.
    mailer = ReceiptMailer('"Instanssi" <noreply@' + settings.DOMAIN + '>', ta.email, 'Instanssi.org kuitti')
    mailer.ordernumber(ta.id)
    mailer.firstname(ta.firstname)
    mailer.lastname(ta.lastname)
    mailer.email(ta.email)
    mailer.company(ta.company)
    mailer.mobile(ta.mobile)
    mailer.telephone(ta.telephone)
    mailer.street(ta.street)
    mailer.city(ta.city)
    mailer.postalcode(ta.postalcode)
    mailer.country(ta.country)

    # Add items to email
    for item, purchase_price in ta.get_distinct_storeitems_and_prices():
{'fraction_non_alphanumeric': 0.11270491803278689, 'fraction_numerical': 0.000585480093676815, 'mean_word_length': 3.6872427983539096, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2956677', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1057, 'n_words': 235}