diff --git a/Pro4U/urls.py b/Pro4U/urls.py index 49c601d..6ada9db 100644 --- a/Pro4U/urls.py +++ b/Pro4U/urls.py @@ -29,7 +29,7 @@ path('', include('reservation.urls')), path('', include('account.urls.login_urls')), path('', include('SearchHistory.urls')), - path('', include(('account.urls.profile_urls', 'profile_urls'))), + path('', include('account.urls.profile_urls')), path('professional//reviews/', review_views.ReviewListView.as_view(model=Review, paginate_by=10), name='reviews'), path('professional//reviews/new/', review_views.ReviewCreateView.as_view(), name='review-create'), diff --git a/account/templates/account/business_page.html b/account/templates/account/business_page.html new file mode 100644 index 0000000..e0a3e97 --- /dev/null +++ b/account/templates/account/business_page.html @@ -0,0 +1,57 @@ +{% extends 'account/profile.html' %} +{% load static %} + +{% block head_content %} + + {% block head_content2 %} + {% endblock %} + + + + +{% endblock %} + +{% block title %}{{ professional.profile_id.user_id.first_name}}'s Profile{% endblock %} + +{% block center-content %} +
+
+
+
+
+ user +
+
+
{{professional.profile_id.user_id.first_name}} {{professional.profile_id.user_id.last_name}}
+ {{professional.profession}} +
+

{{professional.description}}

+
+
+ {% for typeOfjob in typeOfjobs_by_pro %} +
  • {{ typeOfjob.typeOfJob_name }} {{ typeOfjob.price }} + +
  • + {% endfor %} +
    +
    +

    The reviews will be here!

    +
    + +
    + + +
    +
    +
    +
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/account/templates/account/profile.html b/account/templates/account/profile.html index 57099f3..7566817 100644 --- a/account/templates/account/profile.html +++ b/account/templates/account/profile.html @@ -1,5 +1,3 @@ - - {% extends 'landing/base.html' %} {% load static %} @@ -12,9 +10,7 @@ integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous"> {% endblock %} - {% block title %}{{ user.first_name}}'s Profile{% endblock %} - {% block content %}
    @@ -60,7 +56,7 @@
    {{user.first_name}}
    {% elif user.profile.user_type == 'C' %}
  • diff --git a/account/tests/test_login.py b/account/tests/test_login.py index d9966a3..4f312b9 100644 --- a/account/tests/test_login.py +++ b/account/tests/test_login.py @@ -20,7 +20,7 @@ def test_sign_in_POST_valid(self, client, professional): 'password': PASSWORD, }) assert response.status_code == 302 - assert response.url == reverse('profile_urls:user_profile') + assert response.url == reverse('user_profile') def test_sign_in_POST_invalid(self, client): response = client.post('/login/', { diff --git a/account/tests/urls_tests/test_client.py b/account/tests/urls_tests/test_client.py index e9e1cf0..c080da3 100644 --- a/account/tests/urls_tests/test_client.py +++ b/account/tests/urls_tests/test_client.py @@ -1,4 +1,5 @@ import pytest +from conftest import USER_INFORMATION, PROFILE_INFORMATION from account.tests.urls_tests.test_general import PROFILE_URL @@ -13,3 +14,20 @@ def test_get_client_profile(self, client, make_client): assert f"{test_client.profile_id.user_id.first_name}'s Profile" in response.content.decode('utf-8') assert 'Search' in response.content.decode('utf-8') assert 'img/blank_profile.png' in response.content.decode('utf-8') + + def test_get_professional_business_page(self, client, make_client, make_professional): + test_client = make_client() + client.force_login(test_client.profile_id.user_id) + test_professional = make_professional(username=USER_INFORMATION.get('username')[1], + password=USER_INFORMATION.get('password')[1], + email=USER_INFORMATION.get('email')[1], + phone_number=PROFILE_INFORMATION.get('phone_number')[1]) + response = client.get(f"{PROFILE_URL}professional/{test_professional.professional_id}/") + assert response.status_code == 200 + assert 'account/business_page.html' in [template.name for template in response.templates] + returned_professional = response.context.get("professional") + assert returned_professional == test_professional + assert f"{test_professional.profession}" in response.content.decode('utf-8') + assert f"{test_professional.description}" in response.content.decode('utf-8') + assert f"{test_professional.profile_id.user_id.first_name}" in response.content.decode('utf-8') + assert f"{test_professional.profile_id.user_id.last_name}" in response.content.decode('utf-8') diff --git a/account/urls/profile_urls.py b/account/urls/profile_urls.py index a845c39..9ee5121 100644 --- a/account/urls/profile_urls.py +++ b/account/urls/profile_urls.py @@ -3,5 +3,6 @@ urlpatterns = [ + path('profile/professional//', profile_views.show_business_page, name='show_business_page'), path('profile/', profile_views.user_profile, name='user_profile'), ] diff --git a/account/views/login_views.py b/account/views/login_views.py index a5f2246..9279b32 100644 --- a/account/views/login_views.py +++ b/account/views/login_views.py @@ -19,7 +19,7 @@ def sign_in(request): if user: login(request, user) messages.success(request, f'Hi {username.title()}, welcome back!') - return redirect('profile_urls:user_profile') + return redirect('user_profile') messages.error(request, 'Invalid username or password') return render(request, 'account/login.html', {'form': form}) diff --git a/account/views/profile_views.py b/account/views/profile_views.py index 9eb5f9c..018be2c 100644 --- a/account/views/profile_views.py +++ b/account/views/profile_views.py @@ -1,7 +1,18 @@ -from django.shortcuts import render +from django.shortcuts import render, get_object_or_404 +from account.models.professional import Professional +from reservation.models import TypeOfJob def user_profile(request): if request.user.is_authenticated: return render(request, 'account/profile.html') return render(request, 'landing/homepage.html') + + +def show_business_page(request, professional_id): + if request.user.is_authenticated: + professional = get_object_or_404(Professional, pk=professional_id) + typeOfjobs_by_pro = TypeOfJob.get_typeofjobs_by_professional(professional_id=professional.professional_id) + context = {'professional': professional, 'typeOfjobs_by_pro': typeOfjobs_by_pro} + return render(request, 'account/business_page.html', context) + return render(request, 'landing/homepage.html') diff --git a/landing/templates/landing/base.html b/landing/templates/landing/base.html index 817c760..eabbca5 100644 --- a/landing/templates/landing/base.html +++ b/landing/templates/landing/base.html @@ -73,11 +73,11 @@ {% else %}
  • {% if user_id.profile_id.user_type == user_type.PROFESSIONAL.value %} - + Profile {% elif user_id.profile_id.user_type == user_type.CLIENT.value %} - + Profile {% endif %} diff --git a/landing/templates/landing/homepage.html b/landing/templates/landing/homepage.html index 083b783..8500d59 100644 --- a/landing/templates/landing/homepage.html +++ b/landing/templates/landing/homepage.html @@ -15,7 +15,7 @@ {% for professional in professionals %}