diff --git a/src/backoffice/templates/ticket_checkin.html b/src/backoffice/templates/ticket_checkin.html index b35181ef..85344325 100644 --- a/src/backoffice/templates/ticket_checkin.html +++ b/src/backoffice/templates/ticket_checkin.html @@ -13,7 +13,7 @@ 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 Badge Handout view instead. To hand out other products go to the Hand Out Products view instead.
- This table shows all (Shop|Discount|Sponsor)Tickets which are checked_in=False. + This table shows all (Shop|Discount|Sponsor)Tickets which are used=False.

diff --git a/src/backoffice/templates/user/search.html b/src/backoffice/templates/user/search.html index 7c75d026..37afbdbd 100644 --- a/src/backoffice/templates/user/search.html +++ b/src/backoffice/templates/user/search.html @@ -24,7 +24,7 @@ {% if ticket %} {{ ticket }}

- Checked in?: {{ ticket.checked_in }} + Used?: {{ ticket.used }}
{% csrf_token %} diff --git a/src/backoffice/views.py b/src/backoffice/views.py index 07cfbba2..e66c98d6 100644 --- a/src/backoffice/views.py +++ b/src/backoffice/views.py @@ -64,9 +64,9 @@ class TicketCheckinView(CampViewMixin, InfoTeamPermissionMixin, ListView): 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) + shoptickets = ShopTicket.objects.filter(used=False) + sponsortickets = SponsorTicket.objects.filter(used=False) + discounttickets = DiscountTicket.objects.filter(used=False) return list(chain(shoptickets, sponsortickets, discounttickets)) @@ -553,7 +553,7 @@ class SearchForUser(TemplateView): check_in_ticket_id = request.POST.get("check_in_ticket_id") if check_in_ticket_id: ticket_to_check_in = ShopTicket.objects.get(pk=check_in_ticket_id) - ticket_to_check_in.checked_in = True + ticket_to_check_in.used = True ticket_to_check_in.save() messages.info(request, "Ticket checked-in!") diff --git a/src/profiles/templates/tickets/ticket_detail.html b/src/profiles/templates/tickets/ticket_detail.html index 16d24de7..a234a668 100644 --- a/src/profiles/templates/tickets/ticket_detail.html +++ b/src/profiles/templates/tickets/ticket_detail.html @@ -10,7 +10,7 @@
-

{% if ticket.checked_in %}This ticket has been used{% else %}This ticket is unused{% endif %}

+

{% if ticket.used %}This ticket has been used{% else %}This ticket is unused{% endif %}

{% csrf_token %} {% bootstrap_field form.name %} diff --git a/src/profiles/templates/tickets/ticket_list.html b/src/profiles/templates/tickets/ticket_list.html index 95aae6f1..c00a9a79 100644 --- a/src/profiles/templates/tickets/ticket_list.html +++ b/src/profiles/templates/tickets/ticket_list.html @@ -38,7 +38,7 @@ {{ ticket.product.price|currency }} - {% if ticket.checked_in %} + {% if ticket.used %} Yes {% else %} Not yet diff --git a/src/shop/migrations/0059_auto_20190718_2051.py b/src/shop/migrations/0059_auto_20190718_2051.py new file mode 100644 index 00000000..8d423deb --- /dev/null +++ b/src/shop/migrations/0059_auto_20190718_2051.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.2 on 2019-07-18 18:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('shop', '0058_order_pdf'), + ] + + operations = [ + migrations.RenameField( + model_name='orderproductrelation', + old_name='handed_out', + new_name='ticket_generated', + ), + ] diff --git a/src/shop/models.py b/src/shop/models.py index d8f1480a..36fd3d2d 100644 --- a/src/shop/models.py +++ b/src/shop/models.py @@ -239,8 +239,8 @@ class Order(CreatedUpdatedModel): else: print(msg) - # and mark the OPR as handed_out=True - order_product.handed_out = True + # and mark the OPR as ticket_generated=True + order_product.ticket_generated = True order_product.save() def mark_as_paid(self, request=None): @@ -466,7 +466,7 @@ class OrderProductRelation(CreatedUpdatedModel): order = models.ForeignKey("shop.Order", on_delete=models.PROTECT) product = models.ForeignKey("shop.Product", on_delete=models.PROTECT) quantity = models.PositiveIntegerField() - handed_out = models.BooleanField(default=False) + ticket_generated = models.BooleanField(default=False) @property def total(self): diff --git a/src/tickets/admin.py b/src/tickets/admin.py index 45a28a25..478bfca6 100644 --- a/src/tickets/admin.py +++ b/src/tickets/admin.py @@ -23,9 +23,9 @@ class TicketTypeAdmin(admin.ModelAdmin): @admin.register(SponsorTicket) class SponsorTicketAdmin(BaseTicketAdmin): - list_display = ["pk", "ticket_type", "sponsor", "checked_in"] + list_display = ["pk", "ticket_type", "sponsor", "used"] - list_filter = ["ticket_type__camp", "checked_in", "ticket_type", "sponsor"] + list_filter = ["ticket_type__camp", "used", "ticket_type", "sponsor"] search_fields = ["pk", "sponsor__name"] @@ -50,10 +50,10 @@ class ShopTicketAdmin(BaseTicketAdmin): "ticket_type", "order", "product", - "checked_in", + "used", ] - list_filter = ["ticket_type__camp", "checked_in", "ticket_type", "order", "product"] + list_filter = ["ticket_type__camp", "used", "ticket_type", "order", "product"] search_fields = ["uuid", "order__id", "order__user__email", "name", "email"] diff --git a/src/tickets/migrations/0007_save_token_to_db.py b/src/tickets/migrations/0007_save_token_to_db.py new file mode 100644 index 00000000..aba23f66 --- /dev/null +++ b/src/tickets/migrations/0007_save_token_to_db.py @@ -0,0 +1,33 @@ +# Generated by Django 2.2.2 on 2019-07-18 18:52 +import hashlib + +from django.conf import settings +from django.db import migrations + + +def save_tokens(apps, schema_editor): + ShopTicket = apps.get_model('tickets', 'ShopTicket') + SponsorTicket = apps.get_model('tickets', 'SponsorTicket') + DiscountTicket = apps.get_model('tickets', 'DiscountTicket') + + for model in (ShopTicket, SponsorTicket, DiscountTicket): + + for ticket in model.objects.all(): + token = hashlib.sha256( + "{_id}{secret_key}".format( + _id=ticket.uuid, secret_key=settings.SECRET_KEY + ).encode("utf-8") + ).hexdigest() + ticket.token = token + ticket.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('tickets', '0006_auto_20190616_1746'), + ] + + operations = [ + migrations.RunPython(save_tokens) + ] diff --git a/src/tickets/migrations/0008_auto_20190718_2055.py b/src/tickets/migrations/0008_auto_20190718_2055.py new file mode 100644 index 00000000..3462307b --- /dev/null +++ b/src/tickets/migrations/0008_auto_20190718_2055.py @@ -0,0 +1,43 @@ +# Generated by Django 2.2.2 on 2019-07-18 18:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tickets', '0007_save_token_to_db'), + ] + + operations = [ + migrations.RenameField( + model_name='discountticket', + old_name='checked_in', + new_name='used', + ), + migrations.RenameField( + model_name='shopticket', + old_name='checked_in', + new_name='used', + ), + migrations.RenameField( + model_name='sponsorticket', + old_name='checked_in', + new_name='used', + ), + migrations.AlterField( + model_name='discountticket', + name='token', + field=models.CharField(max_length=64), + ), + migrations.AlterField( + model_name='shopticket', + name='token', + field=models.CharField(max_length=64), + ), + migrations.AlterField( + model_name='sponsorticket', + name='token', + field=models.CharField(max_length=64), + ), + ] diff --git a/src/tickets/models.py b/src/tickets/models.py index 5cd9312e..49ffeab7 100644 --- a/src/tickets/models.py +++ b/src/tickets/models.py @@ -24,7 +24,7 @@ class TicketType(CampRelatedModel, UUIDModel): class BaseTicket(CampRelatedModel, UUIDModel): ticket_type = models.ForeignKey("TicketType", on_delete=models.PROTECT) - checked_in = models.BooleanField(default=False) + used = models.BooleanField(default=False) badge_handed_out = models.BooleanField(default=False) token = models.CharField(max_length=64) diff --git a/src/tickets/templates/pdf/ticket.html b/src/tickets/templates/pdf/ticket.html index 7623325e..d8e3eaa8 100644 --- a/src/tickets/templates/pdf/ticket.html +++ b/src/tickets/templates/pdf/ticket.html @@ -25,8 +25,8 @@

Sponsor: {{ ticket.sponsor.name }}

{% endif %} -{% if ticket.checked_in %} -

This ticket has been checked in.

+{% if ticket.used %} +

This ticket has been used.

{% endif %}