2017-10-03 19:14:07 +00:00
|
|
|
from django.views.generic import TemplateView, ListView
|
|
|
|
from django.http import HttpResponseForbidden
|
2017-12-04 09:43:25 +00:00
|
|
|
from shop.models import OrderProductRelation
|
2017-12-12 20:57:17 +00:00
|
|
|
from tickets.models import ShopTicket, SponsorTicket, DiscountTicket
|
2018-04-22 06:28:46 +00:00
|
|
|
from profiles.models import Profile
|
2017-12-12 20:57:17 +00:00
|
|
|
from itertools import chain
|
2017-10-03 19:14:07 +00:00
|
|
|
import logging
|
|
|
|
logger = logging.getLogger("bornhack.%s" % __name__)
|
|
|
|
|
|
|
|
|
|
|
|
class StaffMemberRequiredMixin(object):
|
|
|
|
def dispatch(self, request, *args, **kwargs):
|
|
|
|
if not request.user.is_staff:
|
|
|
|
return HttpResponseForbidden()
|
|
|
|
return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class BackofficeIndexView(StaffMemberRequiredMixin, TemplateView):
|
|
|
|
template_name = "backoffice_index.html"
|
|
|
|
|
|
|
|
|
2017-12-12 20:57:17 +00:00
|
|
|
class ProductHandoutView(StaffMemberRequiredMixin, ListView):
|
|
|
|
template_name = "product_handout.html"
|
2017-12-04 09:49:24 +00:00
|
|
|
queryset = OrderProductRelation.objects.filter(handed_out=False, order__paid=True, order__refunded=False, order__cancelled=False).order_by('order')
|
2017-10-03 19:14:07 +00:00
|
|
|
|
2017-12-12 20:57:17 +00:00
|
|
|
|
|
|
|
class BadgeHandoutView(StaffMemberRequiredMixin, ListView):
|
|
|
|
template_name = "badge_handout.html"
|
|
|
|
context_object_name = 'tickets'
|
|
|
|
|
|
|
|
def get_queryset(self, **kwargs):
|
|
|
|
shoptickets = ShopTicket.objects.filter(badge_handed_out=False)
|
|
|
|
sponsortickets = SponsorTicket.objects.filter(badge_handed_out=False)
|
|
|
|
discounttickets = DiscountTicket.objects.filter(badge_handed_out=False)
|
|
|
|
return list(chain(shoptickets, sponsortickets, discounttickets))
|
|
|
|
|
|
|
|
|
|
|
|
class TicketCheckinView(StaffMemberRequiredMixin, ListView):
|
|
|
|
template_name = "ticket_checkin.html"
|
|
|
|
context_object_name = 'tickets'
|
|
|
|
|
|
|
|
def get_queryset(self, **kwargs):
|
|
|
|
shoptickets = ShopTicket.objects.filter(checked_in=False)
|
|
|
|
sponsortickets = SponsorTicket.objects.filter(checked_in=False)
|
|
|
|
discounttickets = DiscountTicket.objects.filter(checked_in=False)
|
|
|
|
return list(chain(shoptickets, sponsortickets, discounttickets))
|
|
|
|
|
2018-04-22 06:28:46 +00:00
|
|
|
|
|
|
|
class ApproveNamesView(StaffMemberRequiredMixin, ListView):
|
|
|
|
template_name = "approve_public_credit_names.html"
|
|
|
|
context_object_name = 'profiles'
|
|
|
|
|
|
|
|
def get_queryset(self, **kwargs):
|
|
|
|
return Profile.objects.filter(public_credit_name_approved=False).exclude(public_credit_name='')
|
|
|
|
|