Add a list over shop tickets.

This commit is contained in:
Víðir Valberg Guðmundsson 2019-08-11 13:18:19 +02:00
parent 4ad2a23158
commit 814cbb4af5
5 changed files with 73 additions and 13 deletions

View file

@ -57,6 +57,10 @@
<h4 class="list-group-item-heading">Village Gear To Order</h4>
<p class="list-group-item-text">Use this view to generate a list of village gear that needs to be ordered</p>
</a>
<a href="{% url 'backoffice:shop_ticket_overview' camp_slug=camp.slug %}" class="list-group-item">
<h4 class="list-group-item-heading">Shop Ticket Overview</h4>
<p class="list-group-item-text">Use this to list shop tickets</p>
</a>
{% endif %}
{% if perms.camps.economyteam_permission %}

View file

@ -0,0 +1,39 @@
{% extends 'base.html' %}
{% load commonmark %}
{% load static from staticfiles %}
{% load imageutils %}
{% block extra_head %}
<script src="{% static "js/jquery.dataTables.min.js" %}"></script>
<link rel="stylesheet" href="{% static 'css/jquery.dataTables.min.css' %}">
{% endblock extra_head %}
{% block content %}
<div class="row">
<h2>Shop Tickets</h2>
</div>
<br>
<span class="clearfix"></span>
<hr class="clearfix"/>
<table class="table table-hover">
<thead>
<tr>
<th>Ticket Type</th>
<th>Product</th>
<th>Order comment</th>
<th>Paid?</th>
</tr>
</thead>
<tbody>
{% for ticket in shop_tickets %}
<tr>
<td>{{ ticket.ticket_type.name }}</td>
<td>{{ ticket.product.name }}</td>
<td>{{ ticket.order.comment|default:"None" }}</td>
<td>{{ ticket.order.paid }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock content %}

View file

@ -12,6 +12,7 @@ urlpatterns = [
path("", ScanTicketsView.as_view(), name="scan_tickets"),
]
)),
path("shop_tickets/", ShopTicketOverview.as_view(), name="shop_ticket_overview"),
path("product_handout/", ProductHandoutView.as_view(), name="product_handout"),
path("badge_handout/", BadgeHandoutView.as_view(), name="badge_handout"),
path("ticket_checkin/", TicketCheckinView.as_view(), name="ticket_checkin"),

View file

@ -1,27 +1,26 @@
import logging, os
import logging
import os
from itertools import chain
import qrcode
from django.contrib.auth.mixins import PermissionRequiredMixin, UserPassesTestMixin, LoginRequiredMixin
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.models import User
from django.views.generic import TemplateView, ListView, DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.core.files import File
from django.db.models import Sum
from django.shortcuts import redirect, get_object_or_404
from django.urls import reverse
from django.contrib import messages
from django.utils import timezone
from django.db.models import Sum
from django.conf import settings
from django.core.files import File
from django.views.generic import TemplateView, ListView, DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from camps.mixins import CampViewMixin
from shop.models import OrderProductRelation, Invoice, Order
from tickets.models import ShopTicket, SponsorTicket, DiscountTicket
from economy.models import Chain, Credebtor, Expense, Reimbursement, Revenue
from profiles.models import Profile
from program.models import SpeakerProposal, EventProposal
from economy.models import Chain, Credebtor, Expense, Reimbursement, Revenue
from utils.mixins import RaisePermissionRequiredMixin
from shop.models import OrderProductRelation, Order
from teams.models import Team
from tickets.models import ShopTicket, SponsorTicket, DiscountTicket, TicketType
from .mixins import *
logger = logging.getLogger("bornhack.%s" % __name__)
@ -633,3 +632,17 @@ class ScanTicketsView(LoginRequiredMixin, InfoTeamPermissionMixin, CampViewMixin
order = Order.objects.get(id=request.POST.get('mark_as_paid'))
order.mark_as_paid()
messages.success(request, "Order #{} has been marked as paid!".format(order.id))
class ShopTicketOverview(LoginRequiredMixin, CampViewMixin, ListView):
model = ShopTicket
template_name = "shop_ticket_overview.html"
context_object_name = "shop_tickets"
def get_context_data(self, *, object_list=None, **kwargs):
kwargs['ticket_types'] = TicketType.objects.filter(camp=self.camp)
return super().get_context_data(object_list=object_list, **kwargs)

View file

@ -56,10 +56,13 @@ class BaseTicket(CampRelatedModel, UUIDModel):
class Meta:
abstract = True
camp_filter = 'ticket_type__camp'
@property
def camp(self):
return self.ticket_type.camp
def save(self, **kwargs):
self.token = self._get_token()
self.badge_token = self._get_badge_token()