manager: fix alignments of opening hours in months with dst change (#37393)
This commit is contained in:
parent
968232d8b8
commit
befaa3b365
|
@ -24,7 +24,7 @@ from django.db.models import Q
|
|||
from django.http import HttpResponse, Http404, HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.dates import MONTHS
|
||||
from django.utils.timezone import now, make_aware
|
||||
from django.utils.timezone import now, make_aware, make_naive
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext
|
||||
from django.utils.encoding import force_text
|
||||
|
@ -386,6 +386,7 @@ class AgendaMonthView(AgendaDateView, MonthArchiveView):
|
|||
'periods': periods}
|
||||
|
||||
def get_day_timetable_infos(self, day, interval):
|
||||
day = make_aware(make_naive(day)) # give day correct timezone
|
||||
period = current_date = day.replace(hour=self.min_timeperiod.hour, minute=0)
|
||||
timetable = {'date': current_date,
|
||||
'today': day.date() == datetime.date.today(),
|
||||
|
|
|
@ -8,6 +8,7 @@ from django.contrib.auth.models import User, Group
|
|||
from django.utils.encoding import force_text
|
||||
from django.utils.timezone import make_aware, now, localtime
|
||||
import datetime
|
||||
import freezegun
|
||||
import mock
|
||||
import pytest
|
||||
import requests
|
||||
|
@ -1541,6 +1542,41 @@ def test_agenda_month_view(app, admin_user, manager_user, api_user):
|
|||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, today.year, today.month))
|
||||
assert not 'No opening hours this month.' in resp.text
|
||||
|
||||
def test_agenda_month_view_dst_change(app, admin_user, manager_user, api_user):
|
||||
agenda = Agenda.objects.create(label='Passeports', kind='meetings')
|
||||
desk = Desk.objects.create(agenda=agenda, label='Desk A')
|
||||
|
||||
meetingtype = MeetingType(agenda=agenda, label='passeport', duration=20)
|
||||
meetingtype.save()
|
||||
|
||||
for weekday in range(0, 7): # open all mornings
|
||||
TimePeriod(desk=desk, weekday=weekday,
|
||||
start_time=datetime.time(9, 0),
|
||||
end_time=datetime.time(12, 0)).save()
|
||||
|
||||
login(app)
|
||||
for date in ('2019-10-01', '2019-10-31'):
|
||||
with freezegun.freeze_time(date):
|
||||
resp = app.get('/manage/agendas/%s/2019/10/' % agenda.id)
|
||||
# check all days are correctly aligned
|
||||
assert resp.text.count('height:300.0%;top:0.0%') == 31
|
||||
|
||||
# book some slots
|
||||
app.reset()
|
||||
app.authorization = ('Basic', ('john.doe', 'password'))
|
||||
with freezegun.freeze_time('2019-10-01'):
|
||||
resp = app.get('/api/agenda/%s/meetings/%s/datetimes/' % (agenda.slug, meetingtype.slug))
|
||||
booking_url = resp.json['data'][3]['api']['fillslot_url'] # 2019-10-02 10:00:00
|
||||
booking_url2 = resp.json['data'][246]['api']['fillslot_url'] # 2019-10-29 10:00:00
|
||||
resp = app.post(booking_url)
|
||||
resp = app.post_json(booking_url2)
|
||||
|
||||
# check booked slots are similarly aligned
|
||||
login(app)
|
||||
resp = app.get('/manage/agendas/%s/2019/10/' % agenda.id)
|
||||
assert resp.text.count('height:33.0%;top:100.0%;') == 2
|
||||
|
||||
|
||||
def test_import_agenda_as_manager(app, manager_user):
|
||||
# open /manage/ access to manager_user, and check agenda import is not
|
||||
# allowed.
|
||||
|
|
Loading…
Reference in New Issue