Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
didrikmunther committed Aug 4, 2024
1 parent 65f482b commit 2fce40c
Show file tree
Hide file tree
Showing 27 changed files with 348 additions and 202 deletions.
20 changes: 16 additions & 4 deletions accounting/migrations/0034_change_exclusive_for_choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,25 @@
class Migration(migrations.Migration):

dependencies = [
('accounting', '0033_add_stock_model'),
("accounting", "0033_add_stock_model"),
]

operations = [
migrations.AlterField(
model_name='product',
name='exclusively_for',
field=accounting.models.ChoiceArrayField(base_field=models.CharField(choices=[('ir-timely', 'Companies who signed IR during the IR period.'), ('ir-late', 'Companies who signed IR after the IR period.')], max_length=31), blank=True, default=list, help_text='Show this product only to the selected company types. An empty selection means showing it to every company.', size=None),
model_name="product",
name="exclusively_for",
field=accounting.models.ChoiceArrayField(
base_field=models.CharField(
choices=[
("ir-timely", "Companies who signed IR during the IR period."),
("ir-late", "Companies who signed IR after the IR period."),
],
max_length=31,
),
blank=True,
default=list,
help_text="Show this product only to the selected company types. An empty selection means showing it to every company.",
size=None,
),
),
]
34 changes: 26 additions & 8 deletions accounting/migrations/0035_add_specific_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,39 @@
class Migration(migrations.Migration):

dependencies = [
('accounting', '0034_change_exclusive_for_choices'),
("accounting", "0034_change_exclusive_for_choices"),
]

operations = [
migrations.CreateModel(
name='SpecificProduct',
name="SpecificProduct",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('unit_price', models.IntegerField()),
('specific_product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounting.Product')),
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("unit_price", models.IntegerField()),
(
"specific_product",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="accounting.Product",
),
),
],
),
migrations.AddField(
model_name='product',
name='specific_products',
field=models.ManyToManyField(blank=True, help_text='(ONLY RELEVANT FOR PACKAGES AS ROOT PRODUCTS) These products will only be shown to the customer if they select the current package This feature was used in 2024 when silver and bronze packages lead to different prices on the same products', to='accounting.SpecificProduct'),
model_name="product",
name="specific_products",
field=models.ManyToManyField(
blank=True,
help_text="(ONLY RELEVANT FOR PACKAGES AS ROOT PRODUCTS) These products will only be shown to the customer if they select the current package This feature was used in 2024 when silver and bronze packages lead to different prices on the same products",
to="accounting.SpecificProduct",
),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
class Migration(migrations.Migration):

dependencies = [
('accounting', '0035_add_specific_products'),
("accounting", "0035_add_specific_products"),
]

operations = [
migrations.AddField(
model_name='specificproduct',
name='description',
model_name="specificproduct",
name="description",
field=models.TextField(blank=True, null=True),
),
]
22 changes: 15 additions & 7 deletions accounting/migrations/0037_add_product_help_texts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@
class Migration(migrations.Migration):

dependencies = [
('accounting', '0036_add_specific_product_description'),
("accounting", "0036_add_specific_product_description"),
]

operations = [
migrations.AlterField(
model_name='childproduct',
name='description',
field=models.TextField(blank=True, help_text='Optional, describe why you created this child product. This will not be shown to the customer.', null=True),
model_name="childproduct",
name="description",
field=models.TextField(
blank=True,
help_text="Optional, describe why you created this child product. This will not be shown to the customer.",
null=True,
),
),
migrations.AlterField(
model_name='specificproduct',
name='description',
field=models.TextField(blank=True, help_text='Optional, describe why you created this specific product. This will not be shown to the customer.', null=True),
model_name="specificproduct",
name="description",
field=models.TextField(
blank=True,
help_text="Optional, describe why you created this specific product. This will not be shown to the customer.",
null=True,
),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@
class Migration(migrations.Migration):

dependencies = [
('accounting', '0037_add_product_help_texts'),
("accounting", "0037_add_product_help_texts"),
]

operations = [
migrations.AddField(
model_name='product',
name='display_only_when_specific_for_packages',
field=models.BooleanField(default=False, help_text="This product will only be shown to the customer if they select a package that has this product as a specific product. When to use this: e.g. A package is gatekeeping this product, only show the product when the package is selected. When not to use this: e.g. This product's price is only affected by one or more packages, but the product is still available for purchase without the package."),
model_name="product",
name="display_only_when_specific_for_packages",
field=models.BooleanField(
default=False,
help_text="This product will only be shown to the customer if they select a package that has this product as a specific product. When to use this: e.g. A package is gatekeeping this product, only show the product when the package is selected. When not to use this: e.g. This product's price is only affected by one or more packages, but the product is still available for purchase without the package.",
),
),
migrations.AlterField(
model_name='product',
name='specific_products',
field=models.ManyToManyField(blank=True, help_text='(ONLY RELEVANT FOR PACKAGES AS ROOT PRODUCTS) These products will only be shown to the customer if they select the current package This feature was used in 2024 when silver and bronze packages lead to different prices on the same products Neccessary is to toggle the "Display in product list" to false on for the specific product (otherwise it will be displayed with standard price).', to='accounting.SpecificProduct'),
model_name="product",
name="specific_products",
field=models.ManyToManyField(
blank=True,
help_text='(ONLY RELEVANT FOR PACKAGES AS ROOT PRODUCTS) These products will only be shown to the customer if they select the current package This feature was used in 2024 when silver and bronze packages lead to different prices on the same products Neccessary is to toggle the "Display in product list" to false on for the specific product (otherwise it will be displayed with standard price).',
to="accounting.SpecificProduct",
),
),
]
6 changes: 3 additions & 3 deletions accounting/migrations/0039_remove_display_specific_boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
class Migration(migrations.Migration):

dependencies = [
('accounting', '0038_add_display_only_when_specific_for_packages'),
("accounting", "0038_add_display_only_when_specific_for_packages"),
]

operations = [
migrations.RemoveField(
model_name='product',
name='display_only_when_specific_for_packages',
model_name="product",
name="display_only_when_specific_for_packages",
),
]
20 changes: 12 additions & 8 deletions accounting/migrations/0040_something.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@
class Migration(migrations.Migration):

dependencies = [
('accounting', '0039_remove_display_specific_boolean'),
("accounting", "0039_remove_display_specific_boolean"),
]

operations = [
migrations.RemoveField(
model_name='specificproduct',
name='description',
model_name="specificproduct",
name="description",
),
migrations.RemoveField(
model_name='specificproduct',
name='unit_price',
model_name="specificproduct",
name="unit_price",
),
migrations.AlterField(
model_name='product',
name='specific_products',
field=models.ManyToManyField(blank=True, help_text='(ONLY RELEVANT FOR PACKAGES AS ROOT PRODUCTS) These products will only be shown to the customer if they select the current package This feature was used in 2024 when silver and bronze packages lead to different prices on the same products Neccessary is to set the "Display in product list" to false on for the specific product (otherwise it will be displayed with standard price, for any package).', to='accounting.SpecificProduct'),
model_name="product",
name="specific_products",
field=models.ManyToManyField(
blank=True,
help_text='(ONLY RELEVANT FOR PACKAGES AS ROOT PRODUCTS) These products will only be shown to the customer if they select the current package This feature was used in 2024 when silver and bronze packages lead to different prices on the same products Neccessary is to set the "Display in product list" to false on for the specific product (otherwise it will be displayed with standard price, for any package).',
to="accounting.SpecificProduct",
),
),
]
8 changes: 5 additions & 3 deletions accounting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,11 @@ def export_companys(request, year):
e.company.invoice_email_address,
e.company.ths_customer_id,
e.company.invoice_reference,
company_order_total.get(e.company.pk)
if company_order_total.get(e.company.pk)
else None,
(
company_order_total.get(e.company.pk)
if company_order_total.get(e.company.pk)
else None
),
]
)

Expand Down
24 changes: 15 additions & 9 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@ def exhibitor(request, exhibitor, company):
("purpose", exhibitor.catalogue_purpose),
(
"logo_squared",
(exhibitor.catalogue_logo_squared.url)
if exhibitor.catalogue_logo_squared
else (MISSING_IMAGE if img_placeholder else None),
(
(exhibitor.catalogue_logo_squared.url)
if exhibitor.catalogue_logo_squared
else (MISSING_IMAGE if img_placeholder else None)
),
),
(
"logo_freesize",
(exhibitor.catalogue_logo_freesize.url)
if exhibitor.catalogue_logo_freesize
else (MISSING_IMAGE if img_placeholder else None),
(
(exhibitor.catalogue_logo_freesize.url)
if exhibitor.catalogue_logo_freesize
else (MISSING_IMAGE if img_placeholder else None)
),
),
("contact_name", exhibitor.catalogue_contact_name),
("contact_email_address", exhibitor.catalogue_contact_email_address),
Expand Down Expand Up @@ -115,9 +119,11 @@ def exhibitor(request, exhibitor, company):
),
(
"cities",
exhibitor.catalogue_cities
if exhibitor.catalogue_cities is not None
else "",
(
exhibitor.catalogue_cities
if exhibitor.catalogue_cities is not None
else ""
),
),
(
"benefits",
Expand Down
6 changes: 3 additions & 3 deletions banquet/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ def ticket(participant):
"id": participant.pk,
"seat": participant.seat.name if participant.seat else "",
"table": participant.seat.table.name if participant.seat else "",
"name": participant.user.get_full_name()
if participant.user
else participant.name,
"name": (
participant.user.get_full_name() if participant.user else participant.name
),
"ticket_scanned": participant.ticket_scanned,
}

Expand Down
62 changes: 35 additions & 27 deletions banquet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,11 @@ def manage_invitations(request, year, banquet_pk):
"pk": invitation.pk,
"group": invitation.group,
"user": invitation.user,
"name": invitation.user.get_full_name()
if invitation.user is not None
else invitation.name,
"name": (
invitation.user.get_full_name()
if invitation.user is not None
else invitation.name
),
"reason": invitation.reason,
"status": invitation.status,
"price": invitation.price,
Expand Down Expand Up @@ -843,9 +845,7 @@ def manage_invitation_form(request, year, banquet_pk, invitation_pk=None):

if invitation is not None and invitation.participant is not None:
form.fields["price"].disabled = True
form.fields[
"price"
].help_text = (
form.fields["price"].help_text = (
"The price cannot be changed as the invitation has already been accepted."
)

Expand Down Expand Up @@ -919,12 +919,16 @@ def manage_participant(request, year, banquet_pk, participant_pk):
"banquet": banquet,
"participant": {
"pk": participant.pk,
"name": participant.user.get_full_name()
if participant.user
else participant.name,
"email_address": participant.user.email
if participant.user
else participant.email_address,
"name": (
participant.user.get_full_name()
if participant.user
else participant.name
),
"email_address": (
participant.user.email
if participant.user
else participant.email_address
),
"phone_number": participant.phone_number,
"dietary_restrictions": participant.dietary_restrictions,
"other_dietary_restrictions": participant.other_dietary_restrictions,
Expand All @@ -948,12 +952,16 @@ def manage_participants(request, year, banquet_pk):
"pk": participant.pk,
"company": participant.company,
"user": participant.user,
"name": participant.user.get_full_name()
if participant.user
else participant.name,
"email_address": participant.user.email
if participant.user
else participant.email_address,
"name": (
participant.user.get_full_name()
if participant.user
else participant.name
),
"email_address": (
participant.user.email
if participant.user
else participant.email_address
),
"alcohol": participant.alcohol,
"seat": participant.seat,
"invitation": participant.invitation_set.first(),
Expand Down Expand Up @@ -1091,9 +1099,9 @@ def invitation(request, year, token):
if invitation.banquet.caption_phone_number is not None:
form.fields["phone_number"].help_text = invitation.banquet.caption_phone_number
if invitation.banquet.caption_dietary_restrictions is not None:
form.fields[
"dietary_restrictions"
].help_text = invitation.banquet.caption_dietary_restrictions
form.fields["dietary_restrictions"].help_text = (
invitation.banquet.caption_dietary_restrictions
)

can_edit = (
invitation.deadline_smart is None
Expand Down Expand Up @@ -1297,9 +1305,9 @@ def external_invitation(request, token):
if invitation.banquet.caption_phone_number is not None:
form.fields["phone_number"].help_text = invitation.banquet.caption_phone_number
if invitation.banquet.caption_dietary_restrictions is not None:
form.fields[
"dietary_restrictions"
].help_text = invitation.banquet.caption_dietary_restrictions
form.fields["dietary_restrictions"].help_text = (
invitation.banquet.caption_dietary_restrictions
)

can_edit = (
invitation.deadline_smart is None
Expand Down Expand Up @@ -1638,9 +1646,9 @@ def export_afterparty(request, year, banquet_pk):
banquet = get_object_or_404(Banquet, pk=banquet_pk)

response = HttpResponse(content_type="text/csv")
response[
"Content-Disposition"
] = 'attachment; filename="afterparty_participants.csv"'
response["Content-Disposition"] = (
'attachment; filename="afterparty_participants.csv"'
)

writer = csv.writer(response, delimiter=",", quoting=csv.QUOTE_ALL)
writer.writerow(["Name", "Email Sent", "Email", "Inviter"])
Expand Down
Loading

0 comments on commit 2fce40c

Please sign in to comment.