# Path: payway/orders/conf/settings.py
# ORDERS_PER_PAGE = getattr(settings, 'ORDERS_PER_PAGE', 10)
# 
# Path: payway/orders/models.py
# class Order(TimeStampedModel):
#     PAYMENT_STATUS = Choices(
#         (False, 'NOT_PAID', _('not paid')),
#         (True,  'PAID', _('paid')),
#     )
#     user = models.ForeignKey(User, related_name='orders', verbose_name=_('user'))
#     merchant = models.ForeignKey(Merchant, related_name='orders', verbose_name=_('merchant'))
#     uid = models.PositiveIntegerField(unique=False, editable=False)
#     sum = fields.MoneyField(_('sum'), max_digits=MAX_MONEY_DIGITS, decimal_places=MAX_MONEY_PLACES)
#     account = models.ForeignKey(Account, related_name='orders', verbose_name=_('account'))
#     description = models.CharField(_('description'), max_length=255, blank=True)
#     is_paid = models.BooleanField(_('payment status'), default=False, choices=PAYMENT_STATUS)
#     objects = ChainableQuerySetManager(ExtendedQuerySet)
# 
#     class Meta:
#         verbose_name = _('order')
#         verbose_name_plural = _('orders')
#         db_table = 'payway_orders'
# 
#     def __init__(self, *args, **kwargs):
#         account = kwargs.get('account') or None
#         if account:
#             kwargs.setdefault('user', account.user)
#         super(Order, self).__init__(*args, **kwargs)
# 
#     def set_paid(self, is_paid=False):
#         self.is_paid = is_paid
# 
#     def __unicode__(self):
#         return 'Order {0}'.format(self.uid)


from django.views.generic.base import TemplateView
from django_simptools.shortcuts import create_paginated_page
from payway.orders.conf.settings import ORDERS_PER_PAGE
from payway.orders.models import Order
# -*- coding: UTF-8 -*-

__author__ = 'Razzhivin Alexander'
__email__ = 'admin@httpbots.com'


class OrderListView(TemplateView):
    template_name = 'orders/list.html'

    def get(self, request, *args, **kwargs):
        orders_page = create_paginated_page(
            query_set=Order.objects.filter(user=request.user).order_by("-id"),
            page_number=request.GET.get('page') or 1,

# Path: payway/orders/conf/settings.py
# ORDERS_PER_PAGE = getattr(settings, 'ORDERS_PER_PAGE', 10)
# 
# Path: payway/orders/models.py
# class Order(TimeStampedModel):
#     PAYMENT_STATUS = Choices(
#         (False, 'NOT_PAID', _('not paid')),
#         (True,  'PAID', _('paid')),
#     )
#     user = models.ForeignKey(User, related_name='orders', verbose_name=_('user'))
#     merchant = models.ForeignKey(Merchant, related_name='orders', verbose_name=_('merchant'))
#     uid = models.PositiveIntegerField(unique=False, editable=False)
#     sum = fields.MoneyField(_('sum'), max_digits=MAX_MONEY_DIGITS, decimal_places=MAX_MONEY_PLACES)
#     account = models.ForeignKey(Account, related_name='orders', verbose_name=_('account'))
#     description = models.CharField(_('description'), max_length=255, blank=True)
#     is_paid = models.BooleanField(_('payment status'), default=False, choices=PAYMENT_STATUS)
#     objects = ChainableQuerySetManager(ExtendedQuerySet)
# 
#     class Meta:
#         verbose_name = _('order')
#         verbose_name_plural = _('orders')
#         db_table = 'payway_orders'
# 
#     def __init__(self, *args, **kwargs):
#         account = kwargs.get('account') or None
#         if account:
#             kwargs.setdefault('user', account.user)
#         super(Order, self).__init__(*args, **kwargs)
# 
#     def set_paid(self, is_paid=False):
#         self.is_paid = is_paid
# 
#     def __unicode__(self):
#         return 'Order {0}'.format(self.uid)


# Path: payway/orders/views/list.py
from django.views.generic.base import TemplateView
from django_simptools.shortcuts import create_paginated_page
from payway.orders.conf.settings import ORDERS_PER_PAGE
from payway.orders.models import Order

# -*- coding: UTF-8 -*-

__author__ = 'Razzhivin Alexander'
__email__ = 'admin@httpbots.com'


class OrderListView(TemplateView):
    template_name = 'orders/list.html'

    def get(self, request, *args, **kwargs):
        orders_page = create_paginated_page(
            query_set=Order.objects.filter(user=request.user).order_by("-id"),
            page_number=request.GET.get('page') or 1,

            objects_per_page=ORDERS_PER_PAGE