switch backoffice to use the regular CampViewMixin
This commit is contained in:
parent
9c9edff4f7
commit
3180ec457d
|
@ -1,25 +1,10 @@
|
|||
from django.http import HttpResponseForbidden
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.contrib import messages
|
||||
from camps.models import Camp
|
||||
from camps.mixins import CampViewMixin
|
||||
from utils.mixins import StaffMemberRequiredMixin
|
||||
|
||||
|
||||
class BackofficeViewMixin(object):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
# only permit staff users
|
||||
if not request.user.is_staff:
|
||||
messages.error(request, "No thanks")
|
||||
return HttpResponseForbidden()
|
||||
|
||||
# get camp from url kwarg
|
||||
self.bocamp = get_object_or_404(Camp, slug=kwargs['bocamp_slug'])
|
||||
|
||||
# continue with the request
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
""" Add Camp to template context """
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['bocamp'] = self.bocamp
|
||||
return context
|
||||
class BackofficeViewMixin(CampViewMixin, StaffMemberRequiredMixin):
|
||||
"""
|
||||
Mixin used by all backoffice views. For now just uses CampViewMixin and StaffMemberRequiredMixin.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="row">
|
||||
<h2>Hand Out Badges</h2>
|
||||
<div class="lead">
|
||||
Use this view to hand out badges to participants. Use the search field to search for username, email, products, order ID, ticket UUID, etc. To check in participants go to the <a href="{% url 'backoffice:ticket_checkin' bocamp_slug=bocamp.slug %}">Ticket Checkin view</a> instead. To hand out merchandise and other products go to the <a href="{% url 'backoffice:product_handout' bocamp_slug=bocamp.slug %}">Hand Out Products</a> view instead.
|
||||
Use this view to hand out badges to participants. Use the search field to search for username, email, products, order ID, ticket UUID, etc. To check in participants go to the <a href="{% url 'backoffice:ticket_checkin' camp_slug=camp.slug %}">Ticket Checkin view</a> instead. To hand out merchandise and other products go to the <a href="{% url 'backoffice:product_handout' camp_slug=camp.slug %}">Hand Out Products</a> view instead.
|
||||
</div>
|
||||
<div>
|
||||
This table shows all (Shop|Discount|Sponsor)Tickets which are badge_handed_out=False. Tickets must be checked in before they are shown in this list.
|
||||
|
|
|
@ -14,23 +14,23 @@
|
|||
<div class="row">
|
||||
<p>
|
||||
<div class="list-group">
|
||||
<a href="{% url 'backoffice:product_handout' bocamp_slug=bocamp.slug %}" class="list-group-item">
|
||||
<a href="{% url 'backoffice:product_handout' camp_slug=camp.slug %}" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">Hand Out Products</h4>
|
||||
<p class="list-group-item-text">Use this view to mark products such as merchandise, cabins, fridges and so on as handed out.</p>
|
||||
</a>
|
||||
<a href="{% url 'backoffice:ticket_checkin' bocamp_slug=bocamp.slug %}" class="list-group-item">
|
||||
<a href="{% url 'backoffice:ticket_checkin' camp_slug=camp.slug %}" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">Check-In Tickets</h4>
|
||||
<p class="list-group-item-text">Use this view to check-in tickets when participants arrive.</p>
|
||||
</a>
|
||||
<a href="{% url 'backoffice:badge_handout' bocamp_slug=bocamp.slug %}" class="list-group-item">
|
||||
<a href="{% url 'backoffice:badge_handout' camp_slug=camp.slug %}" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">Hand Out Badges</h4>
|
||||
<p class="list-group-item-text">Use this view to mark badges as handed out.</p>
|
||||
</a>
|
||||
<a href="{% url 'backoffice:public_credit_names' bocamp_slug=bocamp.slug %}" class="list-group-item">
|
||||
<a href="{% url 'backoffice:public_credit_names' camp_slug=camp.slug %}" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">Approve Public Credit Names</h4>
|
||||
<p class="list-group-item-text">Use this view to check and approve users Public Credit Names</p>
|
||||
</a>
|
||||
<a href="{% url 'backoffice:manage_proposals' bocamp_slug=bocamp.slug %}" class="list-group-item">
|
||||
<a href="{% url 'backoffice:manage_proposals' camp_slug=camp.slug %}" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">Manage Proposals</h4>
|
||||
<p class="list-group-item-text">Use this view to manage SpeakerProposals and EventProposals</p>
|
||||
</a>
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
{% block content %}
|
||||
<h3>Manage {{ form.instance.event_type.name }} Proposal</h3>
|
||||
{% include 'includes/eventproposal_detail.html' with camp=bocamp %}
|
||||
{% include 'includes/eventproposal_detail.html' with camp=camp %}
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form %}
|
||||
{% bootstrap_button "<i class='fas fa-check'></i> Approve" button_type="submit" button_class="btn-success" name="approve" %}
|
||||
{% bootstrap_button "<i class='fas fa-times'></i> Reject" button_type="submit" button_class="btn-danger" name="reject" %}
|
||||
<a href="{% url 'backoffice:manage_proposals' bocamp_slug=bocamp.slug %}" class="btn btn-primary"><i class="fas fa-undo"></i> Cancel</a>
|
||||
<a href="{% url 'backoffice:manage_proposals' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-undo"></i> Cancel</a>
|
||||
</form>
|
||||
{% endblock content %}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<td class="text-center">{{ proposal.needs_oneday_ticket|truefalseicon }}</td>
|
||||
<td class="text-center">{{ proposal.event|truefalseicon }}</td>
|
||||
<td>{{ proposal.user }}</td>
|
||||
<td><a href="{% url 'backoffice:speakerproposal_manage' bocamp_slug=bocamp.slug pk=proposal.uuid %}" class="btn btn-primary"><i class="fas fa-cog"></i> Manage</a></td>
|
||||
<td><a href="{% url 'backoffice:speakerproposal_manage' camp_slug=camp.slug pk=proposal.uuid %}" class="btn btn-primary"><i class="fas fa-cog"></i> Manage</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
@ -63,7 +63,7 @@
|
|||
<td>{% for speaker in proposal.speakers.all %}<i class="fas fa-user" data-toggle="tooltip" title="{{ speaker.name }}"></i> {% endfor %}</td>
|
||||
<td class="text-center">{{ proposal.speaker|truefalseicon }}</td>
|
||||
<td>{{ proposal.user }}</td>
|
||||
<td><a href="{% url 'backoffice:eventproposal_manage' bocamp_slug=bocamp.slug pk=proposal.uuid %}" class="btn btn-primary"><i class="fas fa-cog"></i> Manage</a></td>
|
||||
<td><a href="{% url 'backoffice:eventproposal_manage' camp_slug=camp.slug pk=proposal.uuid %}" class="btn btn-primary"><i class="fas fa-cog"></i> Manage</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
{% block content %}
|
||||
<h3>Manage Speaker Proposal</h3>
|
||||
{% include 'includes/speakerproposal_detail.html' with camp=bocamp %}
|
||||
{% include 'includes/speakerproposal_detail.html' with camp=camp %}
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form %}
|
||||
{% bootstrap_button "<i class='fas fa-check'></i> Approve" button_type="submit" button_class="btn-success" name="approve" %}
|
||||
{% bootstrap_button "<i class='fas fa-times'></i> Reject" button_type="submit" button_class="btn-danger" name="reject" %}
|
||||
<a href="{% url 'backoffice:manage_proposals' bocamp_slug=bocamp.slug %}" class="btn btn-primary"><i class="fas fa-undo"></i> Cancel</a>
|
||||
<a href="{% url 'backoffice:manage_proposals' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-undo"></i> Cancel</a>
|
||||
</form>
|
||||
{% endblock content %}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="row">
|
||||
<h2>Hand Out Products</h2>
|
||||
<div class="lead">
|
||||
Use this view to hand out products to participants. Use the search field to search for username, email, products, order ID etc. To check in participants go to the <a href="{% url 'backoffice:ticket_checkin' bocamp_slug=bocamp.slug %}">Ticket Checkin view</a> instead. To hand out badges go to the <a href="{% url 'backoffice:badge_handout' bocamp_slug=bocamp.slug %}">Badge Handout view</a> instead.
|
||||
Use this view to hand out products to participants. Use the search field to search for username, email, products, order ID etc. To check in participants go to the <a href="{% url 'backoffice:ticket_checkin' camp_slug=camp.slug %}">Ticket Checkin view</a> instead. To hand out badges go to the <a href="{% url 'backoffice:badge_handout' camp_slug=camp.slug %}">Badge Handout view</a> instead.
|
||||
</div>
|
||||
<div>
|
||||
This table shows all OrderProductRelations which are handed_out=False (not including unpaid, cancelled and refunded orders). The table is initally sorted by order ID but the sorting can be changed by clicking the column headlines (if javascript is enabled).
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="row">
|
||||
<h2>Ticket Check-In</h2>
|
||||
<div class="lead">
|
||||
Use this view to check in participants. Use the search field to search for username, email, products, order ID, ticket UUID, etc. To hand out badges go to the <a href="{% url 'backoffice:badge_handout' bocamp_slug=bocamp.slug %}">Badge Handout view</a> instead. To hand out other products go to the <a href="{% url 'backoffice:product_handout' bocamp_slug=bocamp.slug %}">Hand Out Products</a> view instead.
|
||||
Use this view to check in participants. Use the search field to search for username, email, products, order ID, ticket UUID, etc. To hand out badges go to the <a href="{% url 'backoffice:badge_handout' camp_slug=camp.slug %}">Badge Handout view</a> instead. To hand out other products go to the <a href="{% url 'backoffice:product_handout' camp_slug=camp.slug %}">Hand Out Products</a> view instead.
|
||||
</div>
|
||||
<div>
|
||||
This table shows all (Shop|Discount|Sponsor)Tickets which are checked_in=False.
|
||||
|
|
|
@ -5,9 +5,7 @@ from .views import *
|
|||
app_name = 'backoffice'
|
||||
|
||||
urlpatterns = [
|
||||
path('', CampSelectView.as_view(), name='camp_select'),
|
||||
path('<slug:bocamp_slug>/', include([
|
||||
path('', CampIndexView.as_view(), name='camp_index'),
|
||||
path('', BackofficeIndexView.as_view(), name='index'),
|
||||
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'),
|
||||
|
@ -17,6 +15,5 @@ urlpatterns = [
|
|||
path('speakers/<uuid:pk>/', SpeakerProposalManageView.as_view(), name='speakerproposal_manage'),
|
||||
path('events/<uuid:pk>/', EventProposalManageView.as_view(), name='eventproposal_manage'),
|
||||
])),
|
||||
])),
|
||||
]
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ from shop.models import OrderProductRelation
|
|||
from tickets.models import ShopTicket, SponsorTicket, DiscountTicket
|
||||
from profiles.models import Profile
|
||||
from camps.models import Camp
|
||||
from utils.mixins import StaffMemberRequiredMixin
|
||||
from camps.mixins import CampViewMixin
|
||||
from program.models import SpeakerProposal, EventProposal
|
||||
|
||||
from .mixins import BackofficeViewMixin
|
||||
|
@ -20,31 +20,8 @@ from .mixins import BackofficeViewMixin
|
|||
logger = logging.getLogger("bornhack.%s" % __name__)
|
||||
|
||||
|
||||
class CampSelectView(StaffMemberRequiredMixin, ListView):
|
||||
model = Camp
|
||||
template_name = "camp_select.html"
|
||||
|
||||
def get_queryset(self):
|
||||
"""
|
||||
Filter away camps that are not writeable, since they are not interesting from a backoffice perspective
|
||||
"""
|
||||
return super().get_queryset().filter(read_only=False)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
"""
|
||||
If we only have one writable Camp redirect directly to it rather than show a 1 item list
|
||||
"""
|
||||
if self.get_queryset().count() == 1:
|
||||
return redirect(
|
||||
reverse('backoffice:camp_index', kwargs={
|
||||
'bocamp_slug': self.get_queryset().first().slug
|
||||
})
|
||||
)
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
|
||||
class CampIndexView(BackofficeViewMixin, TemplateView):
|
||||
template_name = "camp_index.html"
|
||||
class BackofficeIndexView(BackofficeViewMixin, TemplateView):
|
||||
template_name = "index.html"
|
||||
|
||||
|
||||
class ProductHandoutView(BackofficeViewMixin, ListView):
|
||||
|
@ -96,14 +73,14 @@ class ManageProposalsView(BackofficeViewMixin, ListView):
|
|||
|
||||
def get_queryset(self, **kwargs):
|
||||
return SpeakerProposal.objects.filter(
|
||||
camp=self.bocamp,
|
||||
camp=self.camp,
|
||||
proposal_status=SpeakerProposal.PROPOSAL_PENDING
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['eventproposals'] = EventProposal.objects.filter(
|
||||
track__camp=self.bocamp,
|
||||
track__camp=self.camp,
|
||||
proposal_status=EventProposal.PROPOSAL_PENDING
|
||||
)
|
||||
return context
|
||||
|
@ -128,7 +105,7 @@ class ProposalManageView(BackofficeViewMixin, UpdateView):
|
|||
form.instance.mark_as_rejected(self.request)
|
||||
else:
|
||||
messages.error(self.request, "Unknown submit action")
|
||||
return redirect(reverse('backoffice:manage_proposals', kwargs={'bocamp_slug': self.bocamp.slug}))
|
||||
return redirect(reverse('backoffice:manage_proposals', kwargs={'camp_slug': self.camp.slug}))
|
||||
|
||||
|
||||
class SpeakerProposalManageView(ProposalManageView):
|
||||
|
|
|
@ -113,11 +113,6 @@ urlpatterns = [
|
|||
name='people',
|
||||
),
|
||||
|
||||
path(
|
||||
'backoffice/',
|
||||
include('backoffice.urls', namespace='backoffice')
|
||||
),
|
||||
|
||||
# camp specific urls below here
|
||||
|
||||
path(
|
||||
|
@ -187,6 +182,10 @@ urlpatterns = [
|
|||
include('teams.urls', namespace='teams')
|
||||
),
|
||||
|
||||
path(
|
||||
'backoffice/',
|
||||
include('backoffice.urls', namespace='backoffice')
|
||||
),
|
||||
|
||||
])
|
||||
)
|
||||
|
|
|
@ -73,8 +73,7 @@
|
|||
</li>
|
||||
<li><a href="{% url 'contact' %}">Contact</a></li>
|
||||
<li><a href="{% url 'people' %}">People</a></li>
|
||||
{% if user.is_authenticated and user.is_staff %}
|
||||
<li><a href="{% url 'backoffice:camp_select' %}">Backoffice</a></li>
|
||||
{% if request.user.is_staff %}
|
||||
<li><a href="{% url 'admin:index' %}">Django Admin</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
|
@ -5,4 +5,7 @@
|
|||
<a class="btn {% menubuttonclass 'villages' %}" href="{% url 'village_list' camp_slug=camp.slug %}">Villages</a>
|
||||
<a class="btn {% menubuttonclass 'sponsors' %}" href="{% url 'sponsors' camp_slug=camp.slug %}">Sponsors</a>
|
||||
<a class="btn {% menubuttonclass 'teams' %}" href="{% url 'teams:list' camp_slug=camp.slug %}">Teams</a>
|
||||
{% if request.user.is_staff %}
|
||||
<a class="btn {% menubuttonclass 'backoffice' %}" href="{% url 'backoffice:index' camp_slug=camp.slug %}">Backoffice</a>
|
||||
{% endif %}
|
||||
|
||||
|
|
Loading…
Reference in a new issue