Rename handed_out field on ORP to ticket_generated. Rename checked_in on tickets to used. Add save token migration.
This commit is contained in:
parent
5911d2042b
commit
b1b810f165
|
@ -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 <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.
|
||||
This table shows all (Shop|Discount|Sponsor)Tickets which are used=False.
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
{% if ticket %}
|
||||
{{ ticket }}<br />
|
||||
<br />
|
||||
Checked in?: {{ ticket.checked_in }}
|
||||
Used?: {{ ticket.used }}
|
||||
|
||||
<hr />
|
||||
<form id="check_in_form" method="POST" action="">{% csrf_token %}
|
||||
|
|
|
@ -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!")
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<h2>{% if ticket.checked_in %}This ticket has been used{% else %}This ticket is unused{% endif %}</h2>
|
||||
<h2>{% if ticket.used %}This ticket has been used{% else %}This ticket is unused{% endif %}</h2>
|
||||
<form method="POST" class="form">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_field form.name %}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<td>
|
||||
{{ ticket.product.price|currency }}
|
||||
<td>
|
||||
{% if ticket.checked_in %}
|
||||
{% if ticket.used %}
|
||||
Yes
|
||||
{% else %}
|
||||
Not yet
|
||||
|
|
18
src/shop/migrations/0059_auto_20190718_2051.py
Normal file
18
src/shop/migrations/0059_auto_20190718_2051.py
Normal file
|
@ -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',
|
||||
),
|
||||
]
|
|
@ -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):
|
||||
|
|
|
@ -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"]
|
||||
|
||||
|
|
33
src/tickets/migrations/0007_save_token_to_db.py
Normal file
33
src/tickets/migrations/0007_save_token_to_db.py
Normal file
|
@ -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)
|
||||
]
|
43
src/tickets/migrations/0008_auto_20190718_2055.py
Normal file
43
src/tickets/migrations/0008_auto_20190718_2055.py
Normal file
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
<h3>Sponsor: {{ ticket.sponsor.name }} </h3>
|
||||
<img src="{% static 'img/sponsors/' %}{{ sponsor.logo_filename }}"></img>
|
||||
{% endif %}
|
||||
{% if ticket.checked_in %}
|
||||
<h2>This ticket has been checked in.</h2>
|
||||
{% if ticket.used %}
|
||||
<h2>This ticket has been used.</h2>
|
||||
{% endif %}
|
||||
|
||||
<center>
|
||||
|
|
Loading…
Reference in a new issue