This is a Flask-built API to maintain experience hours and related information for users that are volunteers or admin of a health clinic.
Table of Contents
This is an API for managing volunteers and their experience hours.
-
Clone the repo
git clone https://github.com/ari-denary/volunteer-management-backend.git
-
cd into project folder in terminal window
-
Create a virtual environment
python3 -m venv venv
- Activate venv
source venv/bin/activate
- Install in
venv
all items fromrequirements.txt
pip3 install -r requirements.txt
- Run Flask
flask run
The API contains the following routes that receive and return JSON.
- Handles user signup. Expects JSON:
{
"badge_number":"1",
"email":"sample@mail.com",
"password":"password",
"first_name":"sample",
"last_name":"user",
"dob":"datetime.datetime(2000, 1, 1, 0, 0)",
"gender":"Prefer not to say",
"address":"123 Cherry lane",
"city":"New York",
"state":"NY",
"zip_code":"11001",
"phone_number":"9991234567",
"is_student":"true",
"is_healthcare_provider": "false",
"is_multilingual":"false"
}
- Returns JSON:
{ "token": "dleoidlksd.aslkfjoiweflkfj.aldsjfoweifsldf" }
- Handles user login. Expects JSON:
{ "email": "mail@mail.com", "password": "mypassword" }
- Returns JSON:
{ "token": "dleoidlksd.aslkfjoiweflkfj.aldsjfoweifsldf" }
- Authorization: None Required
- Returns JSON { race_ethnicity_options: { "race": [...], "ethnicity: [...], "ethnic_background": [...] } }
- Gets all users.
- Authorization: must be admin requesting with valid token.
- Returns JSON:
{
"users": [{
"id": 1,
"email": "admin@mail.com",
"experience_hours": 10,
"badge_number": 100,
"first_name": "first",
"last_name": "user",
"is_admin": False,
"is_student": True,
"is_healthcare_provider": False,
"is_multilingual": False,
"status": "new"
} ... ]
}
- Gets a user by id.
- Authorization: must be same user or admin requesting with valid token.
- Returns JSON:
{
"user": {
"id": 1,
"email": "admin@mail.com",
"school_email": "joe@school.edu",
"badge_number": 100,
"first_name": "first",
"last_name": "user",
"dob": "Sat, 01 Jan 2000 00:00:00 GMT",
"gender": "male",
"pronouns": "he/him",
"race": "white",
"ethnicity": "caucasian",
"created_at": "Sun, 21 May 2023 20:12:14 GMT",
"phone_number": "9991234567",
"phone_carrier": "verizon",
"address": "123 Cherry lane",
"city": "New York",
"state": "NY",
"zip_code": "11001",
"is_admin": false,
"is_multilingual": false,
"is_student": true,
"type_of_student": "full-time",
"school": "Oklahoma State",
"anticipated_graduation": "Sun, 19 May 2025 20:12:14 GMT",
"major": "Biology",
"minor": null,
"classification": null,
"degree": "B.S.",
"is_healthcare_provider": false,
"type_of_provider": null,
"employer": null,
"is_multilingual": false,
"status": "new",
}
}
- Gets all experiences for a user. Optional query parameter of 'incomplete' will return all experiences whose sign_out_time is None. Primary use case for 'incomplete' is for getting experience(s) to "sign out".
- Authorization: must be same user or admin requesting with valid token.
- Returns JSON:
{
"user_experiences": [{
"id": 1,
"date": "2023-04-06-08:35:12:23",
"sign_in_time": "2023-04-06-08:35:12:23",
"sign_out_time": "2023-04-06-08:35:12:23",
"department": "lab",
"user_id": 3
} ... ]
}
- Gets all languages for a user.
- Authorization: must be same user or admin requesting with valid token.
- Returns JSON:
{
"user_languages": [{
"id": 1,
"language": "spanish",
"fluency": "proficent",
"user_id": 3
} ... ]
}
- Gets all experiences for all users. Optional query parameter of 'incomplete' will return all experiences whose sign_out_time is None.
- Primary use case for 'incomplete' is to check any experiences that have not "signed out".
- Authorization: must be admin requesting with valid token.
- Returns JSON:
{
"user_experiences": [{
"id": 1,
"date": "2023-04-06-08:35:12:23",
"sign_in_time": "2023-04-06-08:35:12:23",
"sign_out_time": "2023-04-06-08:35:12:23",
"department": "lab",
"user_id": 3
} ... ]
}
- Create a new experience. Use case for "signing-in" to an experience.
- Authorization: must be same user or admin requesting with valid token.
- Accepts JSON - "date", "sign_in_time", "department", "user_id" required "sign_out_time" optional
{
"date": "2022-01-05 00:00:00",
"sign_in_time": "2022-01-05 08:00:00",
"department": "lab",
"user_id": 3
}
- Returns JSON:
{
"user_experience": {
"id": 1,
"date": "2022-01-05 00:00:00",
"sign_in_time": "2022-01-05 08:00:00",
"sign_out_time": "None",
"department": "lab",
"user_id": 3
}
}
- Update a user's experience sign out time and/or department.
- Use case for "signing-out" of an experience.
- Authorization: must be same user or admin requesting with valid token.
- Accepts JSON - "sign_out_time" required, "department" optional
{
"sign_out_time": "2023-04-06-08:35:12:23",
"department": "pharmacy"
}
- Returns JSON
{
"user_experience": {
"id": 1,
"date": "2023-04-06-08:35:12:23",
"sign_in_time": "2023-04-06-08:35:12:23",
"sign_out_time": "2023-04-06-08:35:12:23",
"department": "pharmacy",
"user_id": 3
}
}
To run tests:
FLASK_DEBUG=False python -m unittest test_filename.py
- Refactor JSON validation to use json schema while maintaining current level of datetime validation
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Ari Denary - adenary.dev@gmail.com - LinkedIn
Project Link: https://github.com/ari-denary/volunteer-management-backend