Getting step two of the inquiry process to display
This commit is contained in:
parent
a07d49c49e
commit
dc74a4fc3e
5 changed files with 72 additions and 29 deletions
|
@ -3,7 +3,10 @@ from django.contrib.gis.db import models
|
||||||
from clients.models import ClientProfile
|
from clients.models import ClientProfile
|
||||||
from partners.models import Establishment
|
from partners.models import Establishment
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
class Inquiry(models.Model):
|
class Inquiry(models.Model):
|
||||||
|
uuid = models.UUIDField(default=uuid.uuid4, unique=True)
|
||||||
client = models.ForeignKey(ClientProfile, models.PROTECT, null=True, blank=True)
|
client = models.ForeignKey(ClientProfile, models.PROTECT, null=True, blank=True)
|
||||||
destination_name = models.CharField(max_length=128)
|
destination_name = models.CharField(max_length=128)
|
||||||
destination_coords = models.PointField()
|
destination_coords = models.PointField()
|
||||||
|
|
|
@ -2,11 +2,12 @@ from django.urls import path
|
||||||
|
|
||||||
from public.views import HomeView
|
from public.views import HomeView
|
||||||
|
|
||||||
from .views import InquiryCreateView
|
from .views import InquiryCreateView, InquiryUpdateView
|
||||||
|
|
||||||
app_name = "auction"
|
app_name = "auction"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('create_inquiry/', InquiryCreateView.as_view(), name="create_inquiry"),
|
path('create_inquiry/', InquiryCreateView.as_view(), name="create_inquiry"),
|
||||||
path('process_inquiry/<slug:uuid>/', HomeView.as_view(), name="process_inquiry"),
|
path('process_inquiry/<slug:uuid>/', InquiryUpdateView.as_view(), name="process_inquiry"),
|
||||||
|
path('create_payment/<slug:uuid>/', HomeView.as_view(), name="inquiry_payment"),
|
||||||
]
|
]
|
|
@ -1,4 +1,4 @@
|
||||||
from django.views.generic import CreateView
|
from django.views.generic import CreateView, UpdateView, View
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
@ -11,11 +11,16 @@ from .helpers import name_to_coords
|
||||||
|
|
||||||
class InquiryCreateView(InConstructionMixin, CreateView):
|
class InquiryCreateView(InConstructionMixin, CreateView):
|
||||||
model = Inquiry
|
model = Inquiry
|
||||||
fields = ["destination_name", "destination_coords", "budget", "arrival", "min_nights", "adults", "children"]
|
fields = ["destination_name", "budget", "arrival", "min_nights", "adults", "children"]
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
form.instance.destination_coords = self.clean_destination_coords()
|
||||||
|
form.instance.destination_radius = 0
|
||||||
|
return super().form_valid(form)
|
||||||
|
|
||||||
def form_invalid(self, form, *args, **kwargs):
|
def form_invalid(self, form, *args, **kwargs):
|
||||||
for field in form:
|
for field in form:
|
||||||
for error in field.errors:
|
for error in field.errors:
|
||||||
|
@ -24,13 +29,24 @@ class InquiryCreateView(InConstructionMixin, CreateView):
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse("auction:process_inquiry", args=(self.object.id))
|
return reverse("auction:process_inquiry", args=(self.object.uuid,))
|
||||||
|
|
||||||
def clean_destination_coords(self):
|
def clean_destination_coords(self):
|
||||||
lat = self.data.get("destination_lat", "")
|
lat = self.request.POST.get("destination_lat", "")
|
||||||
lon = self.data.get("destination_lon", "")
|
lon = self.request.POST.get("destination_lon", "")
|
||||||
|
|
||||||
if (not lat) or (not lon):
|
if (not lat) or (not lon):
|
||||||
lat, lon = name_to_coords(self.cleaned_data.get("destination_name"))
|
lat, lon = name_to_coords(self.request.POST.get("destination_name"))
|
||||||
|
|
||||||
return Point(lon, lat)
|
return Point(lon, lat)
|
||||||
|
|
||||||
|
class InquiryUpdateView(InConstructionMixin, UpdateView):
|
||||||
|
model = Inquiry
|
||||||
|
fields = ["destination_radius", "arrival", "min_nights", "budget", "adults", "children", "comment"]
|
||||||
|
template_name = "auction/process.html"
|
||||||
|
|
||||||
|
def get_object(self):
|
||||||
|
return Inquiry.objects.get(uuid=self.kwargs["uuid"])
|
||||||
|
|
||||||
|
class InquiryPaymentView(InConstructionMixin, View):
|
||||||
|
pass
|
24
public/templatetags/mapimage.py
Normal file
24
public/templatetags/mapimage.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import base64
|
||||||
|
|
||||||
|
from dbsettings.models import Setting
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def mapimage(location, zoom=8, width=348, height=250):
|
||||||
|
payload = {
|
||||||
|
'center': f"{location.y},{location.x}",
|
||||||
|
'zoom': str(zoom),
|
||||||
|
"size": "%ix%i" % (width, height),
|
||||||
|
'sensor': "false",
|
||||||
|
'key': Setting.objects.get(key="google.api.key").value # pylint: disable=no-member
|
||||||
|
}
|
||||||
|
|
||||||
|
r = requests.get('https://maps.googleapis.com/maps/api/staticmap', params=payload)
|
||||||
|
image = r.content
|
||||||
|
data_uri = 'data:image/jpg;base64,'
|
||||||
|
data_uri += base64.b64encode(image).decode().replace('\n', '')
|
||||||
|
return data_uri
|
|
@ -39,25 +39,21 @@
|
||||||
<div class="col-12 col-md-6 col-lg-12">
|
<div class="col-12 col-md-6 col-lg-12">
|
||||||
<div class="side-bar-block detail-block style2 text-center">
|
<div class="side-bar-block detail-block style2 text-center">
|
||||||
<div class="detail-img text-center">
|
<div class="detail-img text-center">
|
||||||
<img src="{% mapimage_coords object.destination_geo.y object.destination_geo.x %}" class="img-fluid" alt="detail-img"/>
|
<img src="{% mapimage object.destination_coords %}" class="img-fluid" alt="detail-img"/>
|
||||||
<div class="detail-title">
|
<div class="detail-title">
|
||||||
<h4><a href="#">{{ object.destination_name }}</a></h4>
|
<h4><a href="#">{{ object.destination_name }}</a></h4>
|
||||||
<p></p>
|
<p></p>
|
||||||
</div><!-- end detail-title -->
|
</div><!-- end detail-title -->
|
||||||
|
|
||||||
<span class="detail-price"><h4>€ {{ object.amount }} <span></h4></span>
|
<span class="detail-price"><h4>€ {{ object.budget }} <span></h4></span>
|
||||||
</div><!-- end detail-img -->
|
</div><!-- end detail-img -->
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% trans "Ankunft ab" %}</td>
|
<td>{% trans "Anreisedatum" %}</td>
|
||||||
<td>{{ object.first_date|date:"SHORT_DATE_FORMAT" }}</td>
|
<td>{{ object.arrival|date:"SHORT_DATE_FORMAT" }}</td>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>{% trans "Abreise bis" %}</td>
|
|
||||||
<td>{{ object.last_date|date:"SHORT_DATE_FORMAT" }}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% trans "Erwachsene" %}</td>
|
<td>{% trans "Erwachsene" %}</td>
|
||||||
|
@ -69,7 +65,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% trans "Gebotener Betrag" %}</td>
|
<td>{% trans "Gebotener Betrag" %}</td>
|
||||||
<td>€ {{ object.amount }}</td>
|
<td>€ {{ object.budget }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -94,7 +90,7 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="col-12 col-md-12 col-lg-7 col-xl-8 content-side">
|
<div class="col-12 col-md-12 col-lg-7 col-xl-8 content-side">
|
||||||
<form class="lg-booking-form" id="frm_booking" name="frm_booking" method="post" action="{% url "auction:post_payment" object.uuid %}">
|
<form class="lg-booking-form" id="frm_booking" name="frm_booking" method="post" action="{% url "auction:inquiry_payment" object.uuid %}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% if not request.user.is_authenticated %}
|
{% if not request.user.is_authenticated %}
|
||||||
<div class="lg-booking-form-heading">
|
<div class="lg-booking-form-heading">
|
||||||
|
@ -122,7 +118,7 @@
|
||||||
<input type="password" name="password" class=" form-control" id="id_password">
|
<input type="password" name="password" class=" form-control" id="id_password">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button id="btn_login" class="btn btn-orange btn-block" formaction="{% url "profiles:login" %}?next={{ request.path }}">{% trans "Login" %}</button>
|
<button id="btn_login" class="btn btn-orange btn-block" formaction="{% url "localauth:login" %}?next={{ request.path }}">{% trans "Login" %}</button>
|
||||||
|
|
||||||
<div class="clearfix" style="height: 50px;"></div>
|
<div class="clearfix" style="height: 50px;"></div>
|
||||||
</div><!-- end tab-login -->
|
</div><!-- end tab-login -->
|
||||||
|
@ -146,7 +142,7 @@
|
||||||
<input type="password" name="password2" class=" form-control" id="id_password2">
|
<input type="password" name="password2" class=" form-control" id="id_password2">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button id="btn_login" class="btn btn-orange btn-block" formaction="{% url "profiles:register" %}?next={{ request.path }}">{% trans "Registrieren" %}</button>
|
<button id="btn_login" class="btn btn-orange btn-block" formaction="{% url "localauth:register" %}?next={{ request.path }}">{% trans "Registrieren" %}</button>
|
||||||
|
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
@ -179,19 +175,12 @@
|
||||||
</div><!-- end row -->
|
</div><!-- end row -->
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>{% trans "Straße" %}</label>
|
<label>{% trans "Straße" %}</label>
|
||||||
<input type="text" class="form-control" id="id_address" name="address" {% if request.user.is_authenticated %}required{% else %}disabled{% endif %} value="{{ request.user.clientprofile.address }}"/>
|
<input type="text" class="form-control" id="id_address" name="address" {% if request.user.is_authenticated %}required{% else %}disabled{% endif %} value="{{ request.user.clientprofile.address }}"/>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- end columns -->
|
</div><!-- end columns -->
|
||||||
|
|
||||||
<div class="col-md-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>{% trans "Straße (Zusatz)" %}</label>
|
|
||||||
<input type="text" class="form-control" id="id_address2" name="address2" {% if request.user.is_authenticated %}{% else %}disabled{% endif %} {% if request.user.clientprofile.address2 %}value="{{ request.user.clientprofile.address2 }}"{% endif %}/>
|
|
||||||
</div>
|
|
||||||
</div><!-- end columns -->
|
|
||||||
</div><!-- end row -->
|
</div><!-- end row -->
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -246,6 +235,7 @@
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li class="nav-item active"><a class="nav-link" href="#tab-credit-card" data-toggle="tab">{% trans "Kreditkarte" %}</a></li>
|
<li class="nav-item active"><a class="nav-link" href="#tab-credit-card" data-toggle="tab">{% trans "Kreditkarte" %}</a></li>
|
||||||
<li class="nav-item"><a class="nav-link" href="#tab-paypal" data-toggle="tab">{% trans "PayPal" %}</a></li>
|
<li class="nav-item"><a class="nav-link" href="#tab-paypal" data-toggle="tab">{% trans "PayPal" %}</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="#tab-sepa" data-toggle="tab">{% trans "Überweisung" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
|
@ -267,6 +257,15 @@
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div><!-- end tab-paypal -->
|
</div><!-- end tab-paypal -->
|
||||||
|
|
||||||
|
<div id="tab-sepa" class="tab-pane">
|
||||||
|
<img src="{% static "frontend/images/paypal.png" %}" class="img-fluid" alt="sepa" />
|
||||||
|
<div class="paypal-text">
|
||||||
|
<p>{% trans "Die Daten für die Überweisung werden im nächsten Schritt angezeigt." %}</p>
|
||||||
|
</div><!-- end paypal-text -->
|
||||||
|
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div><!-- end tab-paypal -->
|
||||||
|
|
||||||
</div><!-- end tab-content -->
|
</div><!-- end tab-content -->
|
||||||
</div><!-- end payment-tabs -->
|
</div><!-- end payment-tabs -->
|
||||||
|
|
Loading…
Reference in a new issue