diff --git a/daycare/models.py b/daycare/models.py index 2678d71..d21a44e 100644 --- a/daycare/models.py +++ b/daycare/models.py @@ -50,6 +50,11 @@ def create(email, username, password, name, description, price_per_day, capacity return new_daycare + def get_daycare_primary_image(self): + if Image.get_images_by_daycare_id(self.id).exists(): + return Image.get_images_by_daycare_id(self.id).first().url + return None + class Image(models.Model): url = models.CharField(max_length=1000) diff --git a/dogowner/templates/dogowner/dog_owner_homepage.html b/dogowner/templates/dogowner/dog_owner_homepage.html new file mode 100644 index 0000000..162f837 --- /dev/null +++ b/dogowner/templates/dogowner/dog_owner_homepage.html @@ -0,0 +1,26 @@ +{% extends "main/base_template.html" %} +{% load static %} + +{% block stylesheets %} + +{% endblock %} + +{% block content %} +
+
+ {% for daycare in daycares %} +
+ {{ daycare.name }} image +
+
+
{{ daycare.name }}
+
+

{{ daycare.description | truncatechars:250 }}

+ Daycare Profile +
+
+ {% endfor %} +
+
+ +{% endblock %} \ No newline at end of file diff --git a/dogowner/views.py b/dogowner/views.py index fd0e044..ff85724 100644 --- a/dogowner/views.py +++ b/dogowner/views.py @@ -1,3 +1,10 @@ -# from django.shortcuts import render +from django.shortcuts import render +from daycare.models import DayCare -# Create your views here. + +def dog_owner_home(request): + context = { + 'dogowner': request.user, + 'daycares': DayCare.objects.all(), + } + return render(request, 'dogowner/dog_owner_homepage.html', context) diff --git a/main/views.py b/main/views.py index d1e9531..571b04c 100644 --- a/main/views.py +++ b/main/views.py @@ -2,6 +2,8 @@ from django.contrib.auth.decorators import login_required from django.shortcuts import redirect from django.contrib.auth import logout +from dogowner.views import dog_owner_home +from dogowner.models import DogOwner def index(request): @@ -13,7 +15,8 @@ def index(request): @login_required() def homepage(request): - return render(request, 'main/homepage.html') + if DogOwner.objects.filter(user=request.user).exists(): + return dog_owner_home(request) def about(request): diff --git a/static/CSS/dog_owner_homepage.css b/static/CSS/dog_owner_homepage.css new file mode 100644 index 0000000..1ddc6f8 --- /dev/null +++ b/static/CSS/dog_owner_homepage.css @@ -0,0 +1,46 @@ +.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; +} + +.btn +{ + +}