diff --git a/server/vbv_lernwelt/shop/views.py b/server/vbv_lernwelt/shop/views.py index 84fb4907..3f5e4a97 100644 --- a/server/vbv_lernwelt/shop/views.py +++ b/server/vbv_lernwelt/shop/views.py @@ -277,31 +277,28 @@ def update_user_address(user: User, checkout_info: CheckoutInformation): user.street_number = checkout_info.street_number user.postal_code = checkout_info.postal_code user.city = checkout_info.city - try: - user.country = Country.objects.get(country_id=checkout_info.country) - except Country.DoesNotExist: - pass - user.organisation_detail_name = checkout_info.company_name - user.organisation_street = checkout_info.company_street - user.organisation_street_number = checkout_info.company_street_number - user.organisation_postal_code = checkout_info.company_postal_code - user.organisation_city = checkout_info.company_city - try: - user.organisation_country = Country.objects.get( - country_id=checkout_info.company_country - ) - except Country.DoesNotExist: - pass + if checkout_info.country: + user.country = Country.objects.filter(country_id=checkout_info.country).first() if ( - user.organisation_detail_name - and user.organisation_street - and user.organisation_street_number - and user.organisation_postal_code - and user.organisation_city - and user.organisation_country + checkout_info.company_name + and checkout_info.company_street + and checkout_info.company_street_number + and checkout_info.company_postal_code + and checkout_info.company_city + and checkout_info.company_country ): + user.organisation_detail_name = checkout_info.company_name + user.organisation_street = checkout_info.company_street + user.organisation_street_number = checkout_info.company_street_number + user.organisation_postal_code = checkout_info.company_postal_code + user.organisation_city = checkout_info.company_city + + user.organisation_country = Country.objects.filter( + country_id=checkout_info.company_country + ).first() + user.invoice_address = User.INVOICE_ADDRESS_ORGANISATION user.save()