Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reservee language from reservations #1499

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1428,10 +1428,6 @@ msgstr "Varaajan postinumero"
msgid "Reservee is an unregistered association"
msgstr "Varaaja on rekisteröimätön yhdistys"

#: tilavarauspalvelu/admin/reservation/form.py
msgid "Preferred language of reservee"
msgstr "Varaajan kieli"

#: tilavarauspalvelu/admin/reservation/form.py
msgid "Type of reservee"
msgstr "Varaajan tyyppi"
Expand Down Expand Up @@ -1610,10 +1606,6 @@ msgstr "Varaajan kaupunki"
msgid "Reservee's zip code"
msgstr "Varaajan postinumero"

#: tilavarauspalvelu/admin/reservation/form.py
msgid "Reservee's preferred language"
msgstr "Varaajan suosima kieli"

#: tilavarauspalvelu/admin/reservation/form.py
msgid "User who made the reservation"
msgstr "Varauksen tehnyt käyttäjä"
Expand Down
8 changes: 0 additions & 8 deletions locale/sv/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1384,10 +1384,6 @@ msgstr ""
msgid "Reservee is an unregistered association"
msgstr ""

#: tilavarauspalvelu/admin/reservation/form.py
msgid "Preferred language of reservee"
msgstr ""

#: tilavarauspalvelu/admin/reservation/form.py
msgid "Type of reservee"
msgstr ""
Expand Down Expand Up @@ -1566,10 +1562,6 @@ msgstr ""
msgid "Reservee's zip code"
msgstr ""

#: tilavarauspalvelu/admin/reservation/form.py
msgid "Reservee's preferred language"
msgstr ""

#: tilavarauspalvelu/admin/reservation/form.py
msgid "User who made the reservation"
msgstr ""
Expand Down
2 changes: 0 additions & 2 deletions tests/factories/reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class Meta:
reservee_address_zip = FakerFI("postcode")
reservee_is_unregistered_association = False
reservee_used_ad_login = False
reservee_language = LazyAttribute(lambda i: i.user.get_preferred_language())
reservee_type = CustomerTypeChoice.INDIVIDUAL

# Billing information
Expand Down Expand Up @@ -309,7 +308,6 @@ def for_user(self, user: User) -> Self:
self.kwargs["reservee_first_name"] = user.first_name
self.kwargs["reservee_last_name"] = user.last_name
self.kwargs["reservee_email"] = user.email
self.kwargs["reservee_language"] = user.get_preferred_language()
return self

def for_reservation_unit(self, reservation_unit: ReservationUnit) -> Self:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_get_verkkokauppa_order_params__to_json():
email="test@localhost",
first_name="First",
last_name="Last",
preferred_language="fi",
)
reservation = ReservationFactory.create(
reservation_units=[reservation_unit],
Expand All @@ -39,15 +40,14 @@ def test_get_verkkokauppa_order_params__to_json():
reservee_last_name="Lastname",
reservee_email="[email protected]",
reservee_phone="+358 50 123 4567",
reservee_language="fi",
)

order_params = get_verkkokauppa_order_params(reservation)
json = order_params.to_json()

assert json["namespace"] == settings.VERKKOKAUPPA_NAMESPACE
assert json["user"] == str(reservation.user.uuid)
assert json["language"] == reservation.reservee_language or "fi"
assert json["language"] == reservation.user.get_preferred_language()
assert json["priceNet"] == "10.12"
assert json["priceVat"] == "2.43"
assert json["priceTotal"] == "12.55"
Expand Down Expand Up @@ -93,6 +93,7 @@ def test_get_verkkokauppa_order_params__to_json__meta_label_language_support():
email="test@localhost",
first_name="First",
last_name="Name",
preferred_language="en",
)
reservation = ReservationFactory.create(
reservation_units=[reservation_unit],
Expand All @@ -104,7 +105,6 @@ def test_get_verkkokauppa_order_params__to_json__meta_label_language_support():
reservee_last_name="Lastname",
reservee_email="[email protected]",
reservee_phone="+358 50 123 4567",
reservee_language="en",
)

order_params = get_verkkokauppa_order_params(reservation)
Expand Down
17 changes: 7 additions & 10 deletions tests/test_external_services/test_verkkokauppa/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
from django.utils.timezone import get_default_timezone
from freezegun import freeze_time

from tilavarauspalvelu.enums import CustomerTypeChoice, Language
from tilavarauspalvelu.enums import CustomerTypeChoice
from tilavarauspalvelu.integrations.verkkokauppa.exceptions import UnsupportedMetaKeyError
from tilavarauspalvelu.integrations.verkkokauppa.helpers import (
get_formatted_reservation_time,
get_meta_label,
get_verkkokauppa_order_params,
)

from tests.factories import PaymentProductFactory, ReservationFactory, ReservationUnitFactory, UserFactory
from tests.factories import PaymentProductFactory, ReservationFactory, ReservationUnitFactory

# Applied to all tests
pytestmark = [
Expand All @@ -35,13 +35,12 @@
def test_get_formatted_reservation_time(language, result):
begin = datetime.datetime.now().astimezone(tz=get_default_timezone())
end = begin + datetime.timedelta(hours=2)
reservation = ReservationFactory.create(begin=begin, end=end, reservee_language=language)
reservation = ReservationFactory.create(begin=begin, end=end, user__preferred_language=language)
date = get_formatted_reservation_time(reservation)
assert date == result


def test_get_verkkokauppa_order_params__respect_reservee_language():
user = UserFactory.create()
payment_product = PaymentProductFactory.create()
runit = ReservationUnitFactory.create(
payment_product=payment_product,
Expand All @@ -52,25 +51,23 @@ def test_get_verkkokauppa_order_params__respect_reservee_language():

reservation_en = ReservationFactory.create(
reservation_units=[runit],
user=user,
user__preferred_language="en",
reservee_type=CustomerTypeChoice.INDIVIDUAL,
reservee_language=Language.EN.value,
)
order_params = get_verkkokauppa_order_params(reservation_en)
assert order_params.items[0].product_name == "Name"

reservation_sv = ReservationFactory.create(
reservation_units=[runit],
user=user,
user__preferred_language="sv",
reservee_type=CustomerTypeChoice.INDIVIDUAL,
reservee_language=Language.SV.value,
)
order_params = get_verkkokauppa_order_params(reservation_sv)
assert order_params.items[0].product_name == "Namn"


def test_get_meta_label():
reservation = ReservationFactory.create(reservee_language=Language.FI.value)
reservation = ReservationFactory.create(user__preferred_language="fi")

period_label = get_meta_label("reservationPeriod", reservation)
assert period_label == "Varausaika"
Expand All @@ -80,7 +77,7 @@ def test_get_meta_label():


def test_get_meta_label__raises_exception_with_unsupported_key():
reservation = ReservationFactory.create(reservee_language=Language.FI.value)
reservation = ReservationFactory.create(user__preferred_language="fi")

with pytest.raises(UnsupportedMetaKeyError) as err:
get_meta_label("unsupported", reservation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def test_recurring_reservations__create_series__reservation_details(graphql):
data["reservationDetails"]["reserveeAddressCity"] = "city"
data["reservationDetails"]["reserveeAddressZip"] = "cip"
data["reservationDetails"]["reserveeIsUnregisteredAssociation"] = False
data["reservationDetails"]["reserveeLanguage"] = "FI"
data["reservationDetails"]["reserveeType"] = CustomerTypeChoice.BUSINESS.upper()
data["reservationDetails"]["billingFirstName"] = "Bill"
data["reservationDetails"]["billingLastName"] = "Admin"
Expand Down Expand Up @@ -157,7 +156,6 @@ def test_recurring_reservations__create_series__reservation_details(graphql):
assert reservations[0].reservee_address_city == "city"
assert reservations[0].reservee_address_zip == "cip"
assert reservations[0].reservee_is_unregistered_association is False
assert reservations[0].reservee_language == "fi"
assert reservations[0].reservee_type == CustomerTypeChoice.BUSINESS
assert reservations[0].billing_first_name == "Bill"
assert reservations[0].billing_last_name == "Admin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def test_recurring_reservations__update_series(graphql):
"reserveeAddressCity": "city",
"reserveeAddressZip": "cip",
"reserveeIsUnregisteredAssociation": False,
"reserveeLanguage": "FI",
"reserveeType": CustomerTypeChoice.BUSINESS.upper(),
"billingFirstName": "Bill",
"billingLastName": "Admin",
Expand Down Expand Up @@ -108,7 +107,6 @@ def test_recurring_reservations__update_series(graphql):
assert reservation.reservee_address_city == "city"
assert reservation.reservee_address_zip == "cip"
assert reservation.reservee_is_unregistered_association is False
assert reservation.reservee_language == "fi"
assert reservation.reservee_type == CustomerTypeChoice.BUSINESS
assert reservation.billing_first_name == "Bill"
assert reservation.billing_last_name == "Admin"
Expand Down
10 changes: 5 additions & 5 deletions tests/test_graphql_api/test_reservation/test_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def test_reservation__confirm__does_not_create_order_when_handling_is_required(g
def test_reservation__confirm__creates_local_order_when_payment_type_is_on_site(graphql):
reservation = ReservationFactory.create_for_confirmation(
reservation_units__payment_types__code=PaymentType.ON_SITE,
reservee_language="fi",
user__preferred_language="fi",
)

graphql.login_with_superuser()
Expand All @@ -243,7 +243,7 @@ def test_reservation__confirm__creates_local_order_when_payment_type_is_on_site(
assert len(orders) == 1
assert orders[0].payment_type == PaymentType.ON_SITE
assert orders[0].status == OrderStatus.PAID_MANUALLY
assert orders[0].language == reservation.reservee_language
assert orders[0].language == reservation.user.preferred_language
assert orders[0].reservation == reservation

assert VerkkokauppaAPIClient.create_order.called is False
Expand All @@ -253,7 +253,7 @@ def test_reservation__confirm__creates_local_order_when_payment_type_is_on_site(
def test_reservation__confirm__calls_verkkokauppa_api_when_payment_type_is_not_on_site(graphql):
reservation = ReservationFactory.create_for_confirmation(
reservation_units__payment_types__code=PaymentType.INVOICE,
reservee_language="fi",
user__preferred_language="fi",
)

order = OrderFactory.create()
Expand All @@ -272,7 +272,7 @@ def test_reservation__confirm__calls_verkkokauppa_api_when_payment_type_is_not_o
assert len(orders) == 1
assert orders[0].payment_type == PaymentType.INVOICE
assert orders[0].status == OrderStatus.DRAFT
assert orders[0].language == reservation.reservee_language
assert orders[0].language == reservation.user.preferred_language
assert orders[0].reservation == reservation
assert orders[0].remote_id == order.order_id
assert orders[0].checkout_url == order.checkout_url
Expand All @@ -286,7 +286,7 @@ def test_reservation__confirm__calls_verkkokauppa_api_when_payment_type_is_not_o
def test_reservation__confirm__does_not_save_when_api_call_fails(graphql):
reservation = ReservationFactory.create_for_confirmation(
reservation_units__payment_types__code=PaymentType.INVOICE,
reservee_language="fi",
user__preferred_language="fi",
)

graphql.login_with_superuser()
Expand Down
17 changes: 2 additions & 15 deletions tests/test_integrations/test_email/test_find_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_get_application_email_language(preferred_language):
assert lang == preferred_language


def test_get_application_email_language__invalid_preferred_language():
def test_get_application_email_language__invalid_language():
application = ApplicationFactory.create(user__preferred_language="uk")

lang = get_application_email_language(application)
Expand All @@ -36,29 +36,16 @@ def test_get_application_email_language__invalid_preferred_language():
def test_get_reservation_email_language(preferred_language):
reservation = ReservationFactory.create(
user__preferred_language=preferred_language,
reservee_language="",
)

lang = get_reservation_email_language(reservation)

assert lang == preferred_language


def test_get_reservation_email_language__use_reservee_language():
reservation = ReservationFactory.create(
user__preferred_language="",
reservee_language=Language.EN.value,
)

lang = get_reservation_email_language(reservation)

assert lang == Language.EN.value


def test_get_reservation_email_language__invalid_languages():
def test_get_reservation_email_language__invalid_language():
reservation = ReservationFactory.create(
user__preferred_language="uk",
reservee_language="es",
)

lang = get_reservation_email_language(reservation)
Expand Down
2 changes: 0 additions & 2 deletions tests/test_integrations/test_email/test_find_recipients.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def test_get_reservation_email_recipients__no_user():
reservation = ReservationFactory.create(
user=None,
reservee_email="[email protected]",
reservee_language=Language.EN.value,
)

result = get_reservation_email_recipients(reservation)
Expand All @@ -79,7 +78,6 @@ def test_get_reservation_email_recipients__no_reservee_email_or_user():
reservation = ReservationFactory.create(
user=None,
reservee_email="",
reservee_language=Language.EN.value,
)

result = get_reservation_email_recipients(reservation)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_models/test_reservation_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_statistics__create__reservation_creation_creates_statistics(settings):
tax_percentage_value=24,
unit_price=10,
working_memo="its like that",
user__preferred_language="fi",
)

reservation_unit = reservation.reservation_units.first()
Expand Down Expand Up @@ -107,7 +108,7 @@ def test_statistics__create__reservation_creation_creates_statistics(settings):
assert stat.reservee_address_zip == ""
assert stat.reservee_id == ""
assert stat.reservee_is_unregistered_association == reservation.reservee_is_unregistered_association
assert stat.reservee_language == reservation.reservee_language
assert stat.reservee_language == reservation.user.preferred_language
assert stat.reservee_organisation_name == ""
assert stat.reservee_type == reservation.reservee_type
assert stat.reservee_uuid == str(reservation.user.tvp_uuid)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_querysets/test_reservation_querysets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from tilavarauspalvelu.enums import Language, ReservationStateChoice, ReservationTypeChoice
from tilavarauspalvelu.enums import ReservationStateChoice, ReservationTypeChoice
from tilavarauspalvelu.integrations.opening_hours.time_span_element import TimeSpanElement
from tilavarauspalvelu.models import AffectingTimeSpan, Reservation, ReservationUnit, ReservationUnitHierarchy
from utils.date_utils import DEFAULT_TIMEZONE, local_date
Expand Down Expand Up @@ -40,7 +40,6 @@ def _create_test_reservations_for_all_reservation_units() -> None:
end=_datetime(minute=0),
reservation_units=[reservation_unit],
user=None,
reservee_language=Language.FI.value,
state=ReservationStateChoice.CREATED,
type=ReservationTypeChoice.NORMAL,
)
Expand Down
1 change: 0 additions & 1 deletion tilavarauspalvelu/admin/reservation/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ class ReservationAdmin(admin.ModelAdmin):
"reservee_address_city",
"reservee_address_zip",
"reservee_is_unregistered_association",
"reservee_language",
"reservee_type",
],
},
Expand Down
2 changes: 0 additions & 2 deletions tilavarauspalvelu/admin/reservation/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class Meta:
"reservee_address_city": _("Reservee address city"),
"reservee_address_zip": _("Reservee address zip code"),
"reservee_is_unregistered_association": _("Reservee is an unregistered association"),
"reservee_language": _("Preferred language of reservee"),
"reservee_type": _("Type of reservee"),
#
"billing_first_name": _("Billing first name"),
Expand Down Expand Up @@ -111,7 +110,6 @@ class Meta:
"reservee_address_city": _("Reservee's city"),
"reservee_address_zip": _("Reservee's zip code"),
"reservee_is_unregistered_association": _("Reservee is an unregistered association"),
"reservee_language": _("Reservee's preferred language"),
"reservee_type": _("Type of reservee"),
#
"billing_first_name": _("Billing first name"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class Meta:
"reservee_address_city",
"reservee_address_zip",
"reservee_is_unregistered_association",
"reservee_language",
"reservee_type",
#
"billing_first_name",
Expand Down Expand Up @@ -277,7 +276,6 @@ class Meta:
"reservee_address_city",
"reservee_address_zip",
"reservee_is_unregistered_association",
"reservee_language",
"reservee_type",
#
"billing_first_name",
Expand Down Expand Up @@ -567,7 +565,6 @@ def get_reservation_details(self, instance: RecurringReservation) -> Reservation
reservee_address_city=next_reservation.reservee_address_city,
reservee_address_zip=next_reservation.reservee_address_zip,
reservee_is_unregistered_association=next_reservation.reservee_is_unregistered_association,
reservee_language=next_reservation.reservee_language,
reservee_type=next_reservation.reservee_type,
#
billing_first_name=next_reservation.billing_first_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class Meta:
"reservee_type",
"reservee_id",
"reservee_is_unregistered_association",
"reservee_language",
#
# Billing information
"billing_address_city",
Expand Down
Loading