# Path: konfera/settings.py
# CURRENCY = getattr(settings, 'CURRENCY', ('€', 'EUR'))
# 
# EMAIL_NOTIFY_BCC = getattr(settings, 'EMAIL_NOTIFY_BCC', [])
# 
# SITE_URL = getattr(settings, 'ABSOLUTE_URL', 'https://www.pycon.sk').rstrip('/')
# 
# UNPAID_ORDER_NOTIFICATION_REPEAT = getattr(settings, 'UNPAID_ORDER_NOTIFICATION_REPEAT', 3)
# 
# UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY = getattr(settings, 'UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY', 5)
# 
# Path: konfera/utils.py
# def send_email(addresses, subject, template_name, formatting_dict=None, **kwargs):
#     formatting_dict = formatting_dict or {}
#     template = get_email_template(template_name)
#     text_template = getattr(template, 'text_template', '')
#     html_template = getattr(template, 'html_template', '')
# 
#     if not text_template:
#         logger.critical('Missing text template (required) for the input {}.'.format(text_template))
#         raise EmailTemplateError("Email template is not valid for the input.")
#     if not html_template:
#         logger.warning('Invalid html template (not required) for the input {}.'.format(html_template))
# 
#     text_content = validate_email_template(text_template, formatting_dict)
#     html_content = validate_email_template(html_template, formatting_dict, False)
# 
#     to = addresses.get('to', [])
#     cc = addresses.get('cc', [])
#     bcc = addresses.get('bcc', EMAIL_NOTIFY_BCC)
# 
#     msg = EmailMultiAlternatives(subject, text_content, to=to, cc=cc, bcc=bcc)
#     if html_content:
#         msg.attach_alternative(html_content, "text/html")
# 
#     try:
#         msg.send()
#     except (SMTPException, ConnectionRefusedError) as e:
#         logger.critical('Sending email raised an exception: %s', e)
#     else:
#         # increase count on email_template
#         template.add_count()
#         if kwargs.get('verbose', 0) > 1:
#             print(msg)
#         return True
# 
# Path: payments/settings.py
# PAYMENT_PROCESS_EMAIL_NOTIFY = getattr(settings, 'PAYMENT_PROCESS_EMAIL_NOTIFY', False)
# FIO_BANK_TOKEN = getattr(settings, 'FIO_BANK_TOKEN', 'token')
# FIO_BANK_PROCESS_DAYS = 3
# PAYMENT_ERROR_RATE = getattr(settings, 'PAYMENT_ERROR_RATE', 0)
# PAYPAL_ADDITIONAL_CHARGE = getattr(settings, 'PAYPAL_ADDITIONAL_CHARGE', 2)
# PAYPAL_MODE = getattr(settings, 'PAYPAL_MODE', 'sandbox')
# PAYPAL_CLIENT_ID = getattr(settings, 'PAYPAL_CLIENT_ID', 'client_id')
# PAYPAL_CLIENT_SECRET = getattr(settings, 'PAYPAL_CLIENT_SECRET', 'secret')


from datetime import timedelta
from decimal import Decimal
from django.db.models import Q
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django import VERSION
from fiobank import FioBank
from konfera.models import Order
from konfera.settings import (CURRENCY, EMAIL_NOTIFY_BCC, SITE_URL,
                              UNPAID_ORDER_NOTIFICATION_REPEAT, UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY)
from konfera.utils import send_email
from payments import settings
from payments.models import ProcessedTransaction
    from django.core.urlresolvers import reverse
    from django.urls import reverse
import requests
import logging
    Display all users who has orders overdue.
    """
    return get_unpaid_orders_print_results(True, verbose)


def show_unpaid_orders(verbose=0):
    """
    Display all users who has no paid orders yet.
    """
    return get_unpaid_orders_print_results(False, verbose)


def email_overdue_orders(verbose=0):
    """
    Mark overdue orders as EXPIRED and send email notifications
    """
    overdue_orders = Order.get_unpaid_orders(overdue=True)
    template_name = 'expired_order_notification'

    for order in overdue_orders:
        subject = 'Your order for {event} has expired.'.format(event=order.event.title)
        order_url = get_full_order_url(order)

        for ticket in order.ticket_set.all():
            content_data = {
                'first_name': ticket.first_name,
                'last_name': ticket.last_name,
                'event': order.event.title,
                'order_url': order_url,
            }

# Path: konfera/settings.py
# CURRENCY = getattr(settings, 'CURRENCY', ('€', 'EUR'))
# 
# EMAIL_NOTIFY_BCC = getattr(settings, 'EMAIL_NOTIFY_BCC', [])
# 
# SITE_URL = getattr(settings, 'ABSOLUTE_URL', 'https://www.pycon.sk').rstrip('/')
# 
# UNPAID_ORDER_NOTIFICATION_REPEAT = getattr(settings, 'UNPAID_ORDER_NOTIFICATION_REPEAT', 3)
# 
# UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY = getattr(settings, 'UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY', 5)
# 
# Path: konfera/utils.py
# def send_email(addresses, subject, template_name, formatting_dict=None, **kwargs):
#     formatting_dict = formatting_dict or {}
#     template = get_email_template(template_name)
#     text_template = getattr(template, 'text_template', '')
#     html_template = getattr(template, 'html_template', '')
# 
#     if not text_template:
#         logger.critical('Missing text template (required) for the input {}.'.format(text_template))
#         raise EmailTemplateError("Email template is not valid for the input.")
#     if not html_template:
#         logger.warning('Invalid html template (not required) for the input {}.'.format(html_template))
# 
#     text_content = validate_email_template(text_template, formatting_dict)
#     html_content = validate_email_template(html_template, formatting_dict, False)
# 
#     to = addresses.get('to', [])
#     cc = addresses.get('cc', [])
#     bcc = addresses.get('bcc', EMAIL_NOTIFY_BCC)
# 
#     msg = EmailMultiAlternatives(subject, text_content, to=to, cc=cc, bcc=bcc)
#     if html_content:
#         msg.attach_alternative(html_content, "text/html")
# 
#     try:
#         msg.send()
#     except (SMTPException, ConnectionRefusedError) as e:
#         logger.critical('Sending email raised an exception: %s', e)
#     else:
#         # increase count on email_template
#         template.add_count()
#         if kwargs.get('verbose', 0) > 1:
#             print(msg)
#         return True
# 
# Path: payments/settings.py
# PAYMENT_PROCESS_EMAIL_NOTIFY = getattr(settings, 'PAYMENT_PROCESS_EMAIL_NOTIFY', False)
# FIO_BANK_TOKEN = getattr(settings, 'FIO_BANK_TOKEN', 'token')
# FIO_BANK_PROCESS_DAYS = 3
# PAYMENT_ERROR_RATE = getattr(settings, 'PAYMENT_ERROR_RATE', 0)
# PAYPAL_ADDITIONAL_CHARGE = getattr(settings, 'PAYPAL_ADDITIONAL_CHARGE', 2)
# PAYPAL_MODE = getattr(settings, 'PAYPAL_MODE', 'sandbox')
# PAYPAL_CLIENT_ID = getattr(settings, 'PAYPAL_CLIENT_ID', 'client_id')
# PAYPAL_CLIENT_SECRET = getattr(settings, 'PAYPAL_CLIENT_SECRET', 'secret')


# Path: payments/utils.py
from datetime import timedelta
from decimal import Decimal
from django.db.models import Q
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django import VERSION
from fiobank import FioBank
from konfera.models import Order
from konfera.settings import (CURRENCY, EMAIL_NOTIFY_BCC, SITE_URL,
                              UNPAID_ORDER_NOTIFICATION_REPEAT, UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY)
from konfera.utils import send_email
from payments import settings
from payments.models import ProcessedTransaction
    from django.core.urlresolvers import reverse
    from django.urls import reverse
import requests
import logging

    Display all users who has orders overdue.
    """
    return get_unpaid_orders_print_results(True, verbose)


def show_unpaid_orders(verbose=0):
    """
    Display all users who has no paid orders yet.
    """
    return get_unpaid_orders_print_results(False, verbose)


def email_overdue_orders(verbose=0):
    """
    Mark overdue orders as EXPIRED and send email notifications
    """
    overdue_orders = Order.get_unpaid_orders(overdue=True)
    template_name = 'expired_order_notification'

    for order in overdue_orders:
        subject = 'Your order for {event} has expired.'.format(event=order.event.title)
        order_url = get_full_order_url(order)

        for ticket in order.ticket_set.all():
            content_data = {
                'first_name': ticket.first_name,
                'last_name': ticket.last_name,
                'event': order.event.title,
                'order_url': order_url,
            }

            addresses = {'to': [ticket.email], 'bcc': EMAIL_NOTIFY_BCC}