Project-Stage-Academy / UA_1155_alpha

UA-1155.Python Project Stage alpha group
3 stars 0 forks source link

Manage and store investors interests #104 #112

Closed YuliaShap closed 1 month ago

YuliaShap commented 1 month ago

To start review, you need to delete the database or clean it completely, because the interests field now accepts a list instead of a string To clear the database: python manage.py dbshell

DO $$ DECLARE
    r RECORD;
BEGIN
    FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
        EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
    END LOOP;
END $$;

Then do the migration: python manage.py makemigrations python manage.py migrate

And add new industries to the database: python manage.py loaddata startups/industries.json

Add new records to the database. Remember, the interests of the investor are entered in a list, for example, {"interests": ["Health Care", "Transportation"]}

Endpoints for testing:

api/investors/{pk}/add_interests/ api/investors/{pk}/remove_interests/

Also you can test all CRUD methods for investors, if you want, because that were refactored.

Add interests

Screenshot 2024-05-20 at 17 14 59

Remove interest

Screenshot 2024-05-20 at 17 15 43

Checking for the presence of interests in the investor list when we add interest

Screenshot 2024-05-20 at 17 16 51

Checking for the presence of interests in the investor list when we remove interest

Screenshot 2024-05-20 at 17 21 27
Thoughtseize1 commented 1 month ago

23-05-2024 17-03-33 Now everything works perfectly! Thank you for your work, @YuliaShap! 🙌🏻