Numerous changes

This commit is contained in:
Kumi 2020-04-08 15:06:24 +02:00
parent 97a83f4801
commit 19c1a50c2a
5 changed files with 21 additions and 15 deletions

View file

@ -6,10 +6,11 @@ from django.conf import settings
from uuid import uuid4
from profiles.models import ClientProfile, ContactProfile
from offers.models import Offer
class Inquiry(Model):
uuid = UUIDField(default=uuid4, primary_key=True)
user = ForeignKey(ClientProfile, null=True, on_delete=CASCADE)
user = ForeignKey(ClientProfile, null=True, on_delete=SET_NULL)
amount = DecimalField(max_digits=25, decimal_places=2)
currency = CharField(max_length=3, choices=settings.CURRENCIES)
first_date = DateField()
@ -22,4 +23,12 @@ class Inquiry(Model):
contact = ForeignKey(ContactProfile, null=True, on_delete=SET_NULL)
def get_absolute_url(self):
return reverse_lazy("auction:payment", kwargs={'pk': self.uuid})
return reverse_lazy("auction:payment", kwargs={'pk': self.uuid})
class Offer(Model):
uuid = UUIDField(default=uuid4, primary_key=True)
inquiry = ForeignKey(Inquiry, on_delete=CASCADE)
offer = ForeignKey(Offer, on_delete=CASCADE)
arrival_date = DateField()
departure_date = DateField()

View file

@ -22,13 +22,7 @@ class InquiryView(CreateView):
return redirect(reverse_lazy("frontend:index"))
def form_invalid(self, form):
#for field in form.errors.keys():
# print('ValidationError: %s[%s] <- "%s" %s' % (
# type(self),
# field,
# form.data.get(field, False),
# form.errors.get(field, False).as_text()
# ))
print(repr(form.errors))
return redirect(reverse_lazy("frontend:index") + "?invalid=true")
def form_valid(self, form):
@ -114,4 +108,4 @@ class PostPaymentView(FormView):
handler = StripePayment
payment = handler.objects.create(invoice=inquiry)
return payment.start()
return payment.start()

View file

@ -1,4 +1,4 @@
from django.shortcuts import redirect, render_to_response
from django.shortcuts import redirect, render
from django.utils.translation import LANGUAGE_SESSION_KEY
from django.views.generic import TemplateView
@ -17,7 +17,7 @@ def change_language(request):
return redirect(url)
def errorhandler(request, exception, status):
response = render_to_response("frontend/error.html", {"status_code": status})
response = render(request, "frontend/error.html", {"status_code": status})
response.status_code = status
return response
@ -25,4 +25,4 @@ def handler404(request, exception):
return errorhandler(request, exception, 404)
def handler500(request):
return errorhandler(request, None, 500)
return errorhandler(request, None, 500)

2
packages.txt Normal file
View file

@ -0,0 +1,2 @@
python3-pip
gdal-bin

View file

@ -17,7 +17,7 @@ SECRET_KEY = 'g$_(44hzu#_utld_hn@yw$-x_1l-0pf2+f-3#$^5f2c(p=)nq3'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["localhost:8000", "*"]
ALLOWED_HOSTS = ["82499757.ngrok.io", "*"]
PROTOCOL = "http"
BASE_URL = PROTOCOL + "://" + ALLOWED_HOSTS[0]
@ -127,7 +127,7 @@ TIME_ZONE = 'Europe/Vienna'
USE_I18N = True
USE_L10N = True
USE_L10N = False
USE_TZ = True
@ -145,3 +145,4 @@ MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
DATE_INPUT_FORMATS = ['%d-%m-%Y','%Y-%m-%d', "%d.%m.%Y"]