예제 #1
0
    def post(self, request, *args, **kwargs):
        failed = not self.save() or not self.invoice_form.is_valid()
        if failed:
            messages.error(
                self.request,
                _("We had difficulties processing your input. Please review the errors below."
                  ))
            return self.get(request, *args, **kwargs)
        if hasattr(self.invoice_form, 'save'):
            self.invoice_form.save()
        self.order.log_action(
            'pretix.event.order.modified', {
                'invoice_data':
                self.invoice_form.cleaned_data,
                'data': [{
                    k: (f.cleaned_data.get(k).name if isinstance(
                        f.cleaned_data.get(k), File) else
                        f.cleaned_data.get(k))
                    for k in f.changed_data
                } for f in self.forms]
            })
        order_modified.send(sender=self.request.event, order=self.order)
        if self.invoice_form.has_changed():
            success_message = (
                'Your invoice address has been updated. Please contact us if you need us '
                'to regenerate your invoice.')
            messages.success(self.request, _(success_message))

        invalidate_cache.apply_async(kwargs={
            'event': self.request.event.pk,
            'order': self.order.pk
        })
        CachedTicket.objects.filter(order_position__order=self.order).delete()
        CachedCombinedTicket.objects.filter(order=self.order).delete()
        return redirect(self.get_order_url())
예제 #2
0
    def perform_update(self, serializer):
        with transaction.atomic():
            if 'comment' in self.request.data and serializer.instance.comment != self.request.data.get('comment'):
                serializer.instance.log_action(
                    'pretix.event.order.comment',
                    user=self.request.user,
                    auth=self.request.auth,
                    data={
                        'new_comment': self.request.data.get('comment')
                    }
                )

            if 'checkin_attention' in self.request.data and serializer.instance.checkin_attention != self.request.data.get('checkin_attention'):
                serializer.instance.log_action(
                    'pretix.event.order.checkin_attention',
                    user=self.request.user,
                    auth=self.request.auth,
                    data={
                        'new_value': self.request.data.get('checkin_attention')
                    }
                )

            if 'email' in self.request.data and serializer.instance.email != self.request.data.get('email'):
                serializer.instance.email_known_to_work = False
                serializer.instance.log_action(
                    'pretix.event.order.contact.changed',
                    user=self.request.user,
                    auth=self.request.auth,
                    data={
                        'old_email': serializer.instance.email,
                        'new_email': self.request.data.get('email'),
                    }
                )

            if 'locale' in self.request.data and serializer.instance.locale != self.request.data.get('locale'):
                serializer.instance.log_action(
                    'pretix.event.order.locale.changed',
                    user=self.request.user,
                    auth=self.request.auth,
                    data={
                        'old_locale': serializer.instance.locale,
                        'new_locale': self.request.data.get('locale'),
                    }
                )

            if 'invoice_address' in self.request.data:
                serializer.instance.log_action(
                    'pretix.event.order.modified',
                    user=self.request.user,
                    auth=self.request.auth,
                    data={
                        'invoice_data': self.request.data.get('invoice_address'),
                    }
                )

            serializer.save()
            tickets.invalidate_cache.apply_async(kwargs={'event': serializer.instance.event.pk, 'order': serializer.instance.pk})

        if 'invoice_address' in self.request.data:
            order_modified.send(sender=serializer.instance.event, order=serializer.instance)
예제 #3
0
    def post(self, request, *args, **kwargs):
        failed = not self.save() or not self.invoice_form.is_valid()
        if failed:
            messages.error(self.request,
                           _("We had difficulties processing your input. Please review the errors below."))
            return self.get(request, *args, **kwargs)
        if hasattr(self.invoice_form, 'save'):
            self.invoice_form.save()
        self.order.log_action('pretix.event.order.modified', {
            'invoice_data': self.invoice_form.cleaned_data,
            'data': [{
                k: (f.cleaned_data.get(k).name
                    if isinstance(f.cleaned_data.get(k), File)
                    else f.cleaned_data.get(k))
                for k in f.changed_data
            } for f in self.forms]
        })
        order_modified.send(sender=self.request.event, order=self.order)
        if self.invoice_form.has_changed():
            success_message = ('Your invoice address has been updated. Please contact us if you need us '
                               'to regenerate your invoice.')
            messages.success(self.request, _(success_message))

        invalidate_cache.apply_async(kwargs={'event': self.request.event.pk, 'order': self.order.pk})
        CachedTicket.objects.filter(order_position__order=self.order).delete()
        CachedCombinedTicket.objects.filter(order=self.order).delete()
        return redirect(self.get_order_url())
예제 #4
0
    def perform_update(self, serializer):
        with transaction.atomic():
            if 'comment' in self.request.data and serializer.instance.comment != self.request.data.get('comment'):
                serializer.instance.log_action(
                    'pretix.event.order.comment',
                    user=self.request.user,
                    auth=self.request.auth,
                    data={
                        'new_comment': self.request.data.get('comment')
                    }
                )

            if 'checkin_attention' in self.request.data and serializer.instance.checkin_attention != self.request.data.get('checkin_attention'):
                serializer.instance.log_action(
                    'pretix.event.order.checkin_attention',
                    user=self.request.user,
                    auth=self.request.auth,
                    data={
                        'new_value': self.request.data.get('checkin_attention')
                    }
                )

            if 'email' in self.request.data and serializer.instance.email != self.request.data.get('email'):
                serializer.instance.email_known_to_work = False
                serializer.instance.log_action(
                    'pretix.event.order.contact.changed',
                    user=self.request.user,
                    auth=self.request.auth,
                    data={
                        'old_email': serializer.instance.email,
                        'new_email': self.request.data.get('email'),
                    }
                )

            if 'locale' in self.request.data and serializer.instance.locale != self.request.data.get('locale'):
                serializer.instance.log_action(
                    'pretix.event.order.locale.changed',
                    user=self.request.user,
                    auth=self.request.auth,
                    data={
                        'old_locale': serializer.instance.locale,
                        'new_locale': self.request.data.get('locale'),
                    }
                )

            if 'invoice_address' in self.request.data:
                serializer.instance.log_action(
                    'pretix.event.order.modified',
                    user=self.request.user,
                    auth=self.request.auth,
                    data={
                        'invoice_data': self.request.data.get('invoice_address'),
                    }
                )

            serializer.save()
            tickets.invalidate_cache.apply_async(kwargs={'event': serializer.instance.event.pk, 'order': serializer.instance.pk})

        if 'invoice_address' in self.request.data:
            order_modified.send(sender=serializer.instance.event, order=serializer.instance)
예제 #5
0
    def post(self, request, *args, **kwargs):
        failed = not self.save() or not self.invoice_form.is_valid()
        if failed:
            messages.error(self.request,
                           _("We had difficulties processing your input. Please review the errors below."))
            return self.get(request, *args, **kwargs)
        if hasattr(self.invoice_form, 'save'):
            self.invoice_form.save()
        self.order.log_action('pretix.event.order.modified', {
            'invoice_data': self.invoice_form.cleaned_data,
            'data': [{
                k: (f.cleaned_data.get(k).name
                    if isinstance(f.cleaned_data.get(k), File)
                    else f.cleaned_data.get(k))
                for k in f.changed_data
            } for f in self.forms]
        })
        order_modified.send(sender=self.request.event, order=self.order)
        if request.GET.get('generate_invoice') == 'true':
            if not can_generate_invoice(self.request.event, self.order):
                messages.error(self.request, _('You cannot generate an invoice for this order.'))
            elif self.order.invoices.exists():
                messages.error(self.request, _('An invoice for this order already exists.'))
            else:
                i = generate_invoice(self.order)
                self.order.log_action('pretix.event.order.invoice.generated', data={
                    'invoice': i.pk
                })
                messages.success(self.request, _('The invoice has been generated.'))

        invalidate_cache.apply_async(kwargs={'event': self.request.event.pk, 'order': self.order.pk})
        CachedTicket.objects.filter(order_position__order=self.order).delete()
        CachedCombinedTicket.objects.filter(order=self.order).delete()
        return redirect(self.get_order_url())