* null-check for Checklist.category
* fixed missing deps * cleanup
This commit is contained in:
parent
4ed1a74a16
commit
edf1118f9f
|
|
@ -68,6 +68,7 @@ INSTALLED_APPS = [
|
|||
'djoser',
|
||||
'debug_toolbar',
|
||||
'django_filters',
|
||||
'mptt',
|
||||
|
||||
'store'
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ from django.contrib import admin
|
|||
from django.contrib.admin import display
|
||||
from mptt.admin import MPTTModelAdmin
|
||||
|
||||
from .models import Category, Checklist, GlobalSettings, PaymentMethod, Promocode, User, Image, Client
|
||||
|
||||
from .models import Category, Checklist, GlobalSettings, PaymentMethod, Promocode, User, Image
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -394,9 +394,10 @@ class Checklist(models.Model):
|
|||
price += self.commission_rub
|
||||
|
||||
# Add commission of bottom-most category
|
||||
category = self.category.get_ancestors(ascending=True, include_self=True).first()
|
||||
category_commission = getattr(category, 'commission', 0)
|
||||
price += category_commission * self.price_rub / 100
|
||||
if self.category:
|
||||
category = self.category.get_ancestors(ascending=True, include_self=True).first()
|
||||
category_commission = getattr(category, 'commission', 0)
|
||||
price += category_commission * self.price_rub / 100
|
||||
|
||||
return max(0, math.ceil(price))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user