From 3142bcacd278b5720aeab5dd30001d078d36572b Mon Sep 17 00:00:00 2001 From: Ido Yekutiel Date: Tue, 6 Jun 2023 16:27:45 +0300 Subject: [PATCH 1/7] Updating search feature --- SearchHistory/templates/html/search.html | 15 +-- SearchHistory/test_search_page.py | 21 +++- SearchHistory/urls.py | 6 +- SearchHistory/views.py | 46 +++------ static/css/newSearch.css | 125 +++++++++++++++++++++++ static/css/search.css | 6 +- 6 files changed, 173 insertions(+), 46 deletions(-) create mode 100644 static/css/newSearch.css diff --git a/SearchHistory/templates/html/search.html b/SearchHistory/templates/html/search.html index 4083377..527f4f4 100644 --- a/SearchHistory/templates/html/search.html +++ b/SearchHistory/templates/html/search.html @@ -1,11 +1,14 @@ +{% extends 'landing/base.html' %} {% load static %} -{% block stylesheets %} - - +{% block head_content %} + + + + {% endblock %} {% block content %} @@ -30,7 +33,6 @@
- @@ -44,14 +46,13 @@

First name: {{ professional.profile_id.user_id.first_name }}

Last name: {{ professional.profile_id.user_id.last_name }}

City: {{ professional.profile_id.city }}

-
+ {% csrf_token %} -
diff --git a/SearchHistory/test_search_page.py b/SearchHistory/test_search_page.py index 9a48171..19e314b 100644 --- a/SearchHistory/test_search_page.py +++ b/SearchHistory/test_search_page.py @@ -1,9 +1,11 @@ from account.models.professional import Professional +from reservation.models import TypeOfJob from django.urls import reverse import pytest +from account.tests.urls_tests.test_general import PROFILE_URL CLIENT_ID = 2 - +PROFESSIONAL_ID = 2 @pytest.mark.django_db def test_search_page(client): @@ -27,8 +29,7 @@ def test_search_by_professional_id(client, make_professional): professional = make_professional() url = reverse('search history', args=[CLIENT_ID]) data = { - 'professional_id': professional.professional_id, - 'opened': '0', + 'professional_id': professional.professional_id } response = client.post(url, data) @@ -42,3 +43,17 @@ def test_search_by_professional_id(client, make_professional): assert professionals[0].profile_id.user_id.first_name == professional.profile_id.user_id.first_name assert professionals[0].profile_id.user_id.last_name == professional.profile_id.user_id.last_name assert professionals[0].profile_id.city == professional.profile_id.city + +# @pytest.mark.django_db +# def test_redirection_to_professional_page(client, make_professional): +# professional = make_professional() +# typeOfjobs_by_pro = TypeOfJob.get_typeofjobs_by_professional(professional_id=professional.professional_id) +# url = reverse('show professional', args=[PROFESSIONAL_ID]) +# data = { +# 'professional': professional, 'typeOfjobs_by_pro': typeOfjobs_by_pro +# } + +# response = client.post(url, data) + +# assert response.status_code == 200 +# assert 'account/profile.html' in response.templates[0].name diff --git a/SearchHistory/urls.py b/SearchHistory/urls.py index 9c4b856..4c458e5 100644 --- a/SearchHistory/urls.py +++ b/SearchHistory/urls.py @@ -1,9 +1,9 @@ from django.urls import path from . import views +from account.views.profile_views import show_business_page urlpatterns = [ - path('search//', views.search, name='search history') - # path('create_search_history/', views.create_search_history, name='create_search_history') - + path('search//', views.search, name='search history'), + path('profile/professional//', show_business_page, name='show professional') ] diff --git a/SearchHistory/views.py b/SearchHistory/views.py index eb12afb..13d963c 100644 --- a/SearchHistory/views.py +++ b/SearchHistory/views.py @@ -1,6 +1,5 @@ -from django.shortcuts import render +from django.shortcuts import render, get_object_or_404 from account.models.professional import Professional -from account.models.client import Client from django.db.models import Q from SearchHistory.models import SearchHistory @@ -19,36 +18,23 @@ def search(request, user_id): return render(request, 'html/search.html', context=context) elif request.method == 'POST': - if request.POST.get("opened", "") == '0': - - professionals = Professional.objects.all() - - professional_id = request.POST.get("professional_id", "") - profession = request.POST.get("profession", "") - first_name = request.POST.get("first_name", "") - last_name = request.POST.get("last_name", "") - city = request.POST.get("city", "") - - professionals = professionals.filter( - Q(professional_id=professional_id) if professional_id else Q(), - Q(profession=profession) if profession else Q(), - Q(profile_id__user_id__first_name=first_name) if first_name else Q(), - Q(profile_id__user_id__last_name=last_name) if last_name else Q(), - Q(profile_id__city=city) if city else Q() - ) - - if not professionals.exists(): - professionals = [] - + professionals = Professional.objects.all() + professional_id = request.POST.get("professional_id", "") + profession = request.POST.get("profession", "") + first_name = request.POST.get("first_name", "") + last_name = request.POST.get("last_name", "") + city = request.POST.get("city", "") + professionals = professionals.filter( + Q(professional_id=professional_id) if professional_id else Q(), + Q(profession=profession) if profession else Q(), + Q(profile_id__user_id__first_name=first_name) if first_name else Q(), + Q(profile_id__user_id__last_name=last_name) if last_name else Q(), + Q(profile_id__city=city) if city else Q() + ) + if not professionals.exists(): + professionals = [] context = { 'professionals': professionals, 'last_searches': last_searches, } - - if request.POST.get("opened", "") == '1': - professional_id = request.POST.get("search_results_professional_id", "") - professional = Professional.filter_by_professional_id(professional_id) - client = Client.filter_by_client_id(user_id) - SearchHistory.create_new_search_history(client[0], professional[0]) - return render(request, 'html/search.html', context=context) diff --git a/static/css/newSearch.css b/static/css/newSearch.css new file mode 100644 index 0000000..6633719 --- /dev/null +++ b/static/css/newSearch.css @@ -0,0 +1,125 @@ +.container { + max-width: 800px; + margin: 0 auto; + padding: 20px; + display: grid; + grid-template-columns: 1fr 2fr 1fr; + grid-gap: 20px; +} + +.filters { + grid-column: 1; +} + +.filters .head-line-label { + font-weight: bold; + margin-bottom: 10px; +} + +.filter-box { + margin-bottom: 10px; +} + +input[type="number"], +input[type="text"] { + width: 100%; + padding: 8px; + border: 1px solid #ccc; + border-radius: 4px; +} + +.search-btn { + padding: 10px 20px; + background-color: #02080f; + color: #fff; + border: none; + border-radius: 4px; + cursor: pointer; +} + +.search-results { + grid-column: 2; +} + +.search-results .head-line-label { + font-weight: bold; + margin-bottom: 10px; +} + +.professional-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + grid-gap: 20px; +} + +.professional-box { + padding: 10px; + border: 1px solid #ccc; + border-radius: 4px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + transition: box-shadow 0.3s; + cursor: pointer; + text-align: center; +} + +.professional-box:hover { + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +.professional-box h3 { + margin-top: 0; + font-size: 24px; +} + +.professional-box p { + margin-top: 5px; + font-size: 16px; + color: #666; +} + +.search-history { + grid-column: 3; + } + +.search-history-box { + width: 100%; + margin-bottom: 5px; + padding: 1px; + border-radius: 5px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + transition: box-shadow 0.3s; + cursor: pointer; + text-align: center; +} + +.search-history-box p { + margin-top: 2px; + font-size: 16px; + color: #666; +} + +.search-history-box h3 { + margin-top: 0; + font-size: 12px; +} + +.search-history-box:hover { + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +.search-history .head-line-label { + font-weight: bold; + margin-bottom: 10px; +} + +.search-history-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + grid-gap: 20px; +} + +.search-history-box { + padding: 10px; + border: 1px solid #ccc; + border-radius: 4px; +} diff --git a/static/css/search.css b/static/css/search.css index 39f33e6..92b04fd 100644 --- a/static/css/search.css +++ b/static/css/search.css @@ -63,8 +63,8 @@ body { } .search-btn { - background-color: #6976eb; - color: white; + background-color: #04061b; + color: rgb(24, 3, 3); padding: 10px; border: none; border-radius: 5px; @@ -143,7 +143,7 @@ body { } .search-btn { - background-color: #009688; + background-color: #dfebea; } .professional-box { From 48a903012685896b5babb85921931c825f5720f3 Mon Sep 17 00:00:00 2001 From: Ido Yekutiel Date: Tue, 6 Jun 2023 16:27:45 +0300 Subject: [PATCH 2/7] Updating search feature --- SearchHistory/templates/html/search.html | 15 ++- SearchHistory/test_search_page.py | 21 ++- SearchHistory/urls.py | 6 +- SearchHistory/views.py | 46 +++---- static/css/search.css | 156 ----------------------- static/css/search_page.css | 125 ++++++++++++++++++ 6 files changed, 170 insertions(+), 199 deletions(-) delete mode 100644 static/css/search.css create mode 100644 static/css/search_page.css diff --git a/SearchHistory/templates/html/search.html b/SearchHistory/templates/html/search.html index 4083377..04d1407 100644 --- a/SearchHistory/templates/html/search.html +++ b/SearchHistory/templates/html/search.html @@ -1,11 +1,14 @@ +{% extends 'landing/base.html' %} {% load static %} -{% block stylesheets %} - - +{% block head_content %} + + + + {% endblock %} {% block content %} @@ -30,7 +33,6 @@
- @@ -44,14 +46,13 @@

First name: {{ professional.profile_id.user_id.first_name }}

Last name: {{ professional.profile_id.user_id.last_name }}

City: {{ professional.profile_id.city }}

-
+ {% csrf_token %} -
diff --git a/SearchHistory/test_search_page.py b/SearchHistory/test_search_page.py index 9a48171..19e314b 100644 --- a/SearchHistory/test_search_page.py +++ b/SearchHistory/test_search_page.py @@ -1,9 +1,11 @@ from account.models.professional import Professional +from reservation.models import TypeOfJob from django.urls import reverse import pytest +from account.tests.urls_tests.test_general import PROFILE_URL CLIENT_ID = 2 - +PROFESSIONAL_ID = 2 @pytest.mark.django_db def test_search_page(client): @@ -27,8 +29,7 @@ def test_search_by_professional_id(client, make_professional): professional = make_professional() url = reverse('search history', args=[CLIENT_ID]) data = { - 'professional_id': professional.professional_id, - 'opened': '0', + 'professional_id': professional.professional_id } response = client.post(url, data) @@ -42,3 +43,17 @@ def test_search_by_professional_id(client, make_professional): assert professionals[0].profile_id.user_id.first_name == professional.profile_id.user_id.first_name assert professionals[0].profile_id.user_id.last_name == professional.profile_id.user_id.last_name assert professionals[0].profile_id.city == professional.profile_id.city + +# @pytest.mark.django_db +# def test_redirection_to_professional_page(client, make_professional): +# professional = make_professional() +# typeOfjobs_by_pro = TypeOfJob.get_typeofjobs_by_professional(professional_id=professional.professional_id) +# url = reverse('show professional', args=[PROFESSIONAL_ID]) +# data = { +# 'professional': professional, 'typeOfjobs_by_pro': typeOfjobs_by_pro +# } + +# response = client.post(url, data) + +# assert response.status_code == 200 +# assert 'account/profile.html' in response.templates[0].name diff --git a/SearchHistory/urls.py b/SearchHistory/urls.py index 9c4b856..4c458e5 100644 --- a/SearchHistory/urls.py +++ b/SearchHistory/urls.py @@ -1,9 +1,9 @@ from django.urls import path from . import views +from account.views.profile_views import show_business_page urlpatterns = [ - path('search//', views.search, name='search history') - # path('create_search_history/', views.create_search_history, name='create_search_history') - + path('search//', views.search, name='search history'), + path('profile/professional//', show_business_page, name='show professional') ] diff --git a/SearchHistory/views.py b/SearchHistory/views.py index eb12afb..13d963c 100644 --- a/SearchHistory/views.py +++ b/SearchHistory/views.py @@ -1,6 +1,5 @@ -from django.shortcuts import render +from django.shortcuts import render, get_object_or_404 from account.models.professional import Professional -from account.models.client import Client from django.db.models import Q from SearchHistory.models import SearchHistory @@ -19,36 +18,23 @@ def search(request, user_id): return render(request, 'html/search.html', context=context) elif request.method == 'POST': - if request.POST.get("opened", "") == '0': - - professionals = Professional.objects.all() - - professional_id = request.POST.get("professional_id", "") - profession = request.POST.get("profession", "") - first_name = request.POST.get("first_name", "") - last_name = request.POST.get("last_name", "") - city = request.POST.get("city", "") - - professionals = professionals.filter( - Q(professional_id=professional_id) if professional_id else Q(), - Q(profession=profession) if profession else Q(), - Q(profile_id__user_id__first_name=first_name) if first_name else Q(), - Q(profile_id__user_id__last_name=last_name) if last_name else Q(), - Q(profile_id__city=city) if city else Q() - ) - - if not professionals.exists(): - professionals = [] - + professionals = Professional.objects.all() + professional_id = request.POST.get("professional_id", "") + profession = request.POST.get("profession", "") + first_name = request.POST.get("first_name", "") + last_name = request.POST.get("last_name", "") + city = request.POST.get("city", "") + professionals = professionals.filter( + Q(professional_id=professional_id) if professional_id else Q(), + Q(profession=profession) if profession else Q(), + Q(profile_id__user_id__first_name=first_name) if first_name else Q(), + Q(profile_id__user_id__last_name=last_name) if last_name else Q(), + Q(profile_id__city=city) if city else Q() + ) + if not professionals.exists(): + professionals = [] context = { 'professionals': professionals, 'last_searches': last_searches, } - - if request.POST.get("opened", "") == '1': - professional_id = request.POST.get("search_results_professional_id", "") - professional = Professional.filter_by_professional_id(professional_id) - client = Client.filter_by_client_id(user_id) - SearchHistory.create_new_search_history(client[0], professional[0]) - return render(request, 'html/search.html', context=context) diff --git a/static/css/search.css b/static/css/search.css deleted file mode 100644 index 39f33e6..0000000 --- a/static/css/search.css +++ /dev/null @@ -1,156 +0,0 @@ -body { - background-color: #e0f2f1; - color: #263238; - } - -.container { - display: flex; - flex-direction: row; - justify-content: space-between; - margin: 20px; -} - -.filters { - flex-basis: 30%; - display: flex; - flex-direction: column; - align-items: center; -} - -.search-results { - flex-basis: 65%; -} - -.filter-box { - margin-bottom: 10px; -} - -.filter-label { - display: block; - font-weight: normal; - font-size: 15px; -} - -.head-line-label { - display: block; - font-weight: bold; - font-size: 20px; - margin-bottom: 25px; - text-align: center; -} - -.filter-input { - width: 100%; - padding: 5px; - border-radius: 5px; - border: 1px solid #ccc; - font-size: 16px; -} - -.search-box { - display: flex; - flex-direction: row; - align-items: center; - background-color: #eee; - padding: 10px; - border-radius: 5px; - margin-bottom: 20px; -} - -.search-box input[type="text"] { - flex-grow: 1; - margin-right: 10px; -} - -.search-btn { - background-color: #6976eb; - color: white; - padding: 10px; - border: none; - border-radius: 5px; - cursor: pointer; - font-size: 16px; - margin-top: 12px; -} - -.professional-box { - background-color: #fff; - padding: 10px; - border-radius: 5px; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); - transition: box-shadow 0.3s; - cursor: pointer; - text-align: center; -} - -.professional-box:hover { - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); -} - -.professional-box h3 { - margin-top: 0; - font-size: 24px; -} - -.professional-box p { - margin-top: 5px; - font-size: 16px; - color: #666; -} - -.professional-grid { - display: grid; - grid-template-columns: repeat(2, 1fr); - grid-gap: 20px; -} - -.search-history-grid { - display: grid; - grid-template-columns: 1fr; - grid-gap: 10px; - align-items: center; -} - -.search-history-box { - width: 100%; - margin-bottom: 5px; - background-color: #c5c5da; - padding: 1px; - border-radius: 5px; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); - transition: box-shadow 0.3s; - cursor: pointer; - text-align: center; -} - -.search-history-box p { - margin-top: 2px; - font-size: 16px; - color: #666; -} - -.search-history-box h3 { - margin-top: 0; - font-size: 12px; -} - -.search-history-box:hover { - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); -} - -.search-box { - background-color: #e6e6fa; -} - -.search-btn { - background-color: #009688; -} - -.professional-box { - background-color: #e6e6fa; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); -} - -.professional-box:hover { - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); -} \ No newline at end of file diff --git a/static/css/search_page.css b/static/css/search_page.css new file mode 100644 index 0000000..6633719 --- /dev/null +++ b/static/css/search_page.css @@ -0,0 +1,125 @@ +.container { + max-width: 800px; + margin: 0 auto; + padding: 20px; + display: grid; + grid-template-columns: 1fr 2fr 1fr; + grid-gap: 20px; +} + +.filters { + grid-column: 1; +} + +.filters .head-line-label { + font-weight: bold; + margin-bottom: 10px; +} + +.filter-box { + margin-bottom: 10px; +} + +input[type="number"], +input[type="text"] { + width: 100%; + padding: 8px; + border: 1px solid #ccc; + border-radius: 4px; +} + +.search-btn { + padding: 10px 20px; + background-color: #02080f; + color: #fff; + border: none; + border-radius: 4px; + cursor: pointer; +} + +.search-results { + grid-column: 2; +} + +.search-results .head-line-label { + font-weight: bold; + margin-bottom: 10px; +} + +.professional-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + grid-gap: 20px; +} + +.professional-box { + padding: 10px; + border: 1px solid #ccc; + border-radius: 4px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + transition: box-shadow 0.3s; + cursor: pointer; + text-align: center; +} + +.professional-box:hover { + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +.professional-box h3 { + margin-top: 0; + font-size: 24px; +} + +.professional-box p { + margin-top: 5px; + font-size: 16px; + color: #666; +} + +.search-history { + grid-column: 3; + } + +.search-history-box { + width: 100%; + margin-bottom: 5px; + padding: 1px; + border-radius: 5px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + transition: box-shadow 0.3s; + cursor: pointer; + text-align: center; +} + +.search-history-box p { + margin-top: 2px; + font-size: 16px; + color: #666; +} + +.search-history-box h3 { + margin-top: 0; + font-size: 12px; +} + +.search-history-box:hover { + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +.search-history .head-line-label { + font-weight: bold; + margin-bottom: 10px; +} + +.search-history-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + grid-gap: 20px; +} + +.search-history-box { + padding: 10px; + border: 1px solid #ccc; + border-radius: 4px; +} From 9a7d43ba89fe3658606da6d6fa5b332a3714c50c Mon Sep 17 00:00:00 2001 From: Ido Yekutiel Date: Wed, 7 Jun 2023 13:53:14 +0300 Subject: [PATCH 3/7] Updated html and css Signed-off-by: Ido Yekutiel --- SearchHistory/templates/html/search.html | 9 +++------ static/css/search_page.css | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/SearchHistory/templates/html/search.html b/SearchHistory/templates/html/search.html index 04d1407..57104cc 100644 --- a/SearchHistory/templates/html/search.html +++ b/SearchHistory/templates/html/search.html @@ -1,9 +1,7 @@ - - -{% extends 'landing/base.html' %} +{% extends 'account/profile.html' %} {% load static %} -{% block head_content %} +{% block head_content2 %} {% endblock %} -{% block content %} +{% block center-content %}
{% endblock %} - \ No newline at end of file diff --git a/static/css/search_page.css b/static/css/search_page.css index 6633719..0beefef 100644 --- a/static/css/search_page.css +++ b/static/css/search_page.css @@ -3,7 +3,7 @@ margin: 0 auto; padding: 20px; display: grid; - grid-template-columns: 1fr 2fr 1fr; + grid-template-columns: 1fr 3fr 1fr; grid-gap: 20px; } @@ -49,6 +49,7 @@ input[type="text"] { .professional-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + grid-gap: 20px; } From d4110b1d655d6b0a253a51e51af6d4be7dc5c9e6 Mon Sep 17 00:00:00 2001 From: Ido Yekutiel Date: Thu, 8 Jun 2023 14:01:44 +0300 Subject: [PATCH 4/7] Updating test_search_page.py Signed-off-by: Ido Yekutiel --- SearchHistory/test_search_page.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/SearchHistory/test_search_page.py b/SearchHistory/test_search_page.py index 672bdf0..1cfe8aa 100644 --- a/SearchHistory/test_search_page.py +++ b/SearchHistory/test_search_page.py @@ -1,8 +1,7 @@ from account.models.professional import Professional -# from reservation.models import TypeOfJob +from reservation.models import TypeOfJob from django.urls import reverse import pytest -# from account.tests.urls_tests.test_general import PROFILE_URL CLIENT_ID = 2 PROFESSIONAL_ID = 2 @@ -45,16 +44,18 @@ def test_search_by_professional_id(client, make_professional): assert professionals[0].profile_id.user_id.last_name == professional.profile_id.user_id.last_name assert professionals[0].profile_id.city == professional.profile_id.city -# @pytest.mark.django_db -# def test_redirection_to_professional_page(client, make_professional): -# professional = make_professional() -# typeOfjobs_by_pro = TypeOfJob.get_typeofjobs_by_professional(professional_id=professional.professional_id) -# url = reverse('show professional', args=[PROFESSIONAL_ID]) -# data = { -# 'professional': professional, 'typeOfjobs_by_pro': typeOfjobs_by_pro -# } -# response = client.post(url, data) +@pytest.mark.django_db +def test_redirection_to_professional_page(client, make_professional): + professional = make_professional() + typeOfjobs_by_pro = TypeOfJob.get_typeofjobs_by_professional(professional_id=professional.professional_id) + client.force_login(professional.profile_id.user_id) + url = reverse('show professional', args=[PROFESSIONAL_ID]) + data = { + 'professional': professional, 'typeOfjobs_by_pro': typeOfjobs_by_pro + } -# assert response.status_code == 200 -# assert 'account/profile.html' in response.templates[0].name + response = client.post(url, data) + + assert response.status_code == 200 + assert 'account/business_page.html' in response.templates[0].name From 949addd8a05ea8daceda7dfdd7b0914b052f3706 Mon Sep 17 00:00:00 2001 From: Ido Yekutiel Date: Thu, 8 Jun 2023 18:35:30 +0300 Subject: [PATCH 5/7] Fixing test --- SearchHistory/test_search_page.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SearchHistory/test_search_page.py b/SearchHistory/test_search_page.py index 1cfe8aa..809a295 100644 --- a/SearchHistory/test_search_page.py +++ b/SearchHistory/test_search_page.py @@ -50,7 +50,7 @@ def test_redirection_to_professional_page(client, make_professional): professional = make_professional() typeOfjobs_by_pro = TypeOfJob.get_typeofjobs_by_professional(professional_id=professional.professional_id) client.force_login(professional.profile_id.user_id) - url = reverse('show professional', args=[PROFESSIONAL_ID]) + url = reverse('show professional', kwargs={'professional_id': professional.professional_id}) data = { 'professional': professional, 'typeOfjobs_by_pro': typeOfjobs_by_pro } @@ -58,4 +58,10 @@ def test_redirection_to_professional_page(client, make_professional): response = client.post(url, data) assert response.status_code == 200 - assert 'account/business_page.html' in response.templates[0].name + assert 'account/business_page.html' in [template.name for template in response.templates] + returned_professional = response.context.get("professional") + assert returned_professional == professional + assert f"{professional.profession}" in response.content.decode('utf-8') + assert f"{professional.description}" in response.content.decode('utf-8') + assert f"{professional.profile_id.user_id.first_name}" in response.content.decode('utf-8') + assert f"{professional.profile_id.user_id.last_name}" in response.content.decode('utf-8') From a326829f9bf1408234447a8dce3e9d4ef4b308a2 Mon Sep 17 00:00:00 2001 From: Ido Yekutiel Date: Thu, 8 Jun 2023 18:43:16 +0300 Subject: [PATCH 6/7] Fixing test --- SearchHistory/test_search_page.py | 1 - 1 file changed, 1 deletion(-) diff --git a/SearchHistory/test_search_page.py b/SearchHistory/test_search_page.py index 809a295..4e6c5da 100644 --- a/SearchHistory/test_search_page.py +++ b/SearchHistory/test_search_page.py @@ -4,7 +4,6 @@ import pytest CLIENT_ID = 2 -PROFESSIONAL_ID = 2 @pytest.mark.django_db From 37e539d3e5b9656471ddb37567c2008fc8664c05 Mon Sep 17 00:00:00 2001 From: Ido Yekutiel Date: Thu, 8 Jun 2023 18:53:44 +0300 Subject: [PATCH 7/7] Fixing test --- SearchHistory/test_search_page.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SearchHistory/test_search_page.py b/SearchHistory/test_search_page.py index 4e6c5da..8dcc6bd 100644 --- a/SearchHistory/test_search_page.py +++ b/SearchHistory/test_search_page.py @@ -60,7 +60,7 @@ def test_redirection_to_professional_page(client, make_professional): assert 'account/business_page.html' in [template.name for template in response.templates] returned_professional = response.context.get("professional") assert returned_professional == professional - assert f"{professional.profession}" in response.content.decode('utf-8') + assert f"{professional.get_profession_display()}" in response.content.decode('utf-8') assert f"{professional.description}" in response.content.decode('utf-8') assert f"{professional.profile_id.user_id.first_name}" in response.content.decode('utf-8') assert f"{professional.profile_id.user_id.last_name}" in response.content.decode('utf-8')