-
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.
Create reservation page for dog-owner user
After a dog owner user has selected the daycare he wishes to book a place for his dog, he will be directed to the daycare owner's home page where he can read more details about the daycare, and make a reservation from there. Signed-off-by: Erez Cohen <[email protected]>
- Loading branch information
1 parent
5a719c6
commit ce0284f
Showing
13 changed files
with
221 additions
and
50 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
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,11 +1,12 @@ | ||
{% extends "main/base_template.html" %} | ||
|
||
{% load crispy_forms_tags %} | ||
{% block stylesheets %} | ||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" | ||
integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous"> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
|
||
<style> | ||
/* Make the image fully responsive */ | ||
.img { | ||
|
@@ -23,17 +24,27 @@ | |
<div class="col-md-7"> | ||
<hr> | ||
<div class="mt-5 mb-5"> | ||
{% if visited_user == 'daycare' %} | ||
<h5> <i class="fas fa-user"></i> Hello {{ daycare.name }}</h5> | ||
<h6>This is where you can manage your daycare. | ||
<br> You will be able:</h6> | ||
<p class="text-muted"># Manage your booking schedule</p> | ||
<p class="text-muted"># Set filters of approved dogs and services you provide</p> | ||
<p class="text-muted"># Read / write reviews of dog owners and their dogs</p> | ||
<p class="text-muted"># Chat with dog owners</p> | ||
{% elif visited_user == 'dogowner' %} | ||
<h5> <i class="fas fa-user"></i> Welcome to {{ daycare.name }}</h5> | ||
<h6>This is where you can book an order for {{ daycare.name }} daycare | ||
<br> You will be able:</h6> | ||
<p class="text-muted"># Look at the details of the daycare</p> | ||
<p class="text-muted"># Read / write reviews of the daycare</p> | ||
<p class="text-muted"># Chat with the daycare owners</p> | ||
{% endif %} | ||
</div> | ||
<hr> | ||
<div class="mt-5"> | ||
<h5>Have a look at your reviews</h5> | ||
<div style="height: 1500px;overflow: scroll;"> | ||
<table class="table table-hover table-bordered table-responsive"> | ||
<thead class="table-dark"> | ||
<tr> | ||
|
@@ -56,6 +67,7 @@ <h5>Have a look at your reviews</h5> | |
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
@@ -115,11 +127,45 @@ <h5 class="card-title">{{daycare.address}}, {{daycare.city}}</h5> | |
<h6><i class="fas fa-dog"></i> Capacity: {{daycare.capacity}} | ||
<br> | ||
<br> | ||
<i class="fas fa-coins"></i> Price: {{daycare.price_per_day}} | ||
<i class="fas fa-coins"></i> Price Per Night: {{daycare.price_per_day}} | ||
</h6> | ||
<br> | ||
<h6><strong>About</strong></h6> | ||
<p class="card-text">{{daycare.description}}</p> | ||
{% if visited_user == 'dogowner' %} | ||
|
||
<form method='POST' action=''>{% csrf_token %} | ||
<div class="col-4" id="searchBoxArea"> | ||
<h2>Book now</h2> | ||
<div class="form-group"> | ||
{{ form.dog_name|as_crispy_field }} | ||
</div> | ||
<div class="form-group"> | ||
{{ form.email|as_crispy_field }} | ||
</div> | ||
<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.requests|as_crispy_field }} | ||
</div> | ||
<div class="form-group"> | ||
{{ form.agree_terms|as_crispy_field }} | ||
</div> | ||
<button type="submit" class="btn btn-primary">Complete Booking</button> | ||
</div> | ||
<br> | ||
{% if order == 'No Capacity' %} | ||
<h6>Failed: Your order could not be submit, there is no space available on the dates specified, please try again</h6> | ||
{% elif order != 'null' %} | ||
<h6>Your order has been successfully received and waiting for {{ daycare.name }} to approve</h6> | ||
<p class="text-muted">You can see the details of the reservation <a href="{% url 'orders' %}">here</a></p> | ||
{% endif %} | ||
</form> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
|
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,15 +1,49 @@ | ||
from django.shortcuts import render | ||
from django.contrib.auth.decorators import login_required | ||
from .models import Image | ||
from orders.models import Order | ||
from review.models import Review | ||
from daycare.models import DayCare | ||
from daycare.forms import BookForm | ||
from dogowner.models import DogOwner | ||
|
||
|
||
@login_required(login_url='login') | ||
def daycare_home(request): | ||
def daycare_home(request, daycare_id): | ||
daycare = DayCare.objects.get(pk=daycare_id) | ||
form = BookForm(request.POST or None) | ||
|
||
if DogOwner.objects.filter(user=request.user): | ||
visited_user = 'dogowner' | ||
else: | ||
visited_user = 'daycare' | ||
|
||
context = { | ||
'daycare': request.user.daycare, | ||
'reviews': Review.get_review_by_daycare_id(request.user.daycare.id), | ||
'images': Image.get_images_by_daycare_id(request.user.daycare.id) | ||
'form': form, | ||
'daycare': daycare, | ||
'visited_user': visited_user, | ||
'reviews': Review.get_review_by_daycare_id(daycare.id), | ||
'images': Image.get_images_by_daycare_id(daycare.id), | ||
'order': 'null' | ||
} | ||
|
||
if request.method == 'POST': | ||
if form.is_valid(): | ||
if Order.are_order_dates_available(daycare_id, form.cleaned_data['start_date'], | ||
form.cleaned_data['end_date']): | ||
new_order = Order.create(request.user.dogowner, DayCare.objects.get(pk=daycare_id), | ||
form.cleaned_data['start_date'], form.cleaned_data['end_date'], | ||
DayCare.objects.get(pk=daycare_id).price_per_day) | ||
else: | ||
new_order = 'No Capacity' | ||
|
||
context = { | ||
'form': form, | ||
'daycare': daycare, | ||
'visited_user': visited_user, | ||
'reviews': Review.get_review_by_daycare_id(daycare.id), | ||
'images': Image.get_images_by_daycare_id(daycare.id), | ||
'order': new_order | ||
} | ||
|
||
return render(request, 'daycare/daycare-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 |
---|---|---|
@@ -0,0 +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"> | ||
<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> | ||
</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
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,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
Oops, something went wrong.