Compare commits

...

2 Commits

Author SHA1 Message Date
Lauréline Guérin 005033ed17 api: sort events by date in datetimes endpoint (#75331)
gitea/chrono/pipeline/head This commit looks good Details
2023-03-10 15:51:10 +01:00
Frédéric Péters 0089553e40 ci: limit tests to django 3.2 (#74894) 2023-03-10 15:51:05 +01:00
3 changed files with 22 additions and 4 deletions

View File

@ -855,6 +855,7 @@ class Datetimes(APIView):
bypass_delays=payload.get('bypass_delays'),
)
entries = Event.annotate_queryset_for_user(entries, user_external_id)
entries = entries.order_by('start_datetime', 'duration', 'label')
if payload['hide_disabled']:
entries = [

View File

@ -82,6 +82,26 @@ def test_datetimes_api_wrong_kind(app):
app.get('/api/agenda/%s/datetimes/' % agenda.slug, status=404)
@pytest.mark.freeze_time('2023-03-10')
def test_datetimes_sort(app):
agenda = Agenda.objects.create(label='Foo bar', kind='events', minimal_booking_delay=0)
Event.objects.create(
slug='event-slug',
start_datetime=localtime(now() + datetime.timedelta(days=5)).replace(hour=17, minute=0),
places=5,
agenda=agenda,
)
Event.objects.create(
slug='event-slug-2',
start_datetime=localtime(now() + datetime.timedelta(days=4)).replace(hour=17, minute=0),
places=5,
agenda=agenda,
)
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
assert resp.json['data'][0]['datetime'] == '2023-03-14 17:00:00'
assert resp.json['data'][1]['datetime'] == '2023-03-15 17:00:00'
def test_datetime_api_fr(app):
agenda = Agenda.objects.create(label='Foo bar', kind='events', minimal_booking_delay=0)
Event.objects.create(

View File

@ -1,7 +1,6 @@
[tox]
envlist =
py3-django22-codestyle-coverage,
py3-django32,
py3-django32-codestyle-coverage,
pylint
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/chrono/{env:BRANCH_NAME:}
@ -32,8 +31,6 @@ deps =
django-mellon>=1.6.1
pytest-freezegun
django-filter>=2.4,<2.5
django22: django>=2.2,<2.3
django22: psycopg2-binary<2.9
django32: django>=3.2,<3.3
django32: psycopg2-binary>=2.9
codestyle: pre-commit