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

Add takes_place_virtually and virtual_address to notification context #293

Merged
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
6 changes: 5 additions & 1 deletion resources/models/reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,8 @@ def get_notification_context(self, language_code, user=None, notification_type=N
'require_workstation': self.require_workstation,
'private_event': self.private_event,
'extra_question': self.reservation_extra_questions,
'home_municipality_id': reserver_home_municipality
'home_municipality_id': reserver_home_municipality,
'takes_place_virtually': self.takes_place_virtually
}
directly_included_fields = (
'number_of_participants',
Expand Down Expand Up @@ -543,6 +544,9 @@ def get_notification_context(self, language_code, user=None, notification_type=N

if self.user and self.user.is_staff:
context['staff_name'] = self.user.get_display_name()

if self.virtual_address:
context['virtual_address'] = self.virtual_address

# Comments should only be added to notifications that are sent to staff.
if notification_type in [NotificationType.RESERVATION_CREATED_OFFICIAL] and self.comments:
Expand Down
35 changes: 31 additions & 4 deletions resources/tests/test_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,37 @@ def test_admin_may_bypass_min_period(resource_with_opening_hours, user):

@pytest.mark.django_db
def test_reservation_home_municipality_field_str():
home_municipality_field = ReservationHomeMunicipalityField.objects.create(name='test municipality')
assert str(home_municipality_field) == 'test municipality'
home_municipality_field = ReservationHomeMunicipalityField.objects.create(name='test municipality')
assert str(home_municipality_field) == 'test municipality'

@pytest.mark.django_db
def test_reservation_home_municipality_set_str():
home_municipality_set = ReservationHomeMunicipalitySet.objects.create(name='test municipality set')
assert str(home_municipality_set) == 'test municipality set'
home_municipality_set = ReservationHomeMunicipalitySet.objects.create(name='test municipality set')
assert str(home_municipality_set) == 'test municipality set'



@pytest.mark.parametrize('virtual_address', (
None,
'jokin://linkki/jonnekkin'
))
@pytest.mark.django_db
def test_reservation_notification_template_takes_place_virtually(resource_in_unit, virtual_address):

tz = timezone.get_current_timezone()
begin = tz.localize(datetime.datetime(2115, 6, 1, 8, 0, 0))
end = begin + datetime.timedelta(hours=0, minutes=30)

reservation = Reservation(
resource=resource_in_unit,
takes_place_virtually=True,
virtual_address=virtual_address,
begin=begin,
end=end
)
context = reservation.get_notification_context('fi')
assert 'takes_place_virtually' in context
if virtual_address:
assert 'virtual_address' in context
else:
assert 'virtual_address' not in context
2 changes: 0 additions & 2 deletions resources/tests/test_reservation_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3281,8 +3281,6 @@ def test_reservation_reminder_create(
resource_with_reservation_reminders):
api_client.force_authenticate(user=user)
reservation_data['resource'] = resource_with_reservation_reminders.pk
reservation_data['begin'] = '2115-04-04T09:00:00+02:00'
reservation_data['end'] = '2115-04-04T10:00:00+02:00'
reservation_data['reserver_name'] = 'Nordea Demo'
reservation_data['reserver_email_address'] = '[email protected]'
reservation_data['reserver_phone_number'] = '+358404040404'
Expand Down
Loading