Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Business page #126

Merged
merged 4 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pro4U/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<int:pk>/reviews/', review_views.ReviewListView.as_view(model=Review, paginate_by=10),
name='reviews'),
path('professional/<int:pk>/reviews/new/', review_views.ReviewCreateView.as_view(), name='review-create'),
Expand Down
57 changes: 57 additions & 0 deletions account/templates/account/business_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{% extends 'account/profile.html' %}
{% load static %}

{% block head_content %}
<!--Add stylesheets dynamically-->
{% block head_content2 %}
{% endblock %}
<link rel="stylesheet" type="text/css" href="{% static 'css/business_page.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/profile.css' %}">
<link href=https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css rel="stylesheet"
integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src=https://kit.fontawesome.com/297bbe7878.js crossorigin="anonymous"></script>
{% endblock %}

{% block title %}{{ professional.profile_id.user_id.first_name}}'s Profile{% endblock %}

{% block center-content %}
<div class="container mt-5">
<div class="row d-flex justify-content-center">
<div class="col-md-7">
<div class="card p-3 py-4">
<div class="text-center">
<img src="{% static 'img/blank_profile.png' %}" alt="user" class="profile-photo" style="width: 150px; height: 150px;">
</div>
<div class="text-center mt-3">
<h5 class="mt-2 mb-0">{{professional.profile_id.user_id.first_name}} {{professional.profile_id.user_id.last_name}}</h5>
<span>{{professional.profession}}</span>
<div class="px-4 mt-1">
<p class="fonts">{{professional.description}} </p>
</div>
<div>
{% for typeOfjob in typeOfjobs_by_pro %}
<li><a>{{ typeOfjob.typeOfJob_name }} {{ typeOfjob.price }}</a>

</li>
{% endfor %}
</div>
<div>
<p class="fonts">The reviews will be here! </p>
</div>
<ul class="social-list">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-dribbble"></i></li>
<li><i class="fa fa-instagram"></i></li>
<li><i class="fa fa-linkedin"></i></li>
<li><i class="fa fa-google"></i></li>
</ul>
<div class="buttons">
<button class="btn btn-outline-primary px-4">Message</button>
<button class="btn btn-primary px-4 ms-3">Make Appointment</button>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
6 changes: 1 addition & 5 deletions account/templates/account/profile.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


{% extends 'landing/base.html' %}
{% load static %}

Expand All @@ -12,9 +10,7 @@
integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src=https://kit.fontawesome.com/297bbe7878.js crossorigin="anonymous"></script>
{% endblock %}

{% block title %}{{ user.first_name}}'s Profile{% endblock %}

{% block content %}
<div>
<div class="container-fluid" style="margin-top: 50px; float: left; width: 30">
Expand Down Expand Up @@ -60,7 +56,7 @@ <h5><a href="#" class="text-white">{{user.first_name}}</a></h5>
</div></div></li>
{% elif user.profile.user_type == 'C' %}
<li><i class="fa fa-search"></i><div><div class="litext">
<a href="{% url 'calendar'%}">
<a href="#">
Search
</a>
</div></div></li>
Expand Down
2 changes: 1 addition & 1 deletion account/tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/', {
Expand Down
18 changes: 18 additions & 0 deletions account/tests/urls_tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from conftest import USER_INFORMATION, PROFILE_INFORMATION
from account.tests.urls_tests.test_general import PROFILE_URL


Expand All @@ -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')
1 change: 1 addition & 0 deletions account/urls/profile_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@


urlpatterns = [
path('profile/professional/<int:professional_id>/', profile_views.show_business_page, name='show_business_page'),
path('profile/', profile_views.user_profile, name='user_profile'),
]
2 changes: 1 addition & 1 deletion account/views/login_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
13 changes: 12 additions & 1 deletion account/views/profile_views.py
Original file line number Diff line number Diff line change
@@ -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')
4 changes: 2 additions & 2 deletions landing/templates/landing/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@
{% else %}
<li>
{% if user_id.profile_id.user_type == user_type.PROFESSIONAL.value %}
<a class="dropdown-item" href="{% url 'professional_urls:show_profile' professional_id=user_id.professional_id %}">
<a class="dropdown-item" href="{% url 'user_profile' entity_id=user_id.professional_id %}">
Profile
</a>
{% elif user_id.profile_id.user_type == user_type.CLIENT.value %}
<a class="dropdown-item" href="{% url 'client_urls:show_profile' client_id=user_id.client_id %}">
<a class="dropdown-item" href="{% url 'user_profile' entity_id=user_id.client_id %}">
Profile
</a>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion landing/templates/landing/homepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% for professional in professionals %}
<div class="col-md-3" style="margin-bottom: 18px;">
<div style="">
<a href="#" style="text-decoration: none;">
<a href="{% url 'show_business_page' professional.professional_id %}" style="text-decoration: none;">
<!-- TODO: add link to profile -->
{% if professional.thumbnail %}
<img class="img-fluid" src="{% static professional.thumbnail %}">
Expand Down
84 changes: 84 additions & 0 deletions static/css/business_page.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
body {

background: #eee;
}

.card{
border:none;

position:relative;
overflow:hidden;
border-radius:8px;
cursor:pointer;
}

.card:before{

content:"";
position:absolute;
left:0;
top:0;
width:4px;
height:100%;
background-color:#E1BEE7;
transform:scaleY(1);
transition:all 0.5s;
transform-origin: bottom
}

.card:after{

content:"";
position:absolute;
left:0;
top:0;
width:4px;
height:100%;
background-color:rgb(255, 193, 7);
transform:scaleY(0);
transition:all 0.5s;
transform-origin: bottom
}

.card:hover::after{
transform:scaleY(1);
}


.fonts{
font-size:11px;
}

.social-list{
display:flex;
list-style:none;
justify-content:center;
padding:0;
}

.social-list li{
padding:10px;
color:rgb(255, 193, 7);
font-size:19px;
}


.buttons button:nth-child(1){
border:1px solid black !important;
color:black;
height:40px;
}

.buttons button:nth-child(1):hover{
border:1px solid black !important;
color:black;
height:40px;
background-color:rgb(255, 193, 7);
}

.buttons button:nth-child(2){
border:1px solid #8E24AA !important;
background-color:rgb(255, 193, 7);
color:black;
height:40px;
}