black everything, working on #355

This commit is contained in:
Thomas Steen Rasmussen 2020-02-07 18:46:34 +01:00
parent 20f380dfd6
commit 377a77143c
39 changed files with 312 additions and 213 deletions

View File

@ -7,11 +7,10 @@ app_name = "backoffice"
urlpatterns = [
path("", BackofficeIndexView.as_view(), name="index"),
# infodesk
path("infodesk/", include(
[
path("", ScanTicketsView.as_view(), name="scan_tickets"),
]
)),
path(
"infodesk/",
include([path("", ScanTicketsView.as_view(), name="scan_tickets"),]),
),
path("shop_tickets/", ShopTicketOverview.as_view(), name="shop_ticket_overview"),
path("product_handout/", ProductHandoutView.as_view(), name="product_handout"),
path("badge_handout/", BadgeHandoutView.as_view(), name="badge_handout"),

View File

@ -564,7 +564,9 @@ def _ticket_getter_by_pk(pk):
pass
class ScanTicketsView(LoginRequiredMixin, InfoTeamPermissionMixin, CampViewMixin,TemplateView):
class ScanTicketsView(
LoginRequiredMixin, InfoTeamPermissionMixin, CampViewMixin, TemplateView
):
template_name = "info_desk/scan.html"
ticket = None
@ -591,23 +593,23 @@ class ScanTicketsView(LoginRequiredMixin, InfoTeamPermissionMixin, CampViewMixin
messages.warning(self.request, "Ticket not found!")
elif self.order_search:
context['order'] = self.order
context["order"] = self.order
return context
def post(self, request, **kwargs):
if 'check_in_ticket_id' in request.POST:
if "check_in_ticket_id" in request.POST:
self.ticket = self.check_in_ticket(request)
elif 'badge_ticket_id' in request.POST:
elif "badge_ticket_id" in request.POST:
self.ticket = self.hand_out_badge(request)
elif 'find_order_id' in request.POST:
elif "find_order_id" in request.POST:
self.order_search = True
try:
order_id = self.request.POST.get('find_order_id')
order_id = self.request.POST.get("find_order_id")
self.order = Order.objects.get(id=order_id)
except Order.DoesNotExist:
pass
elif 'mark_as_paid' in request.POST:
elif "mark_as_paid" in request.POST:
self.mark_order_as_paid(request)
return super().get(request, **kwargs)
@ -621,7 +623,7 @@ class ScanTicketsView(LoginRequiredMixin, InfoTeamPermissionMixin, CampViewMixin
return ticket_to_check_in
def hand_out_badge(self, request):
badge_ticket_id = request.POST.get('badge_ticket_id')
badge_ticket_id = request.POST.get("badge_ticket_id")
ticket_to_handout_badge_for = _ticket_getter_by_pk(badge_ticket_id)
ticket_to_handout_badge_for.badge_handed_out = True
ticket_to_handout_badge_for.save()
@ -629,7 +631,7 @@ class ScanTicketsView(LoginRequiredMixin, InfoTeamPermissionMixin, CampViewMixin
return ticket_to_handout_badge_for
def mark_order_as_paid(self, request):
order = Order.objects.get(id=request.POST.get('mark_as_paid'))
order = Order.objects.get(id=request.POST.get("mark_as_paid"))
order.mark_as_paid()
messages.success(request, "Order #{} has been marked as paid!".format(order.id))
@ -643,6 +645,5 @@ class ShopTicketOverview(LoginRequiredMixin, CampViewMixin, ListView):
context_object_name = "shop_tickets"
def get_context_data(self, *, object_list=None, **kwargs):
kwargs['ticket_types'] = TicketType.objects.filter(camp=self.camp)
kwargs["ticket_types"] = TicketType.objects.filter(camp=self.camp)
return super().get_context_data(object_list=object_list, **kwargs)

View File

@ -19,12 +19,14 @@ class CampFactory(DjangoModelFactory):
buildup = factory.LazyFunction(
lambda: DateTimeTZRange(
lower=timezone.now() - timezone.timedelta(days=3),
upper=timezone.now() - timezone.timedelta(hours=1)
upper=timezone.now() - timezone.timedelta(hours=1),
)
)
camp = factory.LazyFunction(
lambda: DateTimeTZRange(lower=timezone.now(), upper=timezone.now() + timezone.timedelta(days=8))
lambda: DateTimeTZRange(
lower=timezone.now(), upper=timezone.now() + timezone.timedelta(days=8)
)
)
teardown = factory.LazyFunction(

View File

@ -6,13 +6,15 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('camps', '0032_auto_20180917_1754'),
("camps", "0032_auto_20180917_1754"),
]
operations = [
migrations.AddField(
model_name='camp',
name='show_schedule',
field=models.BooleanField(default=True, help_text='Check if the schedule should be shown.'),
model_name="camp",
name="show_schedule",
field=models.BooleanField(
default=True, help_text="Check if the schedule should be shown."
),
),
]

View File

@ -24,6 +24,7 @@ def add_new_speakerproposal_email(speakerproposal):
subject="New speaker proposal '%s' was just submitted" % speakerproposal.name,
)
def add_new_eventproposal_email(eventproposal):
formatdict = {"proposal": eventproposal}
@ -41,6 +42,7 @@ def add_new_eventproposal_email(eventproposal):
subject="New event proposal '%s' was just submitted" % eventproposal.title,
)
def add_speakerproposal_updated_email(speakerproposal):
formatdict = {"proposal": speakerproposal}
@ -58,6 +60,7 @@ def add_speakerproposal_updated_email(speakerproposal):
subject="Speaker proposal '%s' was just updated" % speakerproposal.name,
)
def add_eventproposal_updated_email(eventproposal):
formatdict = {"proposal": eventproposal}
@ -74,4 +77,3 @@ def add_eventproposal_updated_email(eventproposal):
formatdict=formatdict,
subject="Event proposal '%s' was just updated" % eventproposal.title,
)

View File

@ -6,13 +6,16 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('program', '0071_auto_20180827_1958'),
("program", "0071_auto_20180827_1958"),
]
operations = [
migrations.AlterField(
model_name='speakerproposal',
name='email',
field=models.EmailField(help_text='The email of the speaker (defaults to the logged in user if empty).', max_length=150),
model_name="speakerproposal",
name="email",
field=models.EmailField(
help_text="The email of the speaker (defaults to the logged in user if empty).",
max_length=150,
),
),
]

View File

@ -6,13 +6,16 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('program', '0072_auto_20190616_1746'),
("program", "0072_auto_20190616_1746"),
]
operations = [
migrations.AddField(
model_name='eventproposal',
name='use_provided_speaker_laptop',
field=models.BooleanField(default=False, help_text='Will you be using the provided speaker laptop?'),
model_name="eventproposal",
name="use_provided_speaker_laptop",
field=models.BooleanField(
default=False,
help_text="Will you be using the provided speaker laptop?",
),
),
]

View File

@ -6,13 +6,15 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('program', '0073_eventproposal_use_provided_speaker_laptop'),
("program", "0073_eventproposal_use_provided_speaker_laptop"),
]
operations = [
migrations.AlterField(
model_name='eventproposal',
name='use_provided_speaker_laptop',
field=models.BooleanField(default=True, help_text='Will you be using the provided speaker laptop?'),
model_name="eventproposal",
name="use_provided_speaker_laptop",
field=models.BooleanField(
default=True, help_text="Will you be using the provided speaker laptop?"
),
),
]

View File

@ -43,17 +43,17 @@ class MultiForm(object):
button. MultiForm imitates the Form API so that it is invisible to anybody
else that you are using a MultiForm.
"""
form_classes = {}
def __init__(self, data=None, files=None, *args, **kwargs):
# Some things, such as the WizardView expect these to exist.
self.data, self.files = data, files
kwargs.update(
data=data,
files=files,
data=data, files=files,
)
self.initials = kwargs.pop('initial', None)
self.initials = kwargs.pop("initial", None)
if self.initials is None:
self.initials = {}
self.forms = OrderedDict()
@ -68,14 +68,13 @@ class MultiForm(object):
Returns the args and kwargs for initializing one of our form children.
"""
fkwargs = kwargs.copy()
prefix = kwargs.get('prefix')
prefix = kwargs.get("prefix")
if prefix is None:
prefix = key
else:
prefix = '{0}__{1}'.format(key, prefix)
prefix = "{0}__{1}".format(key, prefix)
fkwargs.update(
initial=self.initials.get(key),
prefix=prefix,
initial=self.initials.get(key), prefix=prefix,
)
return args, fkwargs
@ -134,19 +133,20 @@ class MultiForm(object):
def non_field_errors(self):
form_errors = (
form.non_field_errors() for form in self.forms.values()
if hasattr(form, 'non_field_errors')
form.non_field_errors()
for form in self.forms.values()
if hasattr(form, "non_field_errors")
)
return ErrorList(chain(self.crossform_errors, *form_errors))
def as_table(self):
return mark_safe(''.join(form.as_table() for form in self.forms.values()))
return mark_safe("".join(form.as_table() for form in self.forms.values()))
def as_ul(self):
return mark_safe(''.join(form.as_ul() for form in self.forms.values()))
return mark_safe("".join(form.as_ul() for form in self.forms.values()))
def as_p(self):
return mark_safe(''.join(form.as_p() for form in self.forms.values()))
return mark_safe("".join(form.as_p() for form in self.forms.values()))
def is_multipart(self):
return any(form.is_multipart() for form in self.forms.values())
@ -167,14 +167,15 @@ class MultiForm(object):
def cleaned_data(self):
return OrderedDict(
(key, form.cleaned_data)
for key, form in self.forms.items() if form.is_valid()
for key, form in self.forms.items()
if form.is_valid()
)
@cleaned_data.setter
def cleaned_data(self, data):
for key, value in data.items():
child_form = self[key]
if hasattr(child_form, 'forms'):
if hasattr(child_form, "forms"):
for formlet, formlet_data in zip(child_form.forms, value):
formlet.cleaned_data = formlet_data
else:
@ -187,33 +188,37 @@ class MultiModelForm(MultiForm):
means that it includes support for the instance parameter in initialization
and adds a save method.
"""
def __init__(self, *args, **kwargs):
self.instances = kwargs.pop('instance', None)
self.instances = kwargs.pop("instance", None)
if self.instances is None:
self.instances = {}
super(MultiModelForm, self).__init__(*args, **kwargs)
def get_form_args_kwargs(self, key, args, kwargs):
fargs, fkwargs = super(MultiModelForm, self).get_form_args_kwargs(key, args, kwargs)
fargs, fkwargs = super(MultiModelForm, self).get_form_args_kwargs(
key, args, kwargs
)
try:
# If we only pass instance when there was one specified, we make it
# possible to use non-ModelForms together with ModelForms.
fkwargs['instance'] = self.instances[key]
fkwargs["instance"] = self.instances[key]
except KeyError:
pass
return fargs, fkwargs
def save(self, commit=True):
objects = OrderedDict(
(key, form.save(commit))
for key, form in self.forms.items()
(key, form.save(commit)) for key, form in self.forms.items()
)
if any(hasattr(form, 'save_m2m') for form in self.forms.values()):
if any(hasattr(form, "save_m2m") for form in self.forms.values()):
def save_m2m():
for form in self.forms.values():
if hasattr(form, 'save_m2m'):
if hasattr(form, "save_m2m"):
form.save_m2m()
self.save_m2m = save_m2m
return objects

View File

@ -6,13 +6,16 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rideshare', '0002_auto_20180814_1942'),
("rideshare", "0002_auto_20180814_1942"),
]
operations = [
migrations.AddField(
model_name='ride',
name='has_car',
field=models.BooleanField(default=True, help_text='Leave checked if you are offering a ride, uncheck if you need a ride'),
model_name="ride",
name="has_car",
field=models.BooleanField(
default=True,
help_text="Leave checked if you are offering a ride, uncheck if you need a ride",
),
),
]

View File

@ -6,13 +6,11 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('rideshare', '0003_ride_has_car'),
("rideshare", "0003_ride_has_car"),
]
operations = [
migrations.RenameField(
model_name='ride',
old_name='location',
new_name='from_location',
model_name="ride", old_name="location", new_name="from_location",
),
]

View File

@ -6,14 +6,14 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rideshare', '0004_auto_20190711_2036'),
("rideshare", "0004_auto_20190711_2036"),
]
operations = [
migrations.AddField(
model_name='ride',
name='to_location',
field=models.CharField(default='BornHack', max_length=100),
model_name="ride",
name="to_location",
field=models.CharField(default="BornHack", max_length=100),
preserve_default=False,
),
]

View File

@ -6,38 +6,51 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rideshare', '0005_ride_to_location'),
("rideshare", "0005_ride_to_location"),
]
operations = [
migrations.AlterField(
model_name='ride',
name='description',
field=models.TextField(help_text='Include any details you want, like luggage space/requirements, contact info and so on.'),
model_name="ride",
name="description",
field=models.TextField(
help_text="Include any details you want, like luggage space/requirements, contact info and so on."
),
),
migrations.AlterField(
model_name='ride',
name='from_location',
field=models.CharField(help_text='Where does this ride begin?', max_length=100),
model_name="ride",
name="from_location",
field=models.CharField(
help_text="Where does this ride begin?", max_length=100
),
),
migrations.AlterField(
model_name='ride',
name='has_car',
field=models.BooleanField(default=True, help_text='Leave checked if you are offering a ride, uncheck if you need a ride.'),
model_name="ride",
name="has_car",
field=models.BooleanField(
default=True,
help_text="Leave checked if you are offering a ride, uncheck if you need a ride.",
),
),
migrations.AlterField(
model_name='ride',
name='seats',
field=models.PositiveIntegerField(help_text='How many seats are you offering/how many seats do you need?'),
model_name="ride",
name="seats",
field=models.PositiveIntegerField(
help_text="How many seats are you offering/how many seats do you need?"
),
),
migrations.AlterField(
model_name='ride',
name='to_location',
field=models.CharField(help_text='What is the destination of this ride?', max_length=100),
model_name="ride",
name="to_location",
field=models.CharField(
help_text="What is the destination of this ride?", max_length=100
),
),
migrations.AlterField(
model_name='ride',
name='when',
field=models.DateTimeField(help_text='When does this ride leave? Format is YYYY-MM-DD HH:mm'),
model_name="ride",
name="when",
field=models.DateTimeField(
help_text="When does this ride leave? Format is YYYY-MM-DD HH:mm"
),
),
]

View File

@ -6,13 +6,17 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rideshare', '0006_auto_20190713_0859'),
("rideshare", "0006_auto_20190713_0859"),
]
operations = [
migrations.AddField(
model_name='ride',
name='author',
field=models.CharField(default='Unnamed', help_text='Let people know who posted this', max_length=100),
model_name="ride",
name="author",
field=models.CharField(
default="Unnamed",
help_text="Let people know who posted this",
max_length=100,
),
),
]

View File

@ -6,13 +6,17 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rideshare', '0007_ride_author'),
("rideshare", "0007_ride_author"),
]
operations = [
migrations.AlterField(
model_name='ride',
name='author',
field=models.CharField(default='Anonymous', help_text='Let people know who posted this', max_length=100),
model_name="ride",
name="author",
field=models.CharField(
default="Anonymous",
help_text="Let people know who posted this",
max_length=100,
),
),
]

View File

@ -7,16 +7,28 @@ from utils.models import UUIDModel, CampRelatedModel
class Ride(UUIDModel, CampRelatedModel):
camp = models.ForeignKey("camps.Camp", on_delete=models.PROTECT)
user = models.ForeignKey("auth.User", on_delete=models.PROTECT)
author = models.CharField(max_length=100, help_text="Let people know who posted this", default="Anonymous")
author = models.CharField(
max_length=100, help_text="Let people know who posted this", default="Anonymous"
)
has_car = models.BooleanField(
default=True,
help_text="Leave checked if you are offering a ride, uncheck if you need a ride."
help_text="Leave checked if you are offering a ride, uncheck if you need a ride.",
)
seats = models.PositiveIntegerField(
help_text="How many seats are you offering/how many seats do you need?"
)
from_location = models.CharField(
max_length=100, help_text="Where does this ride begin?"
)
to_location = models.CharField(
max_length=100, help_text="What is the destination of this ride?"
)
when = models.DateTimeField(
help_text="When does this ride leave? Format is YYYY-MM-DD HH:mm"
)
description = models.TextField(
help_text="Include any details you want, like luggage space/requirements, contact info and so on."
)
seats = models.PositiveIntegerField(help_text="How many seats are you offering/how many seats do you need?")
from_location = models.CharField(max_length=100, help_text="Where does this ride begin?")
to_location = models.CharField(max_length=100, help_text="What is the destination of this ride?")
when = models.DateTimeField(help_text="When does this ride leave? Format is YYYY-MM-DD HH:mm")
description = models.TextField(help_text="Include any details you want, like luggage space/requirements, contact info and so on.")
def get_absolute_url(self):
return reverse(

View File

@ -63,15 +63,21 @@ class RideDetail(LoginRequiredMixin, CampViewMixin, DetailView):
class RideCreate(LoginRequiredMixin, CampViewMixin, CreateView):
model = Ride
fields = ["author", "has_car", "from_location", "to_location", "when", "seats", "description"]
fields = [
"author",
"has_car",
"from_location",
"to_location",
"when",
"seats",
"description",
]
def get_initial(self):
"""
Default 'author' to users public_credit_name where relevant
"""
return {
"author": self.request.user.profile.get_public_credit_name
}
return {"author": self.request.user.profile.get_public_credit_name}
def form_valid(self, form, **kwargs):
"""
@ -92,7 +98,15 @@ class IsRideOwnerMixin(UserPassesTestMixin):
class RideUpdate(LoginRequiredMixin, CampViewMixin, IsRideOwnerMixin, UpdateView):
model = Ride
fields = ["author", "has_car", "from_location", "to_location", "when", "seats", "description"]
fields = [
"author",
"has_car",
"from_location",
"to_location",
"when",
"seats",
"description",
]
class RideDelete(LoginRequiredMixin, CampViewMixin, IsRideOwnerMixin, DeleteView):

View File

@ -19,7 +19,9 @@ def do_work():
"""
# check if we need to generate any proforma invoices for shop orders
for order in Order.objects.filter(Q(pdf="") | Q(pdf__isnull=True), open__isnull=True):
for order in Order.objects.filter(
Q(pdf="") | Q(pdf__isnull=True), open__isnull=True
):
# generate proforma invoice for this Order
pdffile = generate_pdf_letter(
filename=order.filename,
@ -141,4 +143,3 @@ def do_work():
"Unable to add creditnote email for creditnote %s to %s"
% (creditnote.pk, creditnote.user.email)
)

View File

@ -6,13 +6,15 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0057_order_notes'),
("shop", "0057_order_notes"),
]
operations = [
migrations.AddField(
model_name='order',
name='pdf',
field=models.FileField(blank=True, null=True, upload_to='proforma_invoices/'),
model_name="order",
name="pdf",
field=models.FileField(
blank=True, null=True, upload_to="proforma_invoices/"
),
),
]

View File

@ -6,13 +6,13 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('shop', '0058_order_pdf'),
("shop", "0058_order_pdf"),
]
operations = [
migrations.RenameField(
model_name='orderproductrelation',
old_name='handed_out',
new_name='ticket_generated',
model_name="orderproductrelation",
old_name="handed_out",
new_name="ticket_generated",
),
]

View File

@ -6,13 +6,16 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0059_auto_20190718_2051'),
("shop", "0059_auto_20190718_2051"),
]
operations = [
migrations.AddField(
model_name='productcategory',
name='weight',
field=models.IntegerField(default=100, help_text='Sorting weight. Heavier items sink to the bottom.'),
model_name="productcategory",
name="weight",
field=models.IntegerField(
default=100,
help_text="Sorting weight. Heavier items sink to the bottom.",
),
),
]

View File

@ -376,7 +376,9 @@ class ProductCategory(CreatedUpdatedModel, UUIDModel):
name = models.CharField(max_length=150)
slug = models.SlugField()
public = models.BooleanField(default=True)
weight = models.IntegerField(default=100, help_text="Sorting weight. Heavier items sink to the bottom.")
weight = models.IntegerField(
default=100, help_text="Sorting weight. Heavier items sink to the bottom."
)
def __str__(self):
return self.name

View File

@ -156,7 +156,9 @@ class ShopIndexView(ListView):
def get_queryset(self):
queryset = super(ShopIndexView, self).get_queryset()
return queryset.available().order_by("category__weight", "category__name", "price", "name")
return queryset.available().order_by(
"category__weight", "category__name", "price", "name"
)
def get_context_data(self, **kwargs):
context = super(ShopIndexView, self).get_context_data(**kwargs)

View File

@ -5,7 +5,14 @@ from .models import Sponsor, SponsorTier
@admin.register(Sponsor)
class SponsorAdmin(admin.ModelAdmin):
list_display = ("name", "tier", "ticket_email", "ticket_ready", "tickets_sent", "tickets_generated")
list_display = (
"name",
"tier",
"ticket_email",
"ticket_ready",
"tickets_sent",
"tickets_generated",
)
list_filter = ("tier__camp",)

View File

@ -7,6 +7,7 @@ from utils.email import add_outgoing_email
logger = logging.getLogger("bornhack.%s" % __name__)
def add_sponsorticket_email(ticket):
# put formatdict together
formatdict = {
@ -31,4 +32,3 @@ def add_sponsorticket_email(ticket):
attachment=f.read(),
attachment_filename=filename,
)

View File

@ -29,20 +29,25 @@ class Command(BaseCommand):
for sponsor in sponsors:
if (
sponsor.tier.tickets and
sponsor.tickets_generated and
sponsor.ticket_email and
sponsor.ticket_ready and
not sponsor.tickets_sent
sponsor.tier.tickets
and sponsor.tickets_generated
and sponsor.ticket_email
and sponsor.ticket_ready
and not sponsor.tickets_sent
):
self.output("# Generating outgoing emails to send tickets for {}:".format(sponsor))
self.output(
"# Generating outgoing emails to send tickets for {}:".format(
sponsor
)
)
for ticket in sponsor.sponsorticket_set.all():
# send the email
if add_sponsorticket_email(ticket=ticket):
logger.info("OK: email to %s added" % sponsor)
else:
logger.error("Unable to send sponsor ticket email to %s" % sponsor)
logger.error(
"Unable to send sponsor ticket email to %s" % sponsor
)
sponsor.tickets_sent = True
sponsor.save()

View File

@ -6,23 +6,34 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sponsors', '0011_auto_20181118_1513'),
("sponsors", "0011_auto_20181118_1513"),
]
operations = [
migrations.AddField(
model_name='sponsor',
name='ticket_email',
field=models.EmailField(blank=True, help_text='The email to send the tickets to', max_length=254, null=True),
model_name="sponsor",
name="ticket_email",
field=models.EmailField(
blank=True,
help_text="The email to send the tickets to",
max_length=254,
null=True,
),
),
migrations.AddField(
model_name='sponsor',
name='ticket_ready',
field=models.BooleanField(default=False, help_text='Check when we are ready to send tickets to this sponsor.'),
model_name="sponsor",
name="ticket_ready",
field=models.BooleanField(
default=False,
help_text="Check when we are ready to send tickets to this sponsor.",
),
),
migrations.AddField(
model_name='sponsor',
name='tickets_sent',
field=models.BooleanField(default=False, help_text='True when the tickets have been emailed to the sponsor'),
model_name="sponsor",
name="tickets_sent",
field=models.BooleanField(
default=False,
help_text="True when the tickets have been emailed to the sponsor",
),
),
]

View File

@ -23,11 +23,19 @@ class Sponsor(CampRelatedModel):
tickets_generated = models.BooleanField(default=False)
ticket_email = models.EmailField(null=True, blank=True, help_text="The email to send the tickets to")
ticket_email = models.EmailField(
null=True, blank=True, help_text="The email to send the tickets to"
)
ticket_ready = models.BooleanField(default=False, help_text="Check when we are ready to send tickets to this sponsor.")
ticket_ready = models.BooleanField(
default=False,
help_text="Check when we are ready to send tickets to this sponsor.",
)
tickets_sent = models.BooleanField(default=False, help_text="True when the tickets have been emailed to the sponsor")
tickets_sent = models.BooleanField(
default=False,
help_text="True when the tickets have been emailed to the sponsor",
)
def __str__(self):
return "{} ({})".format(self.name, self.tier.camp)

View File

@ -7,7 +7,7 @@ from .models import TicketType, SponsorTicket, DiscountTicket, ShopTicket
class BaseTicketAdmin(admin.ModelAdmin):
actions = ["generate_pdf"]
exclude = ["qrcode_base64"]
readonly_fields = ['token', 'badge_token']
readonly_fields = ["token", "badge_token"]
def generate_pdf(self, request, queryset):
for ticket in queryset.all():

View File

@ -6,23 +6,23 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0005_auto_20180318_0906'),
("tickets", "0005_auto_20180318_0906"),
]
operations = [
migrations.AddField(
model_name='discountticket',
name='token',
model_name="discountticket",
name="token",
field=models.CharField(max_length=64, null=True),
),
migrations.AddField(
model_name='shopticket',
name='token',
model_name="shopticket",
name="token",
field=models.CharField(max_length=64, null=True),
),
migrations.AddField(
model_name='sponsorticket',
name='token',
model_name="sponsorticket",
name="token",
field=models.CharField(max_length=64, null=True),
),
]

View File

@ -6,38 +6,32 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0007_save_token_to_db'),
("tickets", "0007_save_token_to_db"),
]
operations = [
migrations.RenameField(
model_name='discountticket',
old_name='checked_in',
new_name='used',
model_name="discountticket", old_name="checked_in", new_name="used",
),
migrations.RenameField(
model_name='shopticket',
old_name='checked_in',
new_name='used',
model_name="shopticket", old_name="checked_in", new_name="used",
),
migrations.RenameField(
model_name='sponsorticket',
old_name='checked_in',
new_name='used',
model_name="sponsorticket", old_name="checked_in", new_name="used",
),
migrations.AlterField(
model_name='discountticket',
name='token',
model_name="discountticket",
name="token",
field=models.CharField(max_length=64),
),
migrations.AlterField(
model_name='shopticket',
name='token',
model_name="shopticket",
name="token",
field=models.CharField(max_length=64),
),
migrations.AlterField(
model_name='sponsorticket',
name='token',
model_name="sponsorticket",
name="token",
field=models.CharField(max_length=64),
),
]

View File

@ -6,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0008_auto_20190718_2055'),
("tickets", "0008_auto_20190718_2055"),
]
operations = [
migrations.AddField(
model_name='tickettype',
name='includes_badge',
model_name="tickettype",
name="includes_badge",
field=models.BooleanField(default=False),
),
]

View File

@ -6,23 +6,23 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0009_tickettype_includes_badge'),
("tickets", "0009_tickettype_includes_badge"),
]
operations = [
migrations.AddField(
model_name='discountticket',
name='badge_token',
model_name="discountticket",
name="badge_token",
field=models.CharField(max_length=64, null=True),
),
migrations.AddField(
model_name='shopticket',
name='badge_token',
model_name="shopticket",
name="badge_token",
field=models.CharField(max_length=64, null=True),
),
migrations.AddField(
model_name='sponsorticket',
name='badge_token',
model_name="sponsorticket",
name="badge_token",
field=models.CharField(max_length=64, null=True),
),
]

View File

@ -6,23 +6,23 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0011_save_badge_token_to_db'),
("tickets", "0011_save_badge_token_to_db"),
]
operations = [
migrations.AlterField(
model_name='discountticket',
name='badge_token',
model_name="discountticket",
name="badge_token",
field=models.CharField(max_length=64),
),
migrations.AlterField(
model_name='shopticket',
name='badge_token',
model_name="shopticket",
name="badge_token",
field=models.CharField(max_length=64),
),
migrations.AlterField(
model_name='sponsorticket',
name='badge_token',
model_name="sponsorticket",
name="badge_token",
field=models.CharField(max_length=64),
),
]

View File

@ -6,13 +6,16 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0012_auto_20190724_2037'),
("tickets", "0012_auto_20190724_2037"),
]
operations = [
migrations.AddField(
model_name='tickettype',
name='single_ticket_per_product',
field=models.BooleanField(default=False, help_text='Only create one ticket for a product/order pair no matter the quantity. Useful for products which are bought in larger quantity (ie. village chairs)'),
model_name="tickettype",
name="single_ticket_per_product",
field=models.BooleanField(
default=False,
help_text="Only create one ticket for a product/order pair no matter the quantity. Useful for products which are bought in larger quantity (ie. village chairs)",
),
),
]

View File

@ -6,38 +6,38 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0013_tickettype_single_ticket_per_product'),
("tickets", "0013_tickettype_single_ticket_per_product"),
]
operations = [
migrations.AlterField(
model_name='discountticket',
name='badge_token',
model_name="discountticket",
name="badge_token",
field=models.CharField(blank=True, max_length=64),
),
migrations.AlterField(
model_name='discountticket',
name='token',
model_name="discountticket",
name="token",
field=models.CharField(blank=True, max_length=64),
),
migrations.AlterField(
model_name='shopticket',
name='badge_token',
model_name="shopticket",
name="badge_token",
field=models.CharField(blank=True, max_length=64),
),
migrations.AlterField(
model_name='shopticket',
name='token',
model_name="shopticket",
name="token",
field=models.CharField(blank=True, max_length=64),
),
migrations.AlterField(
model_name='sponsorticket',
name='badge_token',
model_name="sponsorticket",
name="badge_token",
field=models.CharField(blank=True, max_length=64),
),
migrations.AlterField(
model_name='sponsorticket',
name='token',
model_name="sponsorticket",
name="token",
field=models.CharField(blank=True, max_length=64),
),
]

View File

@ -56,13 +56,12 @@ class BaseTicket(CampRelatedModel, UUIDModel):
class Meta:
abstract = True
camp_filter = 'ticket_type__camp'
camp_filter = "ticket_type__camp"
@property
def camp(self):
return self.ticket_type.camp
def save(self, **kwargs):
self.token = self._get_token()
self.badge_token = self._get_badge_token()

View File

@ -6,20 +6,15 @@ from .models import ShopTicket
class TicketTests(TestCase):
def test_correct_token_and_badge_token_are_different(self):
ticket_type = TicketTypeFactory()
orp = OrderProductRelationFactory()
shop_ticket = ShopTicket.objects.create(
ticket_type=ticket_type,
product=orp.product,
order=orp.order,
ticket_type=ticket_type, product=orp.product, order=orp.order,
)
self.assertNotEqual(shop_ticket.token, shop_ticket.badge_token)
self.assertEqual(shop_ticket.token, shop_ticket._get_token())
self.assertEqual(shop_ticket.badge_token, shop_ticket._get_badge_token())

View File

@ -6,4 +6,4 @@ from .models import OutgoingEmail
@admin.register(OutgoingEmail)
class OutgoingEmailAdmin(admin.ModelAdmin):
model = OutgoingEmail
list_display = ['subject', 'to_recipients']
list_display = ["subject", "to_recipients"]