From a6289bdd3038168cfbb92a81d8558f7107e1aeab Mon Sep 17 00:00:00 2001 From: Didrik Munther Date: Wed, 31 Jul 2024 18:18:48 +0200 Subject: [PATCH 1/4] Update pnpm version in react lint job --- .github/workflows/react_lint_and_format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react_lint_and_format.yml b/.github/workflows/react_lint_and_format.yml index 7e1a4c92..efae043e 100644 --- a/.github/workflows/react_lint_and_format.yml +++ b/.github/workflows/react_lint_and_format.yml @@ -19,7 +19,7 @@ jobs: node-version: "20.12" - name: Install pnpm - run: npm install -g pnpm@8.15 + run: npm install -g pnpm@9.6.0 - name: Install dependencies run: cd apps/dashboard && pnpm install From 46977a8a8aab49943acc18677cefbb39e011ea7b Mon Sep 17 00:00:00 2001 From: Didrik Munther Date: Wed, 31 Jul 2024 18:23:17 +0200 Subject: [PATCH 2/4] Update black version --- .github/workflows/pr-style.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-style.yml b/.github/workflows/pr-style.yml index 73cb48a8..9e30102a 100644 --- a/.github/workflows/pr-style.yml +++ b/.github/workflows/pr-style.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: psf/black@23.3.0 + - uses: psf/black@3.12.4 with: options: "--check" src: "." From c42b4e77fcc418ec9a79a68b3cd0b57847888e1e Mon Sep 17 00:00:00 2001 From: Didrik Munther Date: Wed, 31 Jul 2024 18:23:56 +0200 Subject: [PATCH 3/4] Update black version --- .github/workflows/pr-style.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-style.yml b/.github/workflows/pr-style.yml index 9e30102a..33eee2d7 100644 --- a/.github/workflows/pr-style.yml +++ b/.github/workflows/pr-style.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: psf/black@3.12.4 + - uses: psf/black@24.4.2 with: options: "--check" src: "." From 2017068265309e278fccc1d27de288750eee9510 Mon Sep 17 00:00:00 2001 From: Didrik Munther Date: Wed, 31 Jul 2024 18:26:08 +0200 Subject: [PATCH 4/4] Reformat files --- accounting/views.py | 8 +- api/serializers.py | 24 +++--- banquet/serializers.py | 6 +- banquet/views.py | 62 ++++++++------- .../commands/importregistrations.py | 12 +-- events/serializers.py | 6 +- exhibitors/api.py | 78 +++++++++++-------- .../management/commands/generate_bills.py | 1 - exhibitors/serializers.py | 22 +++--- exhibitors/views.py | 16 ++-- fair/serializers.py | 44 ++++++----- fair/views.py | 18 +++-- matching/forms.py | 6 +- orders/forms.py | 18 ++--- recruitment/views.py | 18 ++--- register/forms.py | 2 +- 16 files changed, 197 insertions(+), 144 deletions(-) diff --git a/accounting/views.py b/accounting/views.py index 5ce2e226..7120e134 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -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 + ), ] ) diff --git a/api/serializers.py b/api/serializers.py index dc7ff4e3..e6dfe22a 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -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), @@ -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", diff --git a/banquet/serializers.py b/banquet/serializers.py index b2a1837a..05f74aba 100644 --- a/banquet/serializers.py +++ b/banquet/serializers.py @@ -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, } diff --git a/banquet/views.py b/banquet/views.py index 4e206dab..8ae62e15 100644 --- a/banquet/views.py +++ b/banquet/views.py @@ -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, @@ -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." ) @@ -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, @@ -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(), @@ -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 @@ -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 @@ -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"]) diff --git a/companies/management/commands/importregistrations.py b/companies/management/commands/importregistrations.py index d01b42bd..08f3977a 100644 --- a/companies/management/commands/importregistrations.py +++ b/companies/management/commands/importregistrations.py @@ -133,11 +133,13 @@ def to_int_or_default(value, default_value): "will_you_send_goods_to_ths_armadas_goods_reception_before_the_fair" ], ), - transport_from_fair_type="armada_transport" - if row["we_would_like_to_use_armada_transport"] == "Yes" - else tuple_value_matching_name( - Exhibitor.transport_from_fair_types, - row["if_no_please_select_one_from_fair"], + transport_from_fair_type=( + "armada_transport" + if row["we_would_like_to_use_armada_transport"] == "Yes" + else tuple_value_matching_name( + Exhibitor.transport_from_fair_types, + row["if_no_please_select_one_from_fair"], + ) ), number_of_packages_from_fair=to_int_or_default( row["number_of_packages_from_fair"], 0 diff --git a/events/serializers.py b/events/serializers.py index 08ab5dd8..778846d9 100644 --- a/events/serializers.py +++ b/events/serializers.py @@ -19,9 +19,9 @@ def event(event, request): "event_end": int(event.date_end.strftime("%s")), "event_start_string": event.date_start.strftime("%Y-%m-%d %H:%M"), "registration_end": int(event.date_start.strftime("%s")), - "image_url": request.build_absolute_uri(event.picture.url) - if event.picture - else None, + "image_url": ( + request.build_absolute_uri(event.picture.url) if event.picture else None + ), "fee": event.fee_s, "registration_required": True, "external_event_link": event.external_event_link, diff --git a/exhibitors/api.py b/exhibitors/api.py index 1f9814e2..04d59536 100644 --- a/exhibitors/api.py +++ b/exhibitors/api.py @@ -20,12 +20,14 @@ def serialize_booths(exhibitor): { "id": eib.booth.pk, "location": { - "parent": { - "id": eib.booth.location.parent.pk, - "name": eib.booth.location.parent.name, - } - if eib.booth.location.parent - else None, + "parent": ( + { + "id": eib.booth.location.parent.pk, + "name": eib.booth.location.parent.name, + } + if eib.booth.location.parent + else None + ), "id": eib.booth.location.pk, "name": eib.booth.location.name, }, @@ -51,15 +53,19 @@ def serialize_exhibitor(exhibitor, request): ("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) + ), ), ( "industries", @@ -98,9 +104,11 @@ def serialize_exhibitor(exhibitor, request): ), ( "cities", - exhibitor.catalogue_cities - if exhibitor.catalogue_cities is not None - else "", + ( + exhibitor.catalogue_cities + if exhibitor.catalogue_cities is not None + else "" + ), ), ( "benefits", @@ -130,9 +138,11 @@ def serialize_exhibitor(exhibitor, request): ), ( "location_special", - str(exhibitor.fair_location_special) - if exhibitor.fair_location_special - else "", + ( + str(exhibitor.fair_location_special) + if exhibitor.fair_location_special + else "" + ), ), ("climate_compensation", exhibitor.climate_compensation), ("flyer", (exhibitor.flyer.url) if exhibitor.flyer else ""), @@ -181,9 +191,11 @@ def locations(request): data.append( { "id": location.pk, - "parent": {"id": location.parent.pk, "name": location.parent.name} - if location.parent - else None, + "parent": ( + {"id": location.parent.pk, "name": location.parent.name} + if location.parent + else None + ), "name": location.name, "has_map": bool(location.background), } @@ -223,17 +235,21 @@ def location(request, location_pk): data = { "id": location.pk, - "parent": {"id": location.parent.pk, "name": location.parent.name} - if location.parent - else None, + "parent": ( + {"id": location.parent.pk, "name": location.parent.name} + if location.parent + else None + ), "name": location.name, - "map": { - "url": location.background.url, - "width": location.background.width, - "height": location.background.height, - } - if location.background - else None, + "map": ( + { + "url": location.background.url, + "width": location.background.width, + "height": location.background.height, + } + if location.background + else None + ), "booths": booths, } diff --git a/exhibitors/management/commands/generate_bills.py b/exhibitors/management/commands/generate_bills.py index 5f3b0909..70091993 100644 --- a/exhibitors/management/commands/generate_bills.py +++ b/exhibitors/management/commands/generate_bills.py @@ -9,7 +9,6 @@ to list options """ - # Constants, that might change in the future? # Taken from the example php, you can probably change this if you know what you're doing static = { diff --git a/exhibitors/serializers.py b/exhibitors/serializers.py index 6fbb1330..653800d8 100644 --- a/exhibitors/serializers.py +++ b/exhibitors/serializers.py @@ -11,12 +11,16 @@ def exhibitor(request, exhibitor, company): "company_website": company.website, "about": exhibitor.catalogue_about, "purpose": exhibitor.catalogue_purpose, - "logo_squared": 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), + "logo_squared": ( + 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) + ), "contact_name": exhibitor.catalogue_contact_name, "contact_email_address": exhibitor.catalogue_contact_email_address, "contact_phone_number": exhibitor.catalogue_contact_phone_number, @@ -40,9 +44,9 @@ def exhibitor(request, exhibitor, company): {"id": competence.pk, "name": competence.competence} for competence in exhibitor.catalogue_competences.all() ], - "cities": exhibitor.catalogue_cities - if exhibitor.catalogue_cities is not None - else "", + "cities": ( + exhibitor.catalogue_cities if exhibitor.catalogue_cities is not None else "" + ), "benefits": [ {"id": benefit.pk, "name": benefit.benefit} for benefit in exhibitor.catalogue_benefits.all() diff --git a/exhibitors/views.py b/exhibitors/views.py index ff5e1de4..b8f2b0f8 100644 --- a/exhibitors/views.py +++ b/exhibitors/views.py @@ -372,9 +372,11 @@ def exhibitor(request, year, pk): { "name": order.name if order.name is not None else order.product.name, "comment": order.comment, - "unit_price": order.unit_price - if order.unit_price is not None - else order.product.unit_price, + "unit_price": ( + order.unit_price + if order.unit_price is not None + else order.product.unit_price + ), "quantity": order.quantity, } ) @@ -424,9 +426,11 @@ def exhibitor(request, year, pk): contact_persons.append( { "user": user, - "role": application.delegated_role - if application is not None - else None, + "role": ( + application.delegated_role + if application is not None + else None + ), } ) diff --git a/fair/serializers.py b/fair/serializers.py index b5171c14..035c5e42 100644 --- a/fair/serializers.py +++ b/fair/serializers.py @@ -4,16 +4,20 @@ def lunch_ticket(lunch_ticket): data = { "id": lunch_ticket.pk, - "name": lunch_ticket.user.get_full_name() - if lunch_ticket.user - else lunch_ticket.company.name, - "email_address": lunch_ticket.user.email - if lunch_ticket.user - else lunch_ticket.email_address, + "name": ( + lunch_ticket.user.get_full_name() + if lunch_ticket.user + else lunch_ticket.company.name + ), + "email_address": ( + lunch_ticket.user.email if lunch_ticket.user else lunch_ticket.email_address + ), "comment": lunch_ticket.comment, - "date": lunch_ticket.time.__str__() - if lunch_ticket.time - else lunch_ticket.day.__str__(), + "date": ( + lunch_ticket.time.__str__() + if lunch_ticket.time + else lunch_ticket.day.__str__() + ), "used": lunch_ticket.used, "type": lunch_ticket.get_ticket_type(), "token": lunch_ticket.token, @@ -30,17 +34,21 @@ def lunch_ticket(lunch_ticket): def lunch_ticket_react(request, lunch_ticket): data = { "id": lunch_ticket.pk, - "name": lunch_ticket.user.get_full_name() - if lunch_ticket.user - else lunch_ticket.company.name, - "email_address": lunch_ticket.user.email - if lunch_ticket.user - else lunch_ticket.email_address, + "name": ( + lunch_ticket.user.get_full_name() + if lunch_ticket.user + else lunch_ticket.company.name + ), + "email_address": ( + lunch_ticket.user.email if lunch_ticket.user else lunch_ticket.email_address + ), "comment": lunch_ticket.comment, "day": lunch_ticket.day.__str__(), - "time": lunch_ticket.time.__str__().split(" ")[1] - if len(lunch_ticket.time.__str__().split(" ")) > 1 - else lunch_ticket.time.__str__(), + "time": ( + lunch_ticket.time.__str__().split(" ")[1] + if len(lunch_ticket.time.__str__().split(" ")) > 1 + else lunch_ticket.time.__str__() + ), "used": lunch_ticket.used, "type": lunch_ticket.get_ticket_type(), "token": lunch_ticket.token, diff --git a/fair/views.py b/fair/views.py index d1f2c0f5..6a3eb375 100644 --- a/fair/views.py +++ b/fair/views.py @@ -164,10 +164,12 @@ def lunchtickets(request, year): for lunchticket in lunchtickets_filtered: lunchticket["drl"] = [ - True - if dietary_restriction - in lunchticket["t"].dietary_restrictions.all() - else False + ( + True + if dietary_restriction + in lunchticket["t"].dietary_restrictions.all() + else False + ) for dietary_restriction in dietary_restrictions_all ] @@ -339,9 +341,11 @@ def tickets(request, year): serializers.lunch_ticket(lunch_ticket=lunch_ticket) for lunch_ticket in lunch_tickets ], - "banquet_participant": serializers.banquet_participant(banquet_participant) - if banquet_participant - else None, + "banquet_participant": ( + serializers.banquet_participant(banquet_participant) + if banquet_participant + else None + ), } return render( diff --git a/matching/forms.py b/matching/forms.py index 4e8d22da..4cc333e8 100644 --- a/matching/forms.py +++ b/matching/forms.py @@ -67,9 +67,9 @@ def add_question(self, question, data): if widget: kwargs["widget"] = widget field = self.get_question_field(question, **kwargs) - self.fields[ - "question_%d" % question.pk - ] = field ## VERY IMPORTANT TO KEEP question_%d here. Other code is dependant on it + self.fields["question_%d" % question.pk] = ( + field ## VERY IMPORTANT TO KEEP question_%d here. Other code is dependant on it + ) def get_question_initial(self, question, data): """Get the initial value that we should use in the Form diff --git a/orders/forms.py b/orders/forms.py index e4c4d828..85e64343 100644 --- a/orders/forms.py +++ b/orders/forms.py @@ -14,9 +14,9 @@ def __init__(self, exhibitor, *args, **kwargs): super(ElectricityOrderForm, self).__init__(*args, **kwargs) if instance == None: self.fields["exhibitor"].initial = exhibitor.pk - self.fields[ - "exhibitor" - ].disabled = True # make sure exhibitor field is not editable + self.fields["exhibitor"].disabled = ( + True # make sure exhibitor field is not editable + ) self.fields["exhibitor"].widget = HiddenInput() @@ -31,12 +31,12 @@ def __init__(self, exhibitor, *args, **kwargs): if instance == None: self.fields["exhibitor"].initial = exhibitor.pk self.fields["amount"].initial = 1 - self.fields[ - "exhibitor" - ].disabled = True # make sure exhibitor field is not editable - self.fields[ - "amount" - ].disabled = True # make sure exhibitor field is not editable + self.fields["exhibitor"].disabled = ( + True # make sure exhibitor field is not editable + ) + self.fields["amount"].disabled = ( + True # make sure exhibitor field is not editable + ) self.fields["exhibitor"].widget = HiddenInput() self.fields["amount"].widget = HiddenInput() diff --git a/recruitment/views.py b/recruitment/views.py index 863d2fd4..9eeb42f0 100644 --- a/recruitment/views.py +++ b/recruitment/views.py @@ -1196,9 +1196,9 @@ def recruitment_application_interview( interview_planning_form = InterviewPlanningForm( request.POST or None, instance=application ) - interview_planning_form.fields[ - "recommended_role" - ].queryset = application.recruitment_period.recruitable_roles + interview_planning_form.fields["recommended_role"].queryset = ( + application.recruitment_period.recruitable_roles + ) used_slots = [] @@ -1282,9 +1282,9 @@ def recruitment_application_interview( if "interviewer" in interview_planning_form.fields: interview_planning_form.fields["interviewer"].choices = interviewers_by_language if "interviewer2" in interview_planning_form.fields: - interview_planning_form.fields[ - "interviewer2" - ].choices = interviewers_by_language + interview_planning_form.fields["interviewer2"].choices = ( + interviewers_by_language + ) RoleDelegationForm = modelform_factory( RecruitmentApplication, fields=["delegated_role", "superior_user", "status"] @@ -1293,9 +1293,9 @@ def recruitment_application_interview( role_delegation_form = RoleDelegationForm( request.POST or None, instance=application ) - role_delegation_form.fields[ - "delegated_role" - ].queryset = application.recruitment_period.recruitable_roles + role_delegation_form.fields["delegated_role"].queryset = ( + application.recruitment_period.recruitable_roles + ) role_delegation_form.fields["superior_user"].choices = [("", "---------")] + [ (interviewer.pk, interviewer.get_full_name()) for interviewer in interviewers ] diff --git a/register/forms.py b/register/forms.py index 5acff66a..35ca8e6c 100644 --- a/register/forms.py +++ b/register/forms.py @@ -344,7 +344,7 @@ class Meta: #'catalogue_purpose': 'Your organisation\'s purpose', "catalogue_logo_squared": "Upload your company's squared logotype. (required to sign contract)", "catalogue_logo_freesize": "Upload your company's logotype in any dimensions, in addition to the squared logotype.", - "catalogue_cities": "Please write the main cities where your company operates. Separate the cities with commas." + "catalogue_cities": "Please write the main cities where your company operates. Separate the cities with commas.", #'catalogue_founded': 'Which year was the company founded?' }