From 85cdd483cd886a7ded16b7c214a97c6a5d48a285 Mon Sep 17 00:00:00 2001 From: Erez Cohen Date: Thu, 7 Apr 2022 00:08:58 +0300 Subject: [PATCH] Creating dog owner homepage 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 Signed-off-by: tamirmatok --- .../dogowner/dog_owner_homepage.html | 61 ++++++++++++++----- main/views.py | 1 + orders/models.py | 11 ++-- static/CSS/dog_owner_homepage.css | 2 +- 4 files changed, 54 insertions(+), 21 deletions(-) diff --git a/dogowner/templates/dogowner/dog_owner_homepage.html b/dogowner/templates/dogowner/dog_owner_homepage.html index 8434a05..8bb9b37 100644 --- a/dogowner/templates/dogowner/dog_owner_homepage.html +++ b/dogowner/templates/dogowner/dog_owner_homepage.html @@ -1,4 +1,5 @@ {% extends "main/base_template.html" %} +{% load crispy_forms_tags %} {% load static %} {% block stylesheets %} @@ -6,21 +7,51 @@ {% endblock %} {% block content %} -
-
- {% for daycare in daycares %} -
- {{ daycare.name }} image -
-
-
{{ daycare.name }}
+ +
+
{% csrf_token %} +
+ Search for daycare: +
+ {{ form.start_date|as_crispy_field }} +
+
+ {{ form.end_date|as_crispy_field }} +
+
+ {{ form.price_per_day|as_crispy_field }} +
+
+ {{ form.area|as_crispy_field }} +
+
+ {{ form.city|as_crispy_field }} +
+
+ {{ form.name|as_crispy_field }} +
+ +
+
+
+ Found {{ day_care_queryset.count }} results for your dog! +
+ {% for daycare in day_care_queryset %} +
+ {{ daycare.name }} image +
+
+
{{ daycare.name }}
+
+

{{ daycare.area | truncatechars:20 }}

+

{{ daycare.city | truncatechars:20 }}

+

{{ daycare.price_per_day | truncatechars:20 }}

+

{{ daycare.description | truncatechars:35}}

+ Daycare Profile +
+
+ {% endfor %} +
-

{{ daycare.description | truncatechars:250 }}

- Daycare Profile -
- {% endfor %} -
-
- {% endblock %} \ No newline at end of file diff --git a/main/views.py b/main/views.py index 0808242..6728661 100644 --- a/main/views.py +++ b/main/views.py @@ -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 diff --git a/orders/models.py b/orders/models.py index 527d970..06209eb 100644 --- a/orders/models.py +++ b/orders/models.py @@ -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): diff --git a/static/CSS/dog_owner_homepage.css b/static/CSS/dog_owner_homepage.css index 7c77f17..ef9ed9c 100644 --- a/static/CSS/dog_owner_homepage.css +++ b/static/CSS/dog_owner_homepage.css @@ -38,4 +38,4 @@ .card-img-top { height: 200px; -} \ No newline at end of file +}