mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Allow admin to manually change order email
This commit is contained in:
@@ -88,3 +88,9 @@ class OrderPositionChangeForm(forms.Form):
|
||||
def clean(self):
|
||||
if self.cleaned_data.get('operation') == 'price' and not self.cleaned_data.get('price', '') != '':
|
||||
raise ValidationError(_('You need to enter a price if you want to change the product price.'))
|
||||
|
||||
|
||||
class OrderContactForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Order
|
||||
fields = ['email']
|
||||
|
||||
@@ -59,6 +59,8 @@ def pretixcontrol_logentry_display(sender: Event, logentry: LogEntry, **kwargs):
|
||||
'pretix.event.order.invoice.regenerated': _('The invoice has been regenerated.'),
|
||||
'pretix.event.order.invoice.reissued': _('The invoice has been reissued.'),
|
||||
'pretix.event.order.comment': _('The order\'s internal comment has been updated.'),
|
||||
'pretix.event.order.contact.changed': _('The email address has been changed.'),
|
||||
'pretix.event.order.payment.changed': _('The payment method has been changed.'),
|
||||
}
|
||||
if logentry.action_type in plains:
|
||||
return plains[logentry.action_type]
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{% extends "pretixcontrol/event/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% block title %}
|
||||
{% trans "Change contact information" %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<h1>
|
||||
{% trans "Change contact information" %}
|
||||
</h1>
|
||||
|
||||
<form method="post" class="form-horizontal" href="">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="status" value="c" />
|
||||
{% bootstrap_form form layout='horizontal' %}
|
||||
<div class="form-group submit-group">
|
||||
<a class="btn btn-default btn-lg"
|
||||
href="{% url "control:event.order" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
|
||||
{% trans "Cancel" %}
|
||||
</a>
|
||||
<button class="btn btn-primary btn-save btn-lg" type="submit">
|
||||
{% trans "Save" %}
|
||||
</button>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -91,6 +91,9 @@
|
||||
<dt>{% trans "User" %}</dt>
|
||||
<dd>
|
||||
{{ order.email }}
|
||||
<a href="{% url "control:event.order.contact" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}" class="btn btn-default btn-xs">
|
||||
<span class="fa fa-edit"></span>
|
||||
</a>
|
||||
{% if order.status != "c" %}
|
||||
<form class="form-inline helper-display-inline" method="post"
|
||||
action="{% url "control:event.order.resendlink" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
|
||||
|
||||
@@ -81,6 +81,8 @@ urlpatterns = [
|
||||
name='event.order.reissueinvoice'),
|
||||
url(r'^orders/(?P<code>[0-9A-Z]+)/extend$', orders.OrderExtend.as_view(),
|
||||
name='event.order.extend'),
|
||||
url(r'^orders/(?P<code>[0-9A-Z]+)/contact$', orders.OrderContactChange.as_view(),
|
||||
name='event.order.contact'),
|
||||
url(r'^orders/(?P<code>[0-9A-Z]+)/comment$', orders.OrderComment.as_view(),
|
||||
name='event.order.comment'),
|
||||
url(r'^orders/(?P<code>[0-9A-Z]+)/change$', orders.OrderChange.as_view(),
|
||||
|
||||
@@ -32,7 +32,8 @@ from pretix.base.signals import (
|
||||
register_ticket_outputs,
|
||||
)
|
||||
from pretix.control.forms.orders import (
|
||||
CommentForm, ExporterForm, ExtendForm, OrderPositionChangeForm,
|
||||
CommentForm, ExporterForm, ExtendForm, OrderContactForm,
|
||||
OrderPositionChangeForm,
|
||||
)
|
||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||
from pretix.multidomain.urlreverse import build_absolute_uri
|
||||
@@ -536,6 +537,34 @@ class OrderChange(OrderView):
|
||||
return self.get(*args, **kwargs)
|
||||
|
||||
|
||||
class OrderContactChange(OrderView):
|
||||
permission = 'can_change_orders'
|
||||
template_name = 'pretixcontrol/order/change_contact.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data()
|
||||
ctx['form'] = self.form
|
||||
return ctx
|
||||
|
||||
@cached_property
|
||||
def form(self):
|
||||
return OrderContactForm(
|
||||
instance=self.order,
|
||||
data=self.request.POST if self.request.method == "POST" else None
|
||||
)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
if self.form.is_valid():
|
||||
self.order.log_action('pretix.event.order.contact.changed', {
|
||||
'old_email': self.order.email,
|
||||
'new_email': self.form.cleaned_data['email']
|
||||
})
|
||||
self.form.save()
|
||||
messages.success(self.request, _('The order has been changed.'))
|
||||
return redirect(self.get_order_url())
|
||||
return self.get(*args, **kwargs)
|
||||
|
||||
|
||||
class OverView(EventPermissionRequiredMixin, TemplateView):
|
||||
template_name = 'pretixcontrol/orders/overview.html'
|
||||
permission = 'can_view_orders'
|
||||
|
||||
Reference in New Issue
Block a user