diff --git a/lingo/migrations/0010_regie_payment_min_amount.py b/lingo/migrations/0010_regie_payment_min_amount.py
new file mode 100644
index 0000000..7098886
--- /dev/null
+++ b/lingo/migrations/0010_regie_payment_min_amount.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('lingo', '0009_auto_20150917_1456'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='regie',
+ name='payment_min_amount',
+ field=models.DecimalField(default=0, verbose_name='Minimal payment amount', max_digits=7, decimal_places=2),
+ preserve_default=True,
+ ),
+ ]
diff --git a/lingo/models.py b/lingo/models.py
index c961bf2..7b2eb8a 100644
--- a/lingo/models.py
+++ b/lingo/models.py
@@ -71,6 +71,8 @@ class Regie(models.Model):
verbose_name=_('Payment Service Options'))
webservice_url = models.URLField(_('Webservice URL to retrieve remote items'),
blank=True)
+ payment_min_amount = models.DecimalField(_('Minimal payment amount'),
+ max_digits=7, decimal_places=2, default=0)
def is_remote(self):
return self.webservice_url != ''
diff --git a/lingo/templates/lingo/combo/item.html b/lingo/templates/lingo/combo/item.html
index 7ebbbc1..c3c219c 100644
--- a/lingo/templates/lingo/combo/item.html
+++ b/lingo/templates/lingo/combo/item.html
@@ -29,7 +29,7 @@
{% if item.payment_date %}
{% trans "Payed on:" %} {{ item.payment_date|date:"SHORT_DATE_FORMAT" }}
{% endif %}
- {% if item.online_payment %}
+ {% if item.amount >= regie.payment_min_amount %}
{% csrf_token %}
diff --git a/lingo/templates/lingo/combo/items.html b/lingo/templates/lingo/combo/items.html
index 04a027e..ea902e3 100644
--- a/lingo/templates/lingo/combo/items.html
+++ b/lingo/templates/lingo/combo/items.html
@@ -26,7 +26,7 @@
{% trans "View" %}
- {% if item.online_payment %}{% trans "and pay" %}{% endif %}
+ {% if item.amount >= item.regie.payment_min_amount %}{% trans "and pay" %}{% endif %}
{% if item.has_pdf %} /
diff --git a/lingo/views.py b/lingo/views.py
index 767eebb..745c52f 100644
--- a/lingo/views.py
+++ b/lingo/views.py
@@ -20,6 +20,7 @@ import json
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect
+from django.http import HttpResponseForbidden
from django.template.response import TemplateResponse
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
@@ -132,6 +133,9 @@ class PayView(View):
else:
total_amount = sum([x.amount for x in items])
+ if total_amount < regie.payment_min_amount:
+ return HttpResponseForbidden()
+
payment = eopayment.Payment(regie.service, regie.service_options)
return_url = request.build_absolute_uri(
reverse('lingo-callback', kwargs={'regie_pk': regie.id}))
|