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

Feat/event listing defaultfilters #11

Merged
merged 3 commits into from
Jun 29, 2023
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
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