Skip to content

Commit

Permalink
Creating dog owner homepage
Browse files Browse the repository at this point in the history
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
ErezCohenn committed May 12, 2022
1 parent a9d2d23 commit 85cdd48
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 21 deletions.
61 changes: 46 additions & 15 deletions dogowner/templates/dogowner/dog_owner_homepage.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,57 @@
{% extends "main/base_template.html" %}
{% load crispy_forms_tags %}
{% 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 class="row">
<form method='POST' action=''>{% csrf_token %}
<div class="col-4" id="searchBoxArea">
<span>Search for daycare:</span>
<div class="form-group">
{{ form.start_date|as_crispy_field }}
</div>
<div class="form-group">
{{ form.end_date|as_crispy_field }}
</div>
<div class="form-group">
{{ form.price_per_day|as_crispy_field }}
</div>
<div class="form-group">
{{ form.area|as_crispy_field }}
</div>
<div class="form-group">
{{ form.city|as_crispy_field }}
</div>
<div class="form-group">
{{ form.name|as_crispy_field }}
</div>
<input type="submit" value='Search' style="height:30px;width:70px">
</div>
</form>
<div class="col-10">
<span id="searchResult">Found {{ day_care_queryset.count }} results for your dog!</span>
<div class="cards">
{% for daycare in day_care_queryset %}
<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.area | truncatechars:20 }}</p>
<p class="card-text">{{ daycare.city | truncatechars:20 }}</p>
<p class="card-text">{{ daycare.price_per_day | truncatechars:20 }}</p>
<p class="card-text">{{ daycare.description | truncatechars:35}}</p>
<a href="/daycare/{{ daycare.id }}" class="btn btn-warning">Daycare Profile</a>
</div>
</div>
{% endfor %}
</div>
</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 %}
1 change: 1 addition & 0 deletions main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.contrib.auth.decorators import login_required
from django.shortcuts import redirect
from django.contrib.auth import logout
from daycare.models import DayCare
from dogowner.models import DogOwner
from daycare.models import DayCare
from dogowner.views import dog_owner_home
Expand Down
11 changes: 6 additions & 5 deletions orders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ def get_capacity_of_daycare_in_dates_range(daycare_id, start_datetime, end_datet

return capacity_per_day

def are_order_dates_available(self):
capacity_per_day: list[int] = self.get_capacity_of_daycare_in_dates_range(self.daycare_id,
self.start_date,
self.end_date)
@staticmethod
def are_order_dates_available(daycare_id, start_datetime, end_datetime):
capacity_per_day: list[int] = get_capacity_of_daycare_in_dates_range(daycare_id,
start_date,
end_date)

daycare_capacity = DayCare.objects.get(name=self.daycare_id.name).capacity
daycare_capacity = DayCare.objects.get(name=daycare_id.name).capacity
return all(current_capacity < daycare_capacity for current_capacity in capacity_per_day)

def is_the_order_cancelable(self):
Expand Down
2 changes: 1 addition & 1 deletion static/CSS/dog_owner_homepage.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
.card-img-top
{
height: 200px;
}
}

0 comments on commit 85cdd48

Please sign in to comment.