-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When the dog owner is logged in to Hotails, or when the home is pressed via navbar, All the daycares in the database will be shown to the dog owner on its homepage, with the possibility to check their profile. If the daycare doesn't have any profile picture, a default one will be presented. Signed-off-by: Ofir Matasas <[email protected]> Signed-off-by: tamirmatok <[email protected]>
- Loading branch information
1 parent
3a78ab0
commit 2f16f00
Showing
10 changed files
with
141 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# from django.shortcuts import render | ||
from django.shortcuts import render | ||
from django.contrib.auth.decorators import login_required | ||
|
||
# Create your views here. | ||
|
||
@login_required() | ||
def day_care_home(request): | ||
return render(request, 'main/homepage.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% extends "main/base_template.html" %} | ||
{% load static %} | ||
|
||
{% block stylesheets %} | ||
<link rel="stylesheet" href="{% static 'CSS/dog_owner_homepage.css' %}"> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row row-cols-1 g-3 cards"> | ||
<div style="display: flex; flex-direction: row; flex-wrap: wrap"> | ||
{% for daycare in daycares %} | ||
<div class="card"> | ||
<img src="{{ daycare.get_daycare_primary_image_url }}" alt="{{ daycare.name }} image" class="card-img-top"> | ||
<div class="card-body"> | ||
<div style="display: flex; flex-direction: row"> | ||
<h5 class="card-title">{{ daycare.name }}</h5> | ||
</div> | ||
<p class="card-text">{{ daycare.description | truncatechars:250 }}</p> | ||
<a href="/daycare/{{ daycare.id }}" class="btn btn-primary">Daycare Profile</a> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
# from django.shortcuts import render | ||
from django.contrib.auth.decorators import login_required | ||
from django.shortcuts import render | ||
from daycare.models import DayCare | ||
|
||
# Create your views here. | ||
|
||
@login_required() | ||
def dog_owner_home(request): | ||
context = { | ||
'daycares': DayCare.objects.all(), | ||
} | ||
return render(request, 'dogowner/dog_owner_homepage.html', context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
import pytest | ||
from daycare.models import DayCare | ||
from dogowner.models import DogOwner | ||
|
||
|
||
@pytest.fixture | ||
def create_dog_owner_user(): | ||
return DogOwner.create(email='[email protected]', | ||
username='dogOwnerUser01', | ||
password='password123', | ||
dog_name='dog name', | ||
first_name='test', | ||
last_name='user', | ||
phone_number=1234567890, | ||
dog_race='dog race', | ||
dog_picture_url='https://www.google.com/user1.jpg', | ||
dog_age=4, | ||
dog_weight=2, | ||
dog_gender='M' | ||
) | ||
return DogOwner.create(email='[email protected]', username='dogOwnerUser01', password='password123', | ||
dog_name='dog name', first_name='test', last_name='user', phone_number=1234567890, | ||
dog_race='dog race', dog_picture_url='https://www.google.com/user1.jpg', | ||
dog_age=4, dog_weight=2, dog_gender='M') | ||
|
||
|
||
@pytest.fixture | ||
def create_daycare_user(): | ||
return DayCare.create(email="[email protected]", username="testuser01", password="pass", name="Puppies", | ||
description="This is the first daycare test", price_per_day=10, | ||
capacity=50, area="Merkaz", city="Tel-Aviv", address="The best street 5") | ||
|
||
|
||
@pytest.mark.django_db | ||
|
@@ -82,8 +81,20 @@ def test_root_entrypoint_redirection_logged_user(self, client, create_dog_owner_ | |
assert response['Location'] == '/homepage/' | ||
|
||
|
||
@pytest.mark.django_db | ||
class TestHomepageView: | ||
def test_unlogged_user_access_to_homepage(self, client): | ||
response = client.get("/homepage/") | ||
assert response.status_code == 302 | ||
assert response['Location'] == '/login/?next=/homepage/' | ||
|
||
def test_dog_owner_homepage_is_visible_for_dog_owner(self, client, create_dog_owner_user): | ||
client.force_login(user=create_dog_owner_user.user) | ||
response = client.get("/homepage/") | ||
assert response.status_code == 200 | ||
assert response.context['daycares'] | ||
|
||
def test_day_care_homepage_is_visible_for_day_care(self, client, create_daycare_user): | ||
client.force_login(user=create_daycare_user.user) | ||
response = client.get("/homepage/") | ||
assert response.status_code == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.urls import path | ||
from . import views | ||
|
||
urlpatterns = [ | ||
path('', views.homepage, name='homepage'), | ||
path('about/', views.about, name='about'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.cards | ||
{ | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
margin-left: 50px; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.row | ||
{ | ||
height: 30rem; | ||
width: 120rem; | ||
margin-left: 200px; | ||
} | ||
|
||
.card | ||
{ | ||
width: 18.5%; | ||
height: 30rem; | ||
margin: 60px 60px 0 60px; | ||
max-width: 100%; | ||
} | ||
|
||
.card-body | ||
{ | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.card-body .btn | ||
{ | ||
margin-right: 50%; | ||
margin-top: auto; | ||
} | ||
|
||
.card-img-top | ||
{ | ||
height: 200px; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.