* null-check for Checklist.category

* fixed missing deps
* cleanup
This commit is contained in:
Phil Zhitnikov 2023-08-19 20:01:30 +04:00
parent 4ed1a74a16
commit edf1118f9f
3 changed files with 5 additions and 5 deletions

View File

@ -68,6 +68,7 @@ INSTALLED_APPS = [
'djoser',
'debug_toolbar',
'django_filters',
'mptt',
'store'
]

View File

@ -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

View File

@ -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))