Cancellation/refund: prefer placeholder over value

This commit is contained in:
Raphael Michel
2020-05-28 18:55:37 +02:00
parent dcc54a0204
commit 1c8468c21b
3 changed files with 16 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models
from django.template.defaultfilters import floatformat
from django.urls import reverse
from django.utils.timezone import make_aware, now
from django.utils.translation import (
@@ -121,7 +122,10 @@ class CancelForm(ConfirmPaymentForm):
prs = self.instance.payment_refund_sum
if prs > 0:
change_decimal_field(self.fields['cancellation_fee'], self.instance.event.currency)
self.fields['cancellation_fee'].initial = Decimal('0.00')
self.fields['cancellation_fee'].widget.attrs['placeholder'] = floatformat(
Decimal('0.00'),
settings.CURRENCY_PLACES.get(self.instance.event.currency, 2)
)
self.fields['cancellation_fee'].max_value = prs
else:
del self.fields['cancellation_fee']

View File

@@ -45,7 +45,11 @@
{% trans "Automatically refund" context "amount_label" %}
<div class="input-group">
<input type="text" name="refund-{{ p.pk }}"
{% if p.propose_refund %}
value="{{ p.propose_refund|floatformat:2 }}"
{% else %}
placeholder="{{ p.propose_refund|floatformat:2 }}"
{% endif %}
title="" class="form-control">
<span class="input-group-addon">
{{ request.event.currency }}
@@ -73,7 +77,7 @@
{% trans "Transfer" context "amount_label" %}
<div class="input-group">
<input type="text" name="refund-offsetting"
title="" class="form-control" value="{{ 0|floatformat:2 }}">
title="" class="form-control" placeholder="{{ 0|floatformat:2 }}">
<span class="input-group-addon">
{{ request.event.currency }}
</span>
@@ -94,7 +98,7 @@
<td>
<div class="input-group">
<input type="text" name="refund-new-giftcard"
title="" class="form-control" value="{{ giftcard_proposal|floatformat:2 }}">
title="" class="form-control" placeholder="{{ giftcard_proposal|floatformat:2 }}">
<span class="input-group-addon">
{{ request.event.currency }}
</span>
@@ -114,7 +118,11 @@
{% trans "Manually refund" context "amount_label" %}
<div class="input-group">
<input type="text" name="refund-manual"
{% if remainder %}
value="{{ remainder|floatformat:2 }}"
{% else %}
placeholder="{{ remainder|floatformat:2 }}"
{% endif %}
title="" class="form-control">
<span class="input-group-addon">
{{ request.event.currency }}

View File

@@ -968,7 +968,7 @@ class OrderTransition(OrderView):
instance=self.order,
data=self.request.POST if self.request.method == "POST" else None,
initial={
'cancellation_fee': self.req.cancellation_fee if self.req else Decimal('0.00')
'cancellation_fee': self.req.cancellation_fee if self.req else None
}
)