diff --git a/src/pretix/control/logdisplay.py b/src/pretix/control/logdisplay.py index 160c07097..b12e3d04b 100644 --- a/src/pretix/control/logdisplay.py +++ b/src/pretix/control/logdisplay.py @@ -325,6 +325,8 @@ def pretixcontrol_logentry_display(sender: Event, logentry: LogEntry, **kwargs): 'pretix.device.initialized': _('The device has been initialized.'), 'pretix.device.keyroll': _('The access token of the device has been regenerated.'), 'pretix.device.updated': _('The device has notified the server of an hardware or software update.'), + 'pretix.giftcards.created': _('The gift card has been created.'), + 'pretix.giftcards.transaction.manual': _('A manual transaction has been performed.'), } data = json.loads(logentry.data) diff --git a/src/pretix/control/templates/pretixcontrol/organizers/giftcard.html b/src/pretix/control/templates/pretixcontrol/organizers/giftcard.html index 34f7398e1..89b7e561c 100644 --- a/src/pretix/control/templates/pretixcontrol/organizers/giftcard.html +++ b/src/pretix/control/templates/pretixcontrol/organizers/giftcard.html @@ -11,81 +11,95 @@ {% trans "TEST MODE" %} {% endif %} -
-
-

- {% trans "Details" %} -

-
-
-
-
{% trans "Gift card code" %}
-
{{ card.secret }}
-
{% trans "Creation date" %}
-
{{ card.issuance|date:"SHORT_DATETIME_FORMAT" }}
-
{% trans "Current value" %}
-
{{ card.value|money:card.currency }}
-
{% trans "Currency" %}
-
{{ card.currency }}
- {% if card.issued_in %} -
{% trans "Issued through sale" %}
-
- - {{ card.issued_in.order.full_code }}-{{ card.issued_in.positionid }} -
- {% endif %} -
-
-
-
-
-

- {% trans "Transactions" %} -

-
- - - - - - - - - - {% for t in card.transactions.all %} - - - - - - {% endfor %} - - - - - - + + + +
+
+

+ {% trans "Transactions" %} +

+
+
{% trans "Date" %}{% trans "Order" %}{% trans "Value" %}
{{ t.datetime|date:"SHORT_DATETIME_FORMAT" }} - {% if t.order %} - - {{ t.order.full_code }} - - {% else %} - {% trans "Manual transaction" %} +
+
+
+
+

+ {% trans "Details" %} +

+
+
+
+
{% trans "Gift card code" %}
+
{{ card.secret }}
+
{% trans "Creation date" %}
+
{{ card.issuance|date:"SHORT_DATETIME_FORMAT" }}
+
{% trans "Current value" %}
+
{{ card.value|money:card.currency }}
+
{% trans "Currency" %}
+
{{ card.currency }}
+ {% if card.issued_in %} +
{% trans "Issued through sale" %}
+
+ + {{ card.issued_in.order.full_code }}-{{ card.issued_in.positionid }} +
{% endif %} -
- {{ t.value|money:card.currency }} -
-
- {% csrf_token %} - - -
-
+ + + + + + + + + {% for t in card.transactions.all %} + + + + + + {% endfor %} + + + + + + - - -
{% trans "Date" %}{% trans "Order" %}{% trans "Value" %}
{{ t.datetime|date:"SHORT_DATETIME_FORMAT" }} + {% if t.order %} + + {{ t.order.full_code }} + + {% else %} + {% trans "Manual transaction" %} + {% endif %} + + {{ t.value|money:card.currency }} +
+
+ {% csrf_token %} + + +
+
+ + + +
+ +
+
+
+

+ {% trans "Gift card history" %} +

+
+ {% include "pretixcontrol/includes/logs.html" with obj=card %} +
+
{% endblock %} diff --git a/src/pretix/control/views/orders.py b/src/pretix/control/views/orders.py index b250c02e1..e62591660 100644 --- a/src/pretix/control/views/orders.py +++ b/src/pretix/control/views/orders.py @@ -724,6 +724,7 @@ class OrderRefundView(OrderView): currency=self.request.event.currency, testmode=self.order.testmode ) + giftcard.log_action('pretix.giftcards.created', user=self.request.user, data={}) refunds.append(OrderRefund( order=self.order, payment=None, diff --git a/src/pretix/control/views/organizer.py b/src/pretix/control/views/organizer.py index d5c405f4c..589763d34 100644 --- a/src/pretix/control/views/organizer.py +++ b/src/pretix/control/views/organizer.py @@ -1056,9 +1056,11 @@ class GiftCardCreateView(OrganizerDetailViewMixin, OrganizerPermissionRequiredMi form.instance.transactions.create( value=form.cleaned_data['value'] ) - form.instance.log_action('pretix.giftcards.transaction.manual', user=self.request.user, data={ - 'value': form.cleaned_data['value'] - }) + form.instance.log_action('pretix.giftcards.created', user=self.request.user, data={}) + if form.cleaned_data['value']: + form.instance.log_action('pretix.giftcards.transaction.manual', user=self.request.user, data={ + 'value': form.cleaned_data['value'] + }) return redirect(reverse( 'control:organizer.giftcard', kwargs={