lingo: define minimal payment amount per regie (#8511)

This commit is contained in:
Serghei Mihai 2015-10-05 18:03:52 +02:00 committed by Frédéric Péters
parent 6b8faf8857
commit cc5e1d8ef6
5 changed files with 28 additions and 2 deletions

View File

@ -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,
),
]

View File

@ -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 != ''

View File

@ -29,7 +29,7 @@
{% if item.payment_date %}
<div class="paid">{% trans "Payed on:" %} {{ item.payment_date|date:"SHORT_DATE_FORMAT" }}</div>
{% endif %}
{% if item.online_payment %}
{% if item.amount >= regie.payment_min_amount %}
{% csrf_token %}
<input type="hidden" name="regie" value="{{ regie.pk }}" />
<input type="hidden" name="item" value="{{ item.id }}" />

View File

@ -26,7 +26,7 @@
</td>
<td>
<a href="{% url 'view-item' regie_id=item.regie.pk item_id=item.id %}" rel="popup" class="icon-view">{% trans "View" %}
{% if item.online_payment %}{% trans "and pay" %}{% endif %}
{% if item.amount >= item.regie.payment_min_amount %}{% trans "and pay" %}{% endif %}
</a>
{% if item.has_pdf %} /
<a href="{% url 'download-item-pdf' regie_id=item.regie.pk item_id=item.id %}" class="icon-pdf">

View File

@ -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}))