Skip to content

Commit

Permalink
Contact form submission
Browse files Browse the repository at this point in the history
  • Loading branch information
bradtraversy committed Sep 30, 2018
1 parent e4ce3f0 commit 9c16170
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
22 changes: 20 additions & 2 deletions contacts/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.contrib import messages
from .models import Contact

def contact(request):
return
if request.method == 'POST':
listing_id = request.POST['listing_id']
listing = request.POST['listing']
name = request.POST['name']
email = request.POST['email']
phone = request.POST['phone']
message = request.POST['message']
user_id = request.POST['user_id']
realtor_email = request.POST['realtor_email']

contact = Contact(listing=listing, listing_id=listing_id, name=name, email=email, phone=phone, message=message, user_id=user_id )

contact.save()

messages.success(request, 'Your request has been submitted, a realtor will get back to you soon')
return redirect('/listings/'+listing_id)

5 changes: 4 additions & 1 deletion templates/listings/listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ <h1 class="display-4">{{ listing.title }}</h1>
</div>
</section>

<!-- Alerts -->
{% include 'partials/_alerts.html' %}

<!-- Listing -->
<section id="listing" class="py-4">
<div class="container">
Expand Down Expand Up @@ -179,7 +182,7 @@ <h5 class="modal-title" id="inquiryModalLabel">Make An Inquiry</h5>
<input type="hidden" name="listing_id" value="{{ listing.id }}">
<div class="form-group">
<label for="property_name" class="col-form-label">Property:</label>
<input type="text" name="listing" class="form-control" value="{{ listing.title }}" disabled>
<input type="text" name="listing" class="form-control" value="{{ listing.title }}">
</div>
<div class="form-group">
<label for="name" class="col-form-label">Name:</label>
Expand Down

0 comments on commit 9c16170

Please sign in to comment.