Demo notifications

Fixed a few views
Other stuff
This commit is contained in:
Kumi 2021-04-08 11:30:19 +02:00
parent 9cfe535089
commit 6d67541571
16 changed files with 216 additions and 364 deletions

16
auction/helpers.py Normal file
View file

@ -0,0 +1,16 @@
from dbsettings.functions import getValue
import requests
def name_to_coords(name, api_key=None):
URL = "https://maps.googleapis.com/maps/api/geocode/json"
api_key = api_key or getValue("google.api.key")
payload = {"address": name, "key": api_key}
response = requests.get(URL, params=payload).json()
try:
result = response["results"][0]
return result["geometry"]["location"]["lat"], result["geometry"]["location"]["lng"]
except:
raise ValueError(response)

View file

@ -4,7 +4,7 @@ from clients.models import ClientProfile
from partners.models import Establishment
class Inquiry(models.Model):
client = models.ForeignKey(ClientProfile, models.PROTECT)
client = models.ForeignKey(ClientProfile, models.PROTECT, null=True, blank=True)
destination_name = models.CharField(max_length=128)
destination_coords = models.PointField()
destination_radius = models.IntegerField()
@ -14,6 +14,7 @@ class Inquiry(models.Model):
adults = models.IntegerField()
children = models.IntegerField()
comment = models.TextField(null=True, blank=True)
active = models.BooleanField(default=False)
@property
def is_paid(self):

View file

@ -2,9 +2,11 @@ from django.urls import path
from public.views import HomeView
from .views import InquiryCreateView
app_name = "auction"
urlpatterns = [
path('create_inquiry/', HomeView.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"),
]

View file

@ -1,3 +1,34 @@
from django.shortcuts import render
from django.views.generic import CreateView
from django.shortcuts import redirect
from django.contrib import messages
from django.urls import reverse
# Create your views here.
from public.mixins import InConstructionMixin
from .models import Inquiry
class InquiryCreateView(InConstructionMixin, CreateView):
model = Inquiry
fields = ["destination_name", "destination_coords", "budget", "arrival", "min_nights", "adults", "children"]
def get(self, request, *args, **kwargs):
return redirect("/")
def form_invalid(self, form, *args, **kwargs):
for field in form:
for error in field.errors:
messages.error(self.request, f"{field.name}: {error}")
return redirect("/")
def get_success_url(self):
return reverse("auction:process_inquiry", args=(self.object.id))
def clean_destination_coords(self):
lat = self.cleaned_data.get("destination_lat", "")
lon = self.cleaned_data.get("destination_lon", "")
if (not lat) or (not lon):
lon, lat = get_coords(self.cleaned_data.get("destination_name"))
return Point(lon, lat)

View file

@ -31,4 +31,5 @@ class LoginRequiredMixin:
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
messages.info(self.request, "Um diese Seite anzuzeigen, musst du dich einloggen.")
return super().dispatch(*args, **kwargs)

View file

@ -14,7 +14,7 @@ from clients.models import ClientProfile
from partners.models import PartnerProfile
class LoginView(Login):
template_name = "localauth/register.html"
template_name = "localauth/login.html"
class LogoutView(Logout):
next_page = "/"

View file

@ -1,16 +1,25 @@
from django.views.generic import CreateView, UpdateView
from django.urls import reverse_lazy
from django.http import HttpResponseRedirect
from .models import PartnerProfile
from public.mixins import InConstructionMixin
from localauth.mixins import LoginRequiredMixin
class PartnerRegistrationView(LoginRequiredMixin, CreateView):
class PartnerRegistrationView(InConstructionMixin, LoginRequiredMixin, CreateView):
model = PartnerProfile
exclude = ["user"]
template_name = "partners/signup.html"
fields = ["company", "vat_id", "first_name", "last_name", "street", "city", "zip", "state", "country"]
def dispatch(self, request, *args, **kwargs):
try:
PartnerProfile.objects.get(user=request.user)
return HttpResponseRedirect(reverse_lazy("partners:profile"))
except (PartnerProfile.DoesNotExist, TypeError):
return super().dispatch(request, *args, **kwargs)
def form_valid(self, form):
form.instance.user = self.request.user
return super().form_valid(form)

12
public/middleware.py Normal file
View file

@ -0,0 +1,12 @@
from django.conf import settings
from django.contrib import messages
class DemoMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
if settings.DEBUG:
messages.warning(request, "Sie befinden sich auf der Demo-Instanz von JourneyJoker. Diese ist nur zu Testzwecken gedacht und möglicherweise nicht stabil.")
return self.get_response(request)

6
public/mixins.py Normal file
View file

@ -0,0 +1,6 @@
from django.contrib import messages
class InConstructionMixin:
def dispatch(self, request, *args, **kwargs):
messages.warning(request, "Die aufgerufene Seite wird aktuell bearbeitet und funktioniert möglicherweise nicht wie erwartet. Versuchen Sie es bitte später wieder oder wenden Sie sich an den Administrator, wenn dieses Problem länger besteht.")
return super().dispatch(request, *args, **kwargs)

View file

@ -7,3 +7,5 @@ pyinvoice
django-countries
paypal-checkout-serversdk
python-dateutil
qrcode
requests

View file

@ -43,6 +43,7 @@
<!-- Toastr -->
<link rel="stylesheet" href="{% static "frontend/css/toastr.min.css" %}">
{{ form.media }}
</head>

View file

@ -41,11 +41,7 @@
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs justify-content-center">
<!--<li class="nav-item active"><a class="nav-link" href="#flights" data-toggle="tab"><span><i class="fa fa-plane"></i></span><span class="d-md-inline-flex d-none st-text">Flights</span></a></li>-->
<li class="nav-item active"><a class="nav-link" onclick="return false;" href="#"><span><i class="fa fa-building"></i></span><span class="d-md-inline-flex d-none st-text">Angebote einholen</span></a></li>
<!--<li class="nav-item"><a class="nav-link" href="#tours" data-toggle="tab"><span><i class="fa fa-suitcase"></i></span><span class="d-md-inline-flex d-none st-text">Tours</span></a></li>
<li class="nav-item"><a class="nav-link" href="#cruise" data-toggle="tab"><span><i class="fa fa-ship"></i></span><span class="d-md-inline-flex d-none st-text">Cruise</span></a></li>
<li class="nav-item"><a class="nav-link" href="#cars" data-toggle="tab"><span><i class="fa fa-car"></i></span><span class="d-md-inline-flex d-none st-text">Cars</span></a></li>-->
<li class="nav-item active"><div style="background-color: white;" class="nav-link" onclick="return false;" href="#"><span><i class="fa fa-building"></i></span><span class="d-md-inline-flex d-none st-text">Angebote einholen</span></div></li>
</ul>
<div class="tab-content">
@ -68,7 +64,7 @@
<div class="col-12 col-md-6 col-lg-6">
<div class="form-group left-icon">
<input id="id_amount" name="amount" type="number" step="1" class="form-control" placeholder="{% trans "Mein Budget" %}" >
<input id="id_amount" name="amount" type="number" step="1" class="form-control" placeholder="{% trans "Budget" %}" >
<i class="fa fa-euro-sign"></i>
</div>
</div><!-- end columns -->
@ -81,15 +77,28 @@
<div class="col-6 col-md-6 col-lg-6">
<div class="form-group left-icon">
<input id="id_first_date" name="first_date" type="text" class="form-control dpd1" placeholder="{% trans "Erster Tag" %}" >
<input id="id_first_date" name="first_date" type="text" class="form-control dpd1" placeholder="{% trans "Anreise" %}" >
<i class="fa fa-calendar"></i>
</div>
</div><!-- end columns -->
<div class="col-6 col-md-6 col-lg-6">
<div class="form-group left-icon">
<input id="id_last_date" name="last_date" type="text" class="form-control dpd2" placeholder="{% trans "Letzter Tag" %}" >
<i class="fa fa-calendar"></i>
<div class="form-group right-icon">
<select id="id_adults" name="adults" class="form-control">
<option value="0" selected>{% trans "Mindestdauer" %}</option>
<option value="0">Egal!</option>
<option value="1">1 Nacht</option>
<option value="2">2 Nächte</option>
<option value="3">3 Nächte</option>
<option value="4">4 Nächte</option>
<option value="5">5 Nächte</option>
<option value="6">6 Nächte</option>
<option value="7">7 Nächte</option>
<option value="8">8 Nächte</option>
<option value="9">9 Nächte</option>
<option value="10">10 Nächte</option>
</select>
<i class="fa fa-angle-down"></i>
</div>
</div><!-- end columns -->
@ -136,273 +145,6 @@
</form>
</div><!-- end flights -->
<div id="hotels" class="tab-pane">
<form>
<div class="row">
<div class="col-12 col-md-12 col-lg-6 col-xl-5">
<div class="row">
<div class="col-12 col-md-6">
<div class="form-group left-icon">
<input type="text" class="form-control dpd1" placeholder="Check In" >
<i class="fa fa-calendar"></i>
</div>
</div><!-- end columns -->
<div class="col-12 col-md-6">
<div class="form-group left-icon">
<input type="text" class="form-control dpd2" placeholder="Check Out" >
<i class="fa fa-calendar"></i>
</div>
</div><!-- end columns -->
</div><!-- end row -->
</div><!-- end columns -->
<div class="col-12 col-md-12 col-lg-6 col-xl-5">
<div class="row">
<div class="col-12 col-md-12 col-lg-4">
<div class="form-group right-icon">
<select class="form-control">
<option selected>Rooms</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<i class="fa fa-angle-down"></i>
</div>
</div><!-- end columns -->
<div class="col-6 col-md-6 col-lg-4">
<div class="form-group right-icon">
<select class="form-control">
<option selected>Adults</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<i class="fa fa-angle-down"></i>
</div>
</div><!-- end columns -->
<div class="col-6 col-md-6 col-lg-4">
<div class="form-group right-icon">
<select class="form-control">
<option selected>Kids</option>
<option>0</option>
<option>1</option>
<option>2</option>
</select>
<i class="fa fa-angle-down"></i>
</div>
</div><!-- end columns -->
</div><!-- end row -->
</div><!-- end columns -->
<div class="col-12 col-md-12 col-lg-12 col-xl-2 search-btn">
<button class="btn btn-orange">Search</button>
</div><!-- end columns -->
</div><!-- end row -->
</form>
</div><!-- end hotels -->
<div id="tours" class="tab-pane">
<form>
<div class="row">
<div class="col-12 col-md-12 col-lg-3 col-xl-4">
<div class="form-group left-icon">
<input type="text" class="form-control" placeholder="City,Country" />
<i class="fa fa-map-marker"></i>
</div>
</div><!-- end columns -->
<div class="col-12 col-md-12 col-lg-3 col-xl-3">
<div class="form-group right-icon">
<select class="form-control">
<option selected>Monat</option>
<option>Jänner</option>
<option>Februrar</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
<i class="fa fa-angle-down"></i>
</div>
</div><!-- end columns -->
<div class="col-12 col-md-12 col-lg-6 col-xl-3">
<div class="row">
<div class="col-12 col-md-6">
<div class="form-group right-icon">
<select class="form-control">
<option selected>Adults</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<i class="fa fa-angle-down"></i>
</div>
</div><!-- end columns -->
<div class="col-12 col-md-6">
<div class="form-group right-icon">
<select class="form-control">
<option selected>Kids</option>
<option>0</option>
<option>1</option>
<option>2</option>
</select>
<i class="fa fa-angle-down"></i>
</div>
</div><!-- end columns -->
</div><!-- end row -->
</div><!-- end columns -->
<div class="col-12 col-md-12 col-lg-12 col-xl-2 search-btn">
<button class="btn btn-orange">Search</button>
</div><!-- end columns -->
</div><!-- end row -->
</form>
</div><!-- end tours -->
<div id="cruise" class="tab-pane">
<form>
<div class="row">
<div class="col-12 col-md-12 col-lg-5 col-xl-4">
<div class="row">
<div class="col-12 col-md-6 col-lg-6">
<div class="form-group left-icon">
<input id="id_destination_name" name="destination_name" type="text" class="form-control" placeholder="Ziel" >
<i class="fa fa-map-marker"></i>
</div>
</div><!-- end columns -->
<div class="col-12 col-md-6 col-lg-6">
<div class="form-group left-icon">
<input id="id_amount" name="amount" type="text" class="form-control" placeholder="Budget" >
<i class="fa fa-euro-sign"></i>
</div>
</div><!-- end columns -->
</div><!-- end row -->
</div><!-- end columns -->
<div class="col-12 col-md-12 col-lg-5 col-xl-4">
<div class="row">
<div class="col-6 col-md-6 col-lg-6">
<div class="form-group left-icon">
<input id="id_first_date" name="first_date" type="text" class="form-control dpd1" placeholder="Beginn" >
<i class="fa fa-calendar"></i>
</div>
</div><!-- end columns -->
<div class="col-6 col-md-6 col-lg-6">
<div class="form-group left-icon">
<input id="id_last_date" name="last_date" type="text" class="form-control dpd2" placeholder="Ende" >
<i class="fa fa-calendar"></i>
</div>
</div><!-- end columns -->
</div><!-- end row -->
</div><!-- end columns -->
<div class="col-12 col-md-12 col-lg-2 col-xl-2">
<div class="form-group right-icon">
<select class="form-control">
<option selected>Adults</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<i class="fa fa-angle-down"></i>
</div>
</div><!-- end columns -->
<div class="col-12 col-md-12 col-lg-12 col-xl-2 search-btn">
<button class="btn btn-orange">Search</button>
</div><!-- end columns -->
</div><!-- end columns -->
</form>
</div><!-- end cruises -->
<div id="cars" class="tab-pane">
<form>
<div class="row">
<div class="col-12 col-md-12 col-lg-7 col-xl-6">
<div class="row">
<div class="col-md-6 col-lg-4">
<div class="form-group left-icon">
<input type="text" class="form-control" placeholder="Country" />
<i class="fa fa-globe"></i>
</div>
</div><!-- end columns -->
<div class="col-md-6 col-lg-4">
<div class="form-group left-icon">
<input type="text" class="form-control" placeholder="City" />
<i class="fa fa-map-marker"></i>
</div>
</div><!-- end columns -->
<div class="col-md-12 col-lg-4">
<div class="form-group left-icon">
<input type="text" class="form-control" placeholder="Location" />
<i class="fa fa-street-view"></i>
</div>
</div><!-- end columns -->
</div><!-- end row -->
</div><!-- end columns -->
<div class="col-12 col-md-12 col-lg-5 col-xl-4">
<div class="row">
<div class="col-6 col-md-6 col-lg-6">
<div class="form-group left-icon">
<input type="text" class="form-control dpd1" placeholder="Check In" >
<i class="fa fa-calendar"></i>
</div>
</div><!-- end columns -->
<div class="col-6 col-md-6 col-lg-6">
<div class="form-group left-icon">
<input type="text" class="form-control dpd2" placeholder="Check Out" >
<i class="fa fa-calendar"></i>
</div>
</div><!-- end columns -->
</div><!-- end row -->
</div><!-- end columns -->
<div class="col-12 col-md-12 col-lg-12 col-xl-2 search-btn">
<button class="btn btn-orange">Search</button>
</div><!-- end columns -->
</div><!-- end row -->
</form>
</div><!-- end cars -->
</div><!-- end tab-content -->
</div><!-- end columns -->

View file

@ -0,0 +1,64 @@
{% load static %}
<!doctype html>
<html lang="en">
<head>
<title>JourneyJoker - {{ title }}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="{% static "frontend/images/favicon.png" %}" type="image/x-icon">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i,900,900i%7CMerriweather:300,300i,400,400i,700,700i,900,900i" rel="stylesheet">
<!-- Bootstrap Stylesheet -->
<link rel="stylesheet" href="{% static "frontend/css/bootstrap.min4.2.1.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "frontend/css/bootstrap-reboot4.2.1.css" %}">
<!-- Sidebar Stylesheet -->
<link rel="stylesheet" type="text/css" href="{% static "frontend/css/jquery.mCustomScrollbar.min.css" %}">
<!-- Font Awesome Stylesheet -->
<link rel="stylesheet" href="{% static "frontend/css/font-awesome.min.css" %}">
<!-- Custom Stylesheets -->
<link rel="stylesheet" href="{% static "frontend/css/style.css" %}">
<link rel="stylesheet" id="cpswitch" href="{% static "frontend/css/orange.css" %}">
<link rel="stylesheet" href="{% static "frontend/css/responsive.css" %}">
</head>
<body>
<!--====== LOADER =====-->
<div class="loader"></div>
<!--===== FULL-PAGE-FORM ====-->
<section>
<div class="colored-border"></div>
<div id="full-page-form">
<div class="container">
<div class="row">
<div class="col-md-12">
{% block formspace %}
{% endblock %}
<p class="full-page-copyright">© 2020 2021 <a href="https://kumi.systems/">Kumi Systems e.U.</a> All rights reserved.</p>
</div><!-- end columns -->
</div><!-- end row -->
</div><!-- end container -->
</div><!-- end full-page-form -->
<div class="colored-border"></div>
</section>
<!-- Page Scripts Starts -->
<script src="{% static "frontend/js/jquery-3.3.1.min.js" %}"></script>
<script src="{% static "frontend/js/jquery.mCustomScrollbar.concat.min.js" %}"></script>
<script src="{% static "frontend/js/bootstrap.min4.2.1.js" %}"></script>
<script src="{% static "frontend/js/custom-navigation.js" %}"></script>
<!-- Page Scripts Ends -->
</body>
</html>

View file

@ -0,0 +1,21 @@
{% extends "localauth/authbase.html" %}
{% load i18n %}
{% load bootstrap4 %}
{% block formspace %}
<div class="full-page-title">
<a href="{% url "frontend:home" %}"><h3 class="company-name"><span><i class="fa fa-plane"></i>Journey</span>Joker</h3></a>
</div><!-- end full-page-title -->
<div class="custom-form custom-form-fields">
<h3>{{ title }}</h3>
<form method="POST">
{% csrf_token %}
{% bootstrap_form form %}
<button class="btn btn-orange btn-block">{% trans "Einloggen" %}</button>
</form>
<div class="other-links">
<p class="link-line"><a href="{% url "localauth:register" %}?{{ request.GET.urlencode }}">Noch kein Account? Jetzt registrieren!</a></p>
</div><!-- end other-links -->
</div><!-- end custom-form -->
{% endblock %}

View file

@ -1,48 +1,7 @@
{% load static %}
{% extends "localauth/authbase.html" %}
{% load i18n %}
{% load bootstrap4 %}
<!doctype html>
<html lang="en">
<head>
<title>JourneyJoker - {{ title }}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="{% static "frontend/images/favicon.png" %}" type="image/x-icon">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i,900,900i%7CMerriweather:300,300i,400,400i,700,700i,900,900i" rel="stylesheet">
<!-- Bootstrap Stylesheet -->
<link rel="stylesheet" href="{% static "frontend/css/bootstrap.min4.2.1.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "frontend/css/bootstrap-reboot4.2.1.css" %}">
<!-- Sidebar Stylesheet -->
<link rel="stylesheet" type="text/css" href="{% static "frontend/css/jquery.mCustomScrollbar.min.css" %}">
<!-- Font Awesome Stylesheet -->
<link rel="stylesheet" href="{% static "frontend/css/font-awesome.min.css" %}">
<!-- Custom Stylesheets -->
<link rel="stylesheet" href="{% static "frontend/css/style.css" %}">
<link rel="stylesheet" id="cpswitch" href="{% static "frontend/css/orange.css" %}">
<link rel="stylesheet" href="{% static "frontend/css/responsive.css" %}">
</head>
<body>
<!--====== LOADER =====-->
<div class="loader"></div>
<!--===== FULL-PAGE-FORM ====-->
<section>
<div class="colored-border"></div>
<div id="full-page-form">
<div class="container">
<div class="row">
<div class="col-md-12">
{% block formspace %}
<div class="full-page-title">
<a href="{% url "frontend:home" %}"><h3 class="company-name"><span><i class="fa fa-plane"></i>Journey</span>Joker</h3></a>
</div><!-- end full-page-title -->
@ -52,30 +11,11 @@
<form method="POST">
{% csrf_token %}
{% bootstrap_form form %}
<button class="btn btn-orange btn-block">{% trans "Login" %}</button>
<button class="btn btn-orange btn-block">{% trans "Registrieren" %}</button>
</form>
<div class="other-links">
<!--<p class="link-line"><a href="#">Signup</a></p>
<a class="simple-link" href="#">Forgot Password ?</a>-->
<p class="link-line"><a href="{% url "localauth:login" %}?{{ request.GET.urlencode }}">Schon registriert? Einloggen!</a></p>
</div><!-- end other-links -->
</div><!-- end custom-form -->
<p class="full-page-copyright">© 2020 2021 <a href="https://kumi.systems/">Kumi Systems e.U.</a> All rights reserved.</p>
</div><!-- end columns -->
</div><!-- end row -->
</div><!-- end container -->
</div><!-- end full-page-form -->
<div class="colored-border"></div>
</section>
<!-- Page Scripts Starts -->
<script src="{% static "frontend/js/jquery-3.3.1.min.js" %}"></script>
<script src="{% static "frontend/js/jquery.mCustomScrollbar.concat.min.js" %}"></script>
<script src="{% static "frontend/js/bootstrap.min4.2.1.js" %}"></script>
<script src="{% static "frontend/js/custom-navigation.js" %}"></script>
<!-- Page Scripts Ends -->
</body>
</html>
{% endblock %}

View file

@ -33,6 +33,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'public.middleware.DemoMiddleware',
]
ROOT_URLCONF = 'urlaubsauktion.urls'
@ -117,3 +118,6 @@ AUTH_USER_MODEL = "localauth.User"
REGISTER_REDIRECT_URL = "/"
LOGIN_REDIRECT_URL = "/"
LOGIN_URL = "localauth:login"
LOGOUT_URL = "localauth:logout"