CRUD Features (Professional Management Example)
In Project Part 7, you will add CRUD features to your Professionals and Services page as well as users.
Download this sample app, which shows how CRUD features should work for the Professionals page.
Review the example code carefully.
You should be able to understand all of it based on your experience with other project parts.
If it is unclear in anyway how and why it works, please take the time to look up, test, and analyze until you understand how it works.
Study the Features
Please take time to look at and understand the following features added in the example above:
- Back End (flaskapp)
- New Model Functions (model_main.py): update_field_professional, update_image_professional, delete_row_professional, and the helper function allowedfield (for validation).
- New Routes (app.py):
- "/professionals" (POST),
- "/professional//" (PATCH),
- "/professional//" (PATCH), and
- "/professional/" (DELETE).
- Front End (reactapp)
- New Container Components: DeleteButton, EditImage, EditText
- Consolidated Page Components:
Professionals and ProfessionalsAdd are no longer separate pages.
They are all in the professionals page now.
In the project, you will make the add, edit, and delete buttons show or hide based on the edit mode context, but in this exercise, editmode is set on all the time.
- Changes in api.js: Changes are made to make PATCH, PUT, and DELETE functionality available.
- What is Excluded
- All Login-Related Code:
Note that the above example deliberately excludes anything in model_login.py that you created in Project Part 6, any access_required calls or login status check. You will still need all your Project Part 6 code. You will also need to add login-related functionality in model_login.py and app.py in Project Part 7 (code to manage user profile and password information, check validity, track changes in local storage, etc.)
- All Service and Service-Category-Related Code:
The example above also excludes code that manages services and service categories, which you will need to maintain and add to make in Project Part 7.
- The Nav and Footer:
The example above also has a blank Nav and Footer.
- Note on Modularization: Note that when you are creating functions to update the users, services, and categories tables and files, a lot of the code in these functions will be duplicated unless you do something to modularize it.