Skip to content

Commit

Permalink
Merge pull request #11 from GeotrekCE/feat/EventListing_defaultfilters
Browse files Browse the repository at this point in the history
Feat/event listing defaultfilters
  • Loading branch information
amandine-sahl authored Jun 29, 2023
2 parents f7d3e84 + 6fd2869 commit 24c9231
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 3 additions & 1 deletion backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 12 additions & 0 deletions backend/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion front-vite/src/components/EventReservationForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
10 changes: 6 additions & 4 deletions front-vite/src/views/EventListingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -467,17 +467,19 @@ const config = ref(CONFIGURATION)
*/
const filters = ref<ResaEventFilters>({
search_name: '',
begin_date: '',
begin_date: new Date().toISOString().substring(0,10),
end_date: '',
type_id: [],
massif: []
massif: [],
published: true
})
const defaultFilters =ref<ResaEventFilters>({
begin_date: '',
search_name: '',
begin_date: new Date().toISOString().substring(0,10),
end_date: '',
type_id: [],
massif: [],
search_name: ''
published: true
})
const districts = ref<string[]>([])
const eventtypes = ref<string[]>([])
Expand Down

0 comments on commit 24c9231

Please sign in to comment.