Revert "complex_status"
This reverts commit 5c4a96afcc75717ce258f8bbf4538113b00ab188.
This commit is contained in:
parent
5c4a96afcc
commit
670e450091
@ -25,7 +25,7 @@ from alkatorapi.views import (
|
|||||||
login_status, change_racer,
|
login_status, change_racer,
|
||||||
products, cart_add, cart, cart_delete,
|
products, cart_add, cart, cart_delete,
|
||||||
cart_decrease, cart_buy, select_delivery,
|
cart_decrease, cart_buy, select_delivery,
|
||||||
delivery, complex_status
|
delivery,
|
||||||
)
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@ -50,5 +50,4 @@ urlpatterns = [
|
|||||||
path('api/cart/buy', cart_buy),
|
path('api/cart/buy', cart_buy),
|
||||||
path('api/cart/select_delivery', select_delivery),
|
path('api/cart/select_delivery', select_delivery),
|
||||||
path('api/cart/delivery', delivery),
|
path('api/cart/delivery', delivery),
|
||||||
path('api/complex_status', complex_status),
|
|
||||||
]
|
]
|
||||||
|
@ -90,7 +90,6 @@ class CartProduct(models.Model):
|
|||||||
quantity = models.IntegerField()
|
quantity = models.IntegerField()
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super(self).clean()
|
|
||||||
data = self.cleaned_data
|
data = self.cleaned_data
|
||||||
if data['quantity'] <= 0:
|
if data['quantity'] <= 0:
|
||||||
raise ValidationError("Počet předmětů v košíku musí být kladný!")
|
raise ValidationError("Počet předmětů v košíku musí být kladný!")
|
||||||
@ -137,7 +136,6 @@ class InvoiceProduct(models.Model):
|
|||||||
price = models.IntegerField(default=1)
|
price = models.IntegerField(default=1)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super(self).clean()
|
|
||||||
data = self.cleaned_data
|
data = self.cleaned_data
|
||||||
if data['quantity'] <= 0:
|
if data['quantity'] <= 0:
|
||||||
raise ValidationError("Počet předmětů ve faktuře musí být kladný!")
|
raise ValidationError("Počet předmětů ve faktuře musí být kladný!")
|
||||||
|
@ -395,17 +395,6 @@ def delivery(request):
|
|||||||
return HttpResponse("undefined", status=200, content_type='application/json')
|
return HttpResponse("undefined", status=200, content_type='application/json')
|
||||||
|
|
||||||
|
|
||||||
def complex_status(request):
|
|
||||||
return HttpResponse(json.dumps({
|
|
||||||
"products": products(request).content,
|
|
||||||
"cart": cart(request).content,
|
|
||||||
"results": results(request).content,
|
|
||||||
"delivery": delivery(request).content,
|
|
||||||
"photos": photos(request).content,
|
|
||||||
"login_status": login_status(request).content,
|
|
||||||
}))
|
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def cart_buy(request):
|
def cart_buy(request):
|
||||||
|
@ -35,7 +35,27 @@ class Main extends Component {
|
|||||||
cart: [],
|
cart: [],
|
||||||
delivery: undefined,
|
delivery: undefined,
|
||||||
};
|
};
|
||||||
fetch(addr_prefix + "/api/complex_status").then(resp => resp.json()).then(json => this.setState(json));
|
fetch(addr_prefix + "/api/results").then(resp => resp.json()).then(json => {
|
||||||
|
this.setState({results: json})
|
||||||
|
})
|
||||||
|
fetch(addr_prefix + "/api/photos").then(resp => resp.json()).then(json => {
|
||||||
|
this.setState({photos: json})
|
||||||
|
})
|
||||||
|
fetch(addr_prefix + "/api/products").then(resp => resp.json()).then(json => {
|
||||||
|
this.setState({products: json})
|
||||||
|
})
|
||||||
|
fetch(addr_prefix + "/api/cart").then(resp => resp.json()).then(json => {
|
||||||
|
this.setState({cart: json})
|
||||||
|
})
|
||||||
|
fetch(addr_prefix + "/api/login_status").then(resp => resp.json()).then(json => {
|
||||||
|
this.setState({login_status: json})
|
||||||
|
})
|
||||||
|
fetch(addr_prefix + "/api/cart/delivery").then(resp => resp.json()).then(json => {
|
||||||
|
this.setState({
|
||||||
|
cart: [...this.state.cart, {"name": "Doprava na " + json, "id": 2, "price": delivery_cost, "locked": true, "quantity": 1}],
|
||||||
|
delivery: json,
|
||||||
|
})
|
||||||
|
})
|
||||||
if(window.location.search){
|
if(window.location.search){
|
||||||
let searchParams = new URLSearchParams(window.location.search);
|
let searchParams = new URLSearchParams(window.location.search);
|
||||||
for(const [key, value] of searchParams){
|
for(const [key, value] of searchParams){
|
||||||
@ -130,7 +150,7 @@ class Main extends Component {
|
|||||||
}
|
}
|
||||||
onSubmit(event){
|
onSubmit(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let form = event.target;
|
let form = document.getElementById("form");
|
||||||
let api_endpoint = form.action;
|
let api_endpoint = form.action;
|
||||||
let formData = new FormData(form);
|
let formData = new FormData(form);
|
||||||
if(this.state.progress){
|
if(this.state.progress){
|
||||||
@ -184,7 +204,7 @@ class Main extends Component {
|
|||||||
};
|
};
|
||||||
selectDeliveryCallback(point){
|
selectDeliveryCallback(point){
|
||||||
if(point){
|
if(point){
|
||||||
fetch(addr_prefix + '/api/cart/select_delivery?delivery=' + encodeURIComponent(point.name)).then(resp => resp.json()).then(json => {
|
fetch(addr_prefix + '/api/cart/select_delivery?delivery=' + point.name).then(resp => resp.json()).then(json => {
|
||||||
if(json.status == "failed"){
|
if(json.status == "failed"){
|
||||||
this.setState({
|
this.setState({
|
||||||
status_text: json.reason,
|
status_text: json.reason,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user