Establishment registration, verification and list
This commit is contained in:
parent
3ad8063919
commit
c1e6bfeff2
9 changed files with 89 additions and 14 deletions
|
@ -12,7 +12,7 @@ def name_to_coords(name):
|
|||
return result.latitude, result.longitude
|
||||
|
||||
def profile_to_coords(profile):
|
||||
return name_to_coords("%s, %s, %s, %s" % (profile.address, profile.city, profile.zip, profile.country))
|
||||
return name_to_coords("%s, %s, %s, %s" % (profile.street, profile.city, profile.zip, profile.country))
|
||||
|
||||
def upload_path(instance, filename):
|
||||
return f'userfiles/{instance.user.id}/{uuid.uuid4()}/{filename}'
|
11
partners/forms.py
Normal file
11
partners/forms.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django import forms
|
||||
|
||||
from .models import Establishment
|
||||
|
||||
class VerificationForm(forms.Form):
|
||||
def get_choices():
|
||||
for establishment in Establishment.objects.filter(verified=False):
|
||||
yield ("%i" % establishment.id, "%i – %s" % (establishment.id, establishment.name))
|
||||
|
||||
establishment = forms.ChoiceField(choices=get_choices)
|
|
@ -9,10 +9,22 @@ class PartnerProfile(Profile):
|
|||
|
||||
class Establishment(LocationMixin, ImageMixin, PhoneMixin):
|
||||
owner = models.ForeignKey(PartnerProfile, models.CASCADE)
|
||||
name = models.CharField(max_length=64)
|
||||
stars = models.IntegerField(null=True, blank=True)
|
||||
superior = models.BooleanField(default=False)
|
||||
name = models.CharField("Name", max_length=64)
|
||||
stars = models.IntegerField("Sterne", null=True, blank=True)
|
||||
superior = models.BooleanField("Superior", default=False)
|
||||
verified = models.BooleanField(default=False)
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
@property
|
||||
def user(self):
|
||||
return self.owner.user
|
||||
|
||||
@property
|
||||
def is_active(self):
|
||||
return self.verified and self.active
|
||||
|
||||
def booking_set(self):
|
||||
return self.offer_set.filter(accepted=True)
|
||||
|
||||
class RoomCategory(ImageMixin):
|
||||
establishment = models.ForeignKey(Establishment, models.CASCADE)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django.urls import path, reverse_lazy
|
||||
from django.views.generic import RedirectView
|
||||
|
||||
from .views import PartnerRegistrationView, PartnerProfileView, BiddingListView, OffersListView, EstablishmentsListView, EstablishmentRequestView, PartnerDashboardView
|
||||
from .views import PartnerRegistrationView, PartnerProfileView, BiddingListView, OffersListView, EstablishmentsListView, EstablishmentRequestView, PartnerDashboardView, EstablishmentVerificationView
|
||||
|
||||
app_name = "partners"
|
||||
|
||||
|
@ -9,6 +9,7 @@ urlpatterns = [
|
|||
path('register/', PartnerRegistrationView.as_view(), name="register"),
|
||||
path('profile/', PartnerProfileView.as_view(), name="profile"),
|
||||
path('establishments/', EstablishmentsListView.as_view(), name="establishments"),
|
||||
path('establishments/validate/', EstablishmentVerificationView.as_view(), name="establishment_verify"),
|
||||
path('establishments/register/', EstablishmentRequestView.as_view(), name="establishment_register"),
|
||||
path('bidding/<int:id>/', BiddingListView.as_view(), name="bidding"),
|
||||
path('bidding/', BiddingListView.as_view(), name="bidding"),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from django.views.generic import CreateView, UpdateView, ListView, DetailView
|
||||
from django.views.generic import CreateView, UpdateView, ListView, DetailView, FormView
|
||||
from django.urls import reverse_lazy
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.db.models import F
|
||||
|
@ -7,10 +7,11 @@ from django.contrib import messages
|
|||
|
||||
from .models import PartnerProfile, Establishment
|
||||
from .mixins import PartnerProfileRequiredMixin
|
||||
from .forms import VerificationForm
|
||||
|
||||
from auction.models import Inquiry, Offer
|
||||
from public.mixins import InConstructionMixin
|
||||
from localauth.mixins import LoginRequiredMixin
|
||||
from localauth.mixins import LoginRequiredMixin, SuperUserRequiredMixin
|
||||
|
||||
class PartnerRegistrationView(InConstructionMixin, LoginRequiredMixin, CreateView):
|
||||
model = PartnerProfile
|
||||
|
@ -109,16 +110,36 @@ class EstablishmentsListView(InConstructionMixin, PartnerProfileRequiredMixin, L
|
|||
template_name = "partners/establishment_list.html"
|
||||
|
||||
def get_queryset(self):
|
||||
return self.request.user.partnerprofile.establishment_set
|
||||
return self.request.user.partnerprofile.establishment_set.all()
|
||||
|
||||
class EstablishmentRequestView(InConstructionMixin, PartnerProfileRequiredMixin, CreateView):
|
||||
model = Establishment
|
||||
template_name = "partners/establishment_register.html"
|
||||
fields = ["name", "stars", "superior", "street", "city", "zip", "state", "country"]
|
||||
fields = ["name", "stars", "superior", "street", "city", "zip", "state", "country", "image"]
|
||||
|
||||
def form_valid(self, form):
|
||||
form.instance.owner = self.request.user.partnerprofile
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse_lazy("partners:establishments")
|
||||
|
||||
class PartnerDashboardView(InConstructionMixin, PartnerProfileRequiredMixin, DetailView):
|
||||
model = PartnerProfile
|
||||
template_name = "partners/dashboard.html"
|
||||
|
||||
def get_object(self):
|
||||
return self.request.user.partnerprofile
|
||||
return self.request.user.partnerprofile
|
||||
|
||||
class EstablishmentVerificationView(SuperUserRequiredMixin, FormView):
|
||||
form_class = VerificationForm
|
||||
template_name = "partners/establishment_verify.html"
|
||||
|
||||
def form_valid(self, form):
|
||||
eid = form.cleaned_data["establishment"]
|
||||
eobj = Establishment.objects.get(id=eid)
|
||||
eobj.update(verified=True)
|
||||
|
||||
messages.success(self.request, "Unterkunft %s bestätigt!" % eobj.name)
|
||||
|
||||
return HttpResponseRedirect(resolve_url("partners:establishment_verify"))
|
|
@ -250,6 +250,7 @@
|
|||
<img src="{% static "frontend/images/paypal.png" %}" class="img-fluid" alt="stripe" />
|
||||
<div class="paypal-text">
|
||||
<p>{% trans "Die Zahlung per Kreditkarte wird durch unseren Zahlungsdienstleister Stripe abgewickelt." %}</p>
|
||||
<p>{% trans "Der gebotene Betrag wird autorisiert und erst bei verbindlicher Buchung einer Reise tatsächlich von Ihrer Kreditkarte abgebucht." %}</p>
|
||||
</div><!-- end paypal-text -->
|
||||
|
||||
<div class="clearfix"></div>
|
||||
|
|
|
@ -192,6 +192,7 @@
|
|||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="{% url "payment:sepa:apply" %}">{% trans "SEPA-Zahlung anwenden" %}</a></li>
|
||||
<li><a class="dropdown-item" href="{% url "localauth:verify" %}">{% trans "Account verifizieren" %}</a></li>
|
||||
<li><a class="dropdown-item" href="{% url "partners:establishment_verify" %}">{% trans "Unterkunft verifizieren" %}</a></li>
|
||||
<li><a class="dropdown-item" href="{% url "admin:index" %}">{% trans "Admin-Panel" %}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -324,7 +325,7 @@
|
|||
<div class="col-12 col-md-6 col-lg-6 col-xl-6" id="terms">
|
||||
<ul class="list-unstyled list-inline">
|
||||
<li class="list-inline-item"><a href="#">Allgemeine Geschäftsbedingungen</a></li>
|
||||
<li class="list-inline-item"><a href="#">Datenschutzerklärung</a></li>
|
||||
<li class="list-inline-item"><a href="#">Datenschutzerklärung / Cookie Notice</a></li>
|
||||
</ul>
|
||||
</div><!-- end columns -->
|
||||
</div><!-- end row -->
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
{% block "dashboardcontent" %}
|
||||
<div class="col-12 col-md-10 col-lg-10 dashboard-content booking-trips">
|
||||
<h2 class="dash-content-title">Deine Unterkünfte</h2>
|
||||
<div class="dash-content-title"><a href="{% url "partners:establishment_register" %}" class="btn">Neue Unterkunft registrieren</a></span>
|
||||
<div class="dashboard-listing booking-listing">
|
||||
<div class="dash-listing-heading">
|
||||
<div class="custom-radio">
|
||||
|
@ -25,17 +26,20 @@
|
|||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<tbody>
|
||||
{% for establishment in object_list %}
|
||||
<tr>
|
||||
<td class="dash-list-text booking-list-detail">
|
||||
<h3>Habbo Hotel</h3>
|
||||
<h3>{{ establishment.name }}</h3>
|
||||
<ul class="list-unstyled booking-info">
|
||||
<li><span>Adresse:</span> Stephansplatz 12, Wien, 1010, AT</li>
|
||||
<li><span>Buchungen:</span> 1028</li>
|
||||
<li><span>Adresse:</span> {{ establishment.full_address }}</li>
|
||||
<li><span>Buchungen:</span> {{ establishment.bookings | length }}</li>
|
||||
<li><span>Status:</span> {% if establishment.is_active %}aktiv{% else %}inaktiv{% endif %}</li>
|
||||
</ul>
|
||||
<button class="btn btn-orange">Details</button>
|
||||
</td>
|
||||
<td class="dash-list-btn"><a href="{% url "partners:bidding" 1 %}" class="btn btn-orange">Bieten</a><button class="btn">Deaktivieren</button></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!-- end table-responsive -->
|
||||
|
|
24
templates/partners/establishment_verify.html
Normal file
24
templates/partners/establishment_verify.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{% extends "frontend/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap4 %}
|
||||
{% block "content" %}
|
||||
<!--===== INNERPAGE-WRAPPER ====-->
|
||||
<section class="innerpage-wrapper">
|
||||
<div id="payment-success" class="section-padding">
|
||||
<div class="container text-center">
|
||||
<div class="row d-flex justify-content-center">
|
||||
<div class="col-md-12 col-lg-8 col-lg-offset-2">
|
||||
<div class="payment-success-text">
|
||||
<h2>{% trans "Unterkunft verifizieren" %}</h2>
|
||||
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form %}
|
||||
<button class="btn btn-orange btn-block">{% trans "Verifizieren" %}</button>
|
||||
</div>
|
||||
</div><!-- end columns -->
|
||||
</div><!-- end row -->
|
||||
</div><!-- end container -->
|
||||
</div><!-- end coming-soon-text -->
|
||||
</section><!-- end innerpage-wrapper -->
|
||||
{% endblock %}
|
Loading…
Reference in a new issue