uprm-inso4101-2023-2024-s2 / semester-project-rumaradoptionapp

semester-project-rumaradoptionapp created by GitHub Classroom
5 stars 0 forks source link

Adoption Form Fix and Redirect #266

Closed Javi510348 closed 5 months ago

Javi510348 commented 5 months ago

Objective

Fix the Adoption Form, so it doesn't need the user_id and pet_id in the url. With the addition of sessions, we would use those ids from the session that the user created.

Description

Currently the only way to access the Adoption Form is if the user writes the correct address in the url because at the time we didn't have the pet profile view. Now that the pet profile view is working, we need to add a button in that view in which it will redirect the user to the adoption form. If the user is not logged in, it will redirect him to the login page. By adding that button we will also be able to get the pet_id required for the Adoption Form. Once we have the user_id and pet_id, we should be able to fillout the form without issues.

Implementation

To be able to implement this task, we need to to create a button in the pet profile view in which it will redirect the user from the current view to the Adoption Form view. Also, by pressing this button we will save the pet_id in the user session as request.session.pet_id, so we can have access to that value in the Query created for the adoption form. Once we have the button, we need to make sure that we change some of the logic in the app.post("/fillForm") because currently it works by looking at the values from the url, but that will not be necessary anymore since we have the session. Once we complete the Form, we need to delete the pet_id from the user session since we don't need that id anymore.

Deadline

April 25, 2024

1uismar33r0 commented 5 months ago

Changed the links for the Adoption Form, now the Adoption Form uses the session user id and the pet id. In Pet Listings the id of the pet is stored in the session and is changed to null in the controller of the Adoption Form and in the getAllPets function. This ensures the id of the pet is removed from the session after the form is filled and if the user decides to not fill it and return to Pet listings the function changes it to null. Also added the authentication function to the app.get() of fillForm so a user that is not logged in can't access the form. Fixed a minor bug from the user settings page to prevent other files that are not png or jpeg to be uploaded as the profile picture.