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,
|
||||
products, cart_add, cart, cart_delete,
|
||||
cart_decrease, cart_buy, select_delivery,
|
||||
delivery, complex_status
|
||||
delivery,
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
@ -50,5 +50,4 @@ urlpatterns = [
|
||||
path('api/cart/buy', cart_buy),
|
||||
path('api/cart/select_delivery', select_delivery),
|
||||
path('api/cart/delivery', delivery),
|
||||
path('api/complex_status', complex_status),
|
||||
]
|
||||
|
@ -90,7 +90,6 @@ class CartProduct(models.Model):
|
||||
quantity = models.IntegerField()
|
||||
|
||||
def clean(self):
|
||||
super(self).clean()
|
||||
data = self.cleaned_data
|
||||
if data['quantity'] <= 0:
|
||||
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)
|
||||
|
||||
def clean(self):
|
||||
super(self).clean()
|
||||
data = self.cleaned_data
|
||||
if data['quantity'] <= 0:
|
||||
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')
|
||||
|
||||
|
||||
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
|
||||
@transaction.atomic
|
||||
def cart_buy(request):
|
||||
|
@ -35,7 +35,27 @@ class Main extends Component {
|
||||
cart: [],
|
||||
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){
|
||||
let searchParams = new URLSearchParams(window.location.search);
|
||||
for(const [key, value] of searchParams){
|
||||
@ -130,7 +150,7 @@ class Main extends Component {
|
||||
}
|
||||
onSubmit(event){
|
||||
event.preventDefault();
|
||||
let form = event.target;
|
||||
let form = document.getElementById("form");
|
||||
let api_endpoint = form.action;
|
||||
let formData = new FormData(form);
|
||||
if(this.state.progress){
|
||||
@ -184,7 +204,7 @@ class Main extends Component {
|
||||
};
|
||||
selectDeliveryCallback(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"){
|
||||
this.setState({
|
||||
status_text: json.reason,
|
||||
|
Loading…
x
Reference in New Issue
Block a user