Adding invoice pdf link to Order admin
This commit is contained in:
parent
9203285299
commit
d3bc597f54
|
@ -8,6 +8,7 @@ admin.site.register(models.CoinifyAPIInvoice)
|
||||||
admin.site.register(models.CoinifyAPICallback)
|
admin.site.register(models.CoinifyAPICallback)
|
||||||
admin.site.register(models.Invoice)
|
admin.site.register(models.Invoice)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(models.ProductCategory)
|
@admin.register(models.ProductCategory)
|
||||||
class ProductCategoryAdmin(admin.ModelAdmin):
|
class ProductCategoryAdmin(admin.ModelAdmin):
|
||||||
list_display = [
|
list_display = [
|
||||||
|
@ -35,9 +36,9 @@ class TicketInline(admin.TabularInline):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(models.Order)
|
@admin.register(models.Order)
|
||||||
class OrderAdmin(admin.ModelAdmin):
|
class OrderAdmin(admin.ModelAdmin):
|
||||||
|
change_form_template = 'admin/change_order_form.html'
|
||||||
list_display = [
|
list_display = [
|
||||||
'id',
|
'id',
|
||||||
'user',
|
'user',
|
||||||
|
@ -67,4 +68,4 @@ class OrderAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
@admin.register(models.Ticket)
|
@admin.register(models.Ticket)
|
||||||
class TicketAdmin(admin.ModelAdmin):
|
class TicketAdmin(admin.ModelAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -2,6 +2,7 @@ from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.aggregates import Sum
|
from django.db.models.aggregates import Sum
|
||||||
from django.contrib.postgres.fields import DateTimeRangeField, JSONField
|
from django.contrib.postgres.fields import DateTimeRangeField, JSONField
|
||||||
|
from django.http import HttpResponse
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
16
shop/templates/admin/change_order_form.html
Normal file
16
shop/templates/admin/change_order_form.html
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{% extends "admin/change_form.html" %}
|
||||||
|
{% load i18n admin_urls admin_static admin_modify %}
|
||||||
|
|
||||||
|
{% block object-tools-items %}
|
||||||
|
<li>
|
||||||
|
{% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}
|
||||||
|
<a href="{% add_preserved_filters history_url %}" class="historylink">{% trans "History" %}</a>
|
||||||
|
</li>
|
||||||
|
{% if original.paid and original.invoice %}
|
||||||
|
<li>
|
||||||
|
{% url 'shop:download_invoice' original.pk|admin_urlquote as invoice_url %}
|
||||||
|
<a href="{% add_preserved_filters invoice_url %}" class="historylink">{% trans "Invoice PDF" %}</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if has_absolute_url %}<li><a href="{{ absolute_url }}" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif %}
|
||||||
|
{% endblock %}
|
|
@ -39,11 +39,13 @@ from vendor.coinify_api import CoinifyAPI
|
||||||
from vendor.coinify_callback import CoinifyCallback
|
from vendor.coinify_callback import CoinifyCallback
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
class EnsureUserOwnsOrderMixin(SingleObjectMixin):
|
class EnsureUserOwnsOrderMixin(SingleObjectMixin):
|
||||||
model = Order
|
model = Order
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
if self.get_object().user != request.user:
|
# If the user does not own this ticket OR is not staff
|
||||||
|
if self.get_object().user != request.user or not request.user.is_staff:
|
||||||
raise Http404("Order not found")
|
raise Http404("Order not found")
|
||||||
|
|
||||||
return super(EnsureUserOwnsOrderMixin, self).dispatch(
|
return super(EnsureUserOwnsOrderMixin, self).dispatch(
|
||||||
|
|
Loading…
Reference in a new issue