From f379e0af95074e1c73d0c38ff94e598dbac6804b Mon Sep 17 00:00:00 2001 From: amandine-sahl Date: Wed, 28 Jun 2023 21:24:28 +0200 Subject: [PATCH 1/3] Add default filter date and published --- front-vite/src/views/EventListingView.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/front-vite/src/views/EventListingView.vue b/front-vite/src/views/EventListingView.vue index 33fd39cf..5bffc3b8 100644 --- a/front-vite/src/views/EventListingView.vue +++ b/front-vite/src/views/EventListingView.vue @@ -467,17 +467,19 @@ const config = ref(CONFIGURATION) */ const filters = ref({ search_name: '', - begin_date: '', + begin_date: new Date(), end_date: '', type_id: [], - massif: [] + massif: [], + published: true }) const defaultFilters =ref({ - begin_date: '', + search_name: '', + begin_date: new Date(), end_date: '', type_id: [], massif: [], - search_name: '' + published: true }) const districts = ref([]) const eventtypes = ref([]) From 1c527ca6cbfa74ad236d3ee03096c87fa022d3b0 Mon Sep 17 00:00:00 2001 From: amandine-sahl Date: Wed, 28 Jun 2023 21:45:37 +0200 Subject: [PATCH 2/3] Correction filtre date de fin --- backend/core/models.py | 4 +++- backend/test/test_api.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/backend/core/models.py b/backend/core/models.py index 47a9f86d..a3e9e1ce 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -25,7 +25,9 @@ def filter_properties(self, filters): if "end_date" in filters: # set the end_date at 23h59 because a hour can be set in timestamp - end_date = datetime.datetime.strptime(filters.pop("end_date"), "%Y-%m-%d") + end_date = datetime.datetime.strptime( + filters.pop("end_date")[:10], "%Y-%m-%d" + ) end_date = end_date.replace(hour=23, minute=59, second=59) self = self.filter(GTEvents.end_date <= end_date) diff --git a/backend/test/test_api.py b/backend/test/test_api.py index 21b59f7b..f6a96d5f 100644 --- a/backend/test/test_api.py +++ b/backend/test/test_api.py @@ -96,6 +96,18 @@ def test_login(self): def test_get_events(self): response = self.client.get(url_for("app_routes.get_events")) assert response.status_code == 200 + response = self.client.get( + url_for( + "app_routes.get_events", + published=True, + begin_date="2023-06-27T22:00:00.000Z", + end_date="2023-07-27T22:00:00.000Z", + cancelled=True, + sortBy="begin_date", + sortDesc=False, + ) + ) + assert response.status_code == 200 def test_get_one_event(self, events): data = GTEvents.query.limit(1).one() From 6fd2869a4e8d50d546e6c057657976a2589173ed Mon Sep 17 00:00:00 2001 From: amandine-sahl Date: Wed, 28 Jun 2023 22:11:52 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Correction=20type=20d=C3=A9claration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front-vite/src/components/EventReservationForm.vue | 2 +- front-vite/src/views/EventListingView.vue | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/front-vite/src/components/EventReservationForm.vue b/front-vite/src/components/EventReservationForm.vue index da7abeca..b7715bfc 100644 --- a/front-vite/src/components/EventReservationForm.vue +++ b/front-vite/src/components/EventReservationForm.vue @@ -347,7 +347,7 @@ const formSchema = yup.object().shape({ tel: yup.string().required().label('Téléphone'), nom: yup.string().required().label('Nom'), prenom: yup.string().required().label('Prénom'), - num_departement: yup.string().required().oneOf(CONFIGURATION.ORIGINS.map(x => x.value)).label('Lieu d\'origine'), + num_departement: yup.string().required().oneOf(CONFIGURATION.ORIGINS.map(x => String(x.value))).label('Lieu d\'origine'), commentaire: yup.string().nullable().label('Commentaire'), nb_adultes: yup.number().min(0).default(0).label('Adulte(s)'), nb_moins_6_ans: yup.number().min(0).default(0).label('Moins de 6 ans'), diff --git a/front-vite/src/views/EventListingView.vue b/front-vite/src/views/EventListingView.vue index 5bffc3b8..0ab3746a 100644 --- a/front-vite/src/views/EventListingView.vue +++ b/front-vite/src/views/EventListingView.vue @@ -467,7 +467,7 @@ const config = ref(CONFIGURATION) */ const filters = ref({ search_name: '', - begin_date: new Date(), + begin_date: new Date().toISOString().substring(0,10), end_date: '', type_id: [], massif: [], @@ -475,7 +475,7 @@ const filters = ref({ }) const defaultFilters =ref({ search_name: '', - begin_date: new Date(), + begin_date: new Date().toISOString().substring(0,10), end_date: '', type_id: [], massif: [],