# Path: payway/qiwi/views.py
# class QiwiView(TemplateView):
#     template_name = 'qiwi/add_money_request.html'
# 
#     def get(self, request, *args, **kwargs):
#         context = super(QiwiView, self).get_context_data(**kwargs)
#         invoice_uid = int(kwargs.get('invoice_uid', 0))
#         invoice = get_object_or_404(Invoice, uid=invoice_uid)
#         invoice.update_money_amount_with_percent(QIWI_PERCENT)
# 
#         context['request_form'] = RequestPaymentForm(initial={
#             'txn_id': invoice.uid,
#             'from': QIWI_LOGIN,
#             'summ': invoice.money_amount.amount,
#             'com': render_to_string(
#                 'qiwi/payment_description.txt', {
#                     'invoice_uid': invoice.uid,
#                     'user': request.user
#                 }).strip()[:255],
#             'lifetime': QIWI_BILL_LIFETIME,
#             'check_agt': QIWI_CHECK_AGT
#             })
# 
#         return self.render_to_response(context)


from django.conf.urls.defaults import patterns, url
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
from payway.qiwi.views import QiwiView
# -*- coding: UTF-8 -*-


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

urlpatterns = patterns('',

# Path: payway/qiwi/views.py
# class QiwiView(TemplateView):
#     template_name = 'qiwi/add_money_request.html'
# 
#     def get(self, request, *args, **kwargs):
#         context = super(QiwiView, self).get_context_data(**kwargs)
#         invoice_uid = int(kwargs.get('invoice_uid', 0))
#         invoice = get_object_or_404(Invoice, uid=invoice_uid)
#         invoice.update_money_amount_with_percent(QIWI_PERCENT)
# 
#         context['request_form'] = RequestPaymentForm(initial={
#             'txn_id': invoice.uid,
#             'from': QIWI_LOGIN,
#             'summ': invoice.money_amount.amount,
#             'com': render_to_string(
#                 'qiwi/payment_description.txt', {
#                     'invoice_uid': invoice.uid,
#                     'user': request.user
#                 }).strip()[:255],
#             'lifetime': QIWI_BILL_LIFETIME,
#             'check_agt': QIWI_CHECK_AGT
#             })
# 
#         return self.render_to_response(context)


# Path: payway/qiwi/urls.py
from django.conf.urls.defaults import patterns, url
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
from payway.qiwi.views import QiwiView

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


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

urlpatterns = patterns('',

    url(r'add-money/(?P<invoice_uid>\d+)/$', login_required(QiwiView.as_view()), name='qiwi_add_money'),