Skip to content

Commit

Permalink
Forbid scanning tickets when camp is read only. (#1620)
Browse files Browse the repository at this point in the history
  • Loading branch information
valberg authored Jul 20, 2024
1 parent 11e0df0 commit ac6dbb2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DOCKER_COMPOSE = COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -p bornhack -f docker/docker-compose.yml
DOCKER_COMPOSE = COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -p bornhack -f docker/docker-compose.yml
DOCKER_RUN = ${DOCKER_COMPOSE} run -u `id -u`
MANAGE_EXEC = ${DOCKER_COMPOSE} exec app python /app/src/manage.py
MANAGE_RUN = ${DOCKER_RUN} app python /app/src/manage.py
Expand Down
20 changes: 11 additions & 9 deletions src/backoffice/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,17 @@ <h4 class="list-group-item-heading">
Use this view see a list of all Credit Notes in the system
</p>
</a>
<a href="{% url 'backoffice:scan_tickets_pos_select' camp_slug=camp.slug %}"
class="list-group-item">
<h4 class="list-group-item-heading">
Scan tickets
</h4>
<p class="list-group-item-text">
Use this view to scan tickets QR codes to check in visitors, hand out merch and HAX, etc.
</p>
</a>
{% if not camp.read_only %}
<a href="{% url 'backoffice:scan_tickets_pos_select' camp_slug=camp.slug %}"
class="list-group-item">
<h4 class="list-group-item-heading">
Scan tickets
</h4>
<p class="list-group-item-text">
Use this view to scan tickets QR codes to check in visitors, hand out merch and HAX, etc.
</p>
</a>
{% endif %}
<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>
Expand Down
3 changes: 3 additions & 0 deletions src/backoffice/views/backoffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def get_context_data(self, *args, **kwargs):
responsible_team__camp=self.camp,
).count()
)

context["camp"] = self.camp

return context


Expand Down
9 changes: 9 additions & 0 deletions src/backoffice/views/infodesk.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.db.models import Q
from django.http import Http404
from django.http import HttpResponse
from django.http import HttpResponseForbidden
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.utils import timezone
Expand Down Expand Up @@ -62,6 +63,10 @@ class ScanTicketsPosSelectView(
model = Pos
template_name = "scan_ticket_pos_select.html"

def dispatch(self, *args, **kwargs):
if self.camp.read_only:
return HttpResponseForbidden("Camp is read-only")


class ScanTicketsView(
LoginRequiredMixin,
Expand All @@ -75,6 +80,10 @@ class ScanTicketsView(
order = None
order_search = False

def dispatch(self, *args, **kwargs):
if self.camp.read_only:
return HttpResponseForbidden("Camp is read-only")

def setup(self, *args, **kwargs):
super().setup(*args, **kwargs)
self.pos = Pos.objects.get(team__camp=self.camp, slug=kwargs["pos_slug"])
Expand Down
3 changes: 3 additions & 0 deletions src/economy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ class Meta:
help_text="The Team managing this POS",
)

def __str__(self):
return f"{self.name} POS ({self.camp})"

def save(self, **kwargs):
"""Generate slug if needed."""
if not self.slug:
Expand Down
8 changes: 4 additions & 4 deletions src/utils/management/commands/bootstrap_devsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1928,28 +1928,28 @@ def create_camp_sponsor_tiers(self, camp):
description="- 10 tickets\n- logo on website\n- physical banner in the speaker's tent\n- thanks from the podium\n- recruitment area\n- sponsor meeting with organizers\n- promoted HackMe\n- sponsored social event",
camp=camp,
weight=0,
tickets=10,
week_tickets=10,
)
tiers["gold"] = SponsorTier.objects.create(
name="Gold sponsors",
description="- 10 tickets\n- logo on website\n- physical banner in the speaker's tent\n- thanks from the podium\n- recruitment area\n- sponsor meeting with organizers\n- promoted HackMe",
camp=camp,
weight=1,
tickets=10,
week_tickets=10,
)
tiers["silver"] = SponsorTier.objects.create(
name="Silver sponsors",
description="- 5 tickets\n- logo on website\n- physical banner in the speaker's tent\n- thanks from the podium\n- recruitment area\n- sponsor meeting with organizers",
camp=camp,
weight=2,
tickets=5,
week_tickets=5,
)
tiers["sponsor"] = SponsorTier.objects.create(
name="Sponsors",
description="- 2 tickets\n- logo on website\n- physical banner in the speaker's tent\n- thanks from the podium\n- recruitment area",
camp=camp,
weight=3,
tickets=2,
week_tickets=2,
)

return tiers
Expand Down

0 comments on commit ac6dbb2

Please sign in to comment.