mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Format eboutic
This commit is contained in:
parent
d722efc40f
commit
4395d62cd8
@ -27,9 +27,9 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from accounting.models import CurrencyField
|
from accounting.models import CurrencyField
|
||||||
from counter.models import Counter, Product, Customer, Selling, Refilling
|
from counter.models import Counter, Product, Selling, Refilling
|
||||||
from core.models import User
|
from core.models import User
|
||||||
from subscription.models import Subscription
|
|
||||||
|
|
||||||
class Basket(models.Model):
|
class Basket(models.Model):
|
||||||
"""
|
"""
|
||||||
@ -64,6 +64,7 @@ class Basket(models.Model):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s's basket (%d items)" % (self.user, self.items.all().count())
|
return "%s's basket (%d items)" % (self.user, self.items.all().count())
|
||||||
|
|
||||||
|
|
||||||
class Invoice(models.Model):
|
class Invoice(models.Model):
|
||||||
"""
|
"""
|
||||||
Invoices are generated once the payment has been validated
|
Invoices are generated once the payment has been validated
|
||||||
@ -120,6 +121,7 @@ class Invoice(models.Model):
|
|||||||
self.validated = True
|
self.validated = True
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
|
||||||
class AbstractBaseItem(models.Model):
|
class AbstractBaseItem(models.Model):
|
||||||
product_id = models.IntegerField(_('product id'))
|
product_id = models.IntegerField(_('product id'))
|
||||||
product_name = models.CharField(_('product name'), max_length=255)
|
product_name = models.CharField(_('product name'), max_length=255)
|
||||||
@ -133,8 +135,10 @@ class AbstractBaseItem(models.Model):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Item: %s (%s) x%d" % (self.product_name, self.product_unit_price, self.quantity)
|
return "Item: %s (%s) x%d" % (self.product_name, self.product_unit_price, self.quantity)
|
||||||
|
|
||||||
|
|
||||||
class BasketItem(AbstractBaseItem):
|
class BasketItem(AbstractBaseItem):
|
||||||
basket = models.ForeignKey(Basket, related_name='items', verbose_name=_('basket'))
|
basket = models.ForeignKey(Basket, related_name='items', verbose_name=_('basket'))
|
||||||
|
|
||||||
|
|
||||||
class InvoiceItem(AbstractBaseItem):
|
class InvoiceItem(AbstractBaseItem):
|
||||||
invoice = models.ForeignKey(Invoice, related_name='items', verbose_name=_('invoice'))
|
invoice = models.ForeignKey(Invoice, related_name='items', verbose_name=_('invoice'))
|
||||||
|
@ -34,7 +34,8 @@ from django.core.management import call_command
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from core.models import User
|
from core.models import User
|
||||||
from counter.models import Customer, ProductType, Product, Counter, Refilling
|
from counter.models import Product, Counter, Refilling
|
||||||
|
|
||||||
|
|
||||||
class EbouticTest(TestCase):
|
class EbouticTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -93,7 +94,6 @@ class EbouticTest(TestCase):
|
|||||||
" <td>Barbar</td>\\n <td>1</td>\\n <td>1.70 \\xe2\\x82\\xac</td>\\n"
|
" <td>Barbar</td>\\n <td>1</td>\\n <td>1.70 \\xe2\\x82\\xac</td>\\n"
|
||||||
" <td>Compte utilisateur</td>" in str(response.content))
|
" <td>Compte utilisateur</td>" in str(response.content))
|
||||||
|
|
||||||
|
|
||||||
def test_buy_simple_product_with_credit_card(self):
|
def test_buy_simple_product_with_credit_card(self):
|
||||||
self.client.login(username='subscriber', password='plop')
|
self.client.login(username='subscriber', password='plop')
|
||||||
response = self.client.post(reverse("eboutic:main"), {
|
response = self.client.post(reverse("eboutic:main"), {
|
||||||
@ -171,6 +171,3 @@ class EbouticTest(TestCase):
|
|||||||
" <td>15.00 \\xe2\\x82\\xac</td>" in str(response.content))
|
" <td>15.00 \\xe2\\x82\\xac</td>" in str(response.content))
|
||||||
response = self.client.get(reverse("core:user_profile", kwargs={"user_id": self.old_subscriber.id}))
|
response = self.client.get(reverse("core:user_profile", kwargs={"user_id": self.old_subscriber.id}))
|
||||||
self.assertTrue("Cotisant jusqu\\'au" in str(response.content))
|
self.assertTrue("Cotisant jusqu\\'au" in str(response.content))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url
|
||||||
|
|
||||||
from eboutic.views import *
|
from eboutic.views import *
|
||||||
|
|
||||||
@ -33,6 +33,3 @@ urlpatterns = [
|
|||||||
url(r'^pay$', EbouticPayWithSith.as_view(), name='pay_with_sith'),
|
url(r'^pay$', EbouticPayWithSith.as_view(), name='pay_with_sith'),
|
||||||
url(r'^et_autoanswer$', EtransactionAutoAnswer.as_view(), name='etransation_autoanswer'),
|
url(r'^et_autoanswer$', EtransactionAutoAnswer.as_view(), name='etransation_autoanswer'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,23 +24,21 @@
|
|||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import pytz
|
|
||||||
import hmac
|
import hmac
|
||||||
import base64
|
import base64
|
||||||
from OpenSSL import crypto
|
from OpenSSL import crypto
|
||||||
|
|
||||||
from django.shortcuts import render
|
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
from django.views.generic import TemplateView, View
|
from django.views.generic import TemplateView, View
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.core.exceptions import SuspiciousOperation
|
from django.core.exceptions import SuspiciousOperation
|
||||||
from django.shortcuts import render
|
|
||||||
from django.db import transaction, DataError
|
from django.db import transaction, DataError
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from counter.models import Customer, Counter, ProductType, Selling
|
from counter.models import Customer, Counter, ProductType, Selling
|
||||||
from eboutic.models import Basket, Invoice, BasketItem, InvoiceItem
|
from eboutic.models import Basket, Invoice, InvoiceItem
|
||||||
|
|
||||||
|
|
||||||
class EbouticMain(TemplateView):
|
class EbouticMain(TemplateView):
|
||||||
template_name = 'eboutic/eboutic_main.jinja'
|
template_name = 'eboutic/eboutic_main.jinja'
|
||||||
@ -77,7 +75,6 @@ class EbouticMain(TemplateView):
|
|||||||
self.del_product(request)
|
self.del_product(request)
|
||||||
return self.render_to_response(self.get_context_data(**kwargs))
|
return self.render_to_response(self.get_context_data(**kwargs))
|
||||||
|
|
||||||
|
|
||||||
def add_product(self, request):
|
def add_product(self, request):
|
||||||
""" Add a product to the basket """
|
""" Add a product to the basket """
|
||||||
try:
|
try:
|
||||||
@ -108,6 +105,7 @@ class EbouticMain(TemplateView):
|
|||||||
kwargs['categories'] = kwargs['categories'].exclude(id=settings.SITH_PRODUCTTYPE_SUBSCRIPTION)
|
kwargs['categories'] = kwargs['categories'].exclude(id=settings.SITH_PRODUCTTYPE_SUBSCRIPTION)
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
class EbouticCommand(TemplateView):
|
class EbouticCommand(TemplateView):
|
||||||
template_name = 'eboutic/eboutic_makecommand.jinja'
|
template_name = 'eboutic/eboutic_makecommand.jinja'
|
||||||
|
|
||||||
@ -150,6 +148,7 @@ class EbouticCommand(TemplateView):
|
|||||||
"sha512").hexdigest().upper()
|
"sha512").hexdigest().upper()
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
class EbouticPayWithSith(TemplateView):
|
class EbouticPayWithSith(TemplateView):
|
||||||
template_name = 'eboutic/eboutic_payment_result.jinja'
|
template_name = 'eboutic/eboutic_payment_result.jinja'
|
||||||
|
|
||||||
@ -189,6 +188,7 @@ class EbouticPayWithSith(TemplateView):
|
|||||||
kwargs['not_enough'] = True
|
kwargs['not_enough'] = True
|
||||||
return self.render_to_response(self.get_context_data(**kwargs))
|
return self.render_to_response(self.get_context_data(**kwargs))
|
||||||
|
|
||||||
|
|
||||||
class EtransactionAutoAnswer(View):
|
class EtransactionAutoAnswer(View):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
if (not 'Amount' in request.GET.keys() or
|
if (not 'Amount' in request.GET.keys() or
|
||||||
@ -225,4 +225,3 @@ class EtransactionAutoAnswer(View):
|
|||||||
return HttpResponse()
|
return HttpResponse()
|
||||||
else:
|
else:
|
||||||
return HttpResponse("Payment failed with error: " + request.GET['Error'], status=400)
|
return HttpResponse("Payment failed with error: " + request.GET['Error'], status=400)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user