Features: 1) Add async logger initialization in core/vendors and log warnings for missing attribute values, groups, and integrity errors; 2) Add traceback logging for attribute-related errors in core/vendors;
Fixes: 1) Add missing `sku` to readonly fields in `core/admin`; Extra: 1) Remove unnecessary import of `AnonymousUser` from `core/serializers/detail.py`.
This commit is contained in:
parent
efeab3e426
commit
44e5e74044
3 changed files with 9 additions and 1 deletions
|
|
@ -410,6 +410,7 @@ class ProductAdmin(FieldsetsMixin, ActivationActionsMixin, ModelAdmin): # type:
|
|||
"sku",
|
||||
)
|
||||
readonly_fields = (
|
||||
"sku",
|
||||
"slug",
|
||||
"uuid",
|
||||
"modified",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ from collections import defaultdict
|
|||
from contextlib import suppress
|
||||
from typing import Collection, Any
|
||||
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.core.cache import cache
|
||||
from django.db.models.functions import Length
|
||||
from rest_framework.fields import JSONField, SerializerMethodField
|
||||
|
|
|
|||
8
core/vendors/__init__.py
vendored
8
core/vendors/__init__.py
vendored
|
|
@ -1,5 +1,6 @@
|
|||
import gzip
|
||||
import json
|
||||
import traceback
|
||||
from contextlib import suppress
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
|
|
@ -7,6 +8,7 @@ from io import BytesIO
|
|||
from math import ceil, log10
|
||||
from typing import Any
|
||||
|
||||
from celery.utils.log import get_task_logger
|
||||
from constance import config
|
||||
from django.conf import settings
|
||||
from django.core.files.base import ContentFile
|
||||
|
|
@ -28,6 +30,8 @@ from core.models import (
|
|||
from payments.errors import RatesError
|
||||
from payments.utils import get_rates
|
||||
|
||||
async_logger = get_task_logger(__name__)
|
||||
|
||||
|
||||
class NotEnoughBalanceError(Exception):
|
||||
"""
|
||||
|
|
@ -416,9 +420,11 @@ class AbstractVendor:
|
|||
|
||||
def process_attribute(self, key: str, value: Any, product: Product, attr_group: AttributeGroup) -> None:
|
||||
if not value:
|
||||
async_logger.warning(f"No value for attribute {key!r} at {product.name!r}...")
|
||||
return
|
||||
|
||||
if not attr_group:
|
||||
async_logger.warning(f"No group for attribute {key!r} at {product.name!r}...")
|
||||
return
|
||||
|
||||
if key in self.blocked_attributes:
|
||||
|
|
@ -444,6 +450,8 @@ class AbstractVendor:
|
|||
attribute.value_type = attr_value_type
|
||||
attribute.save()
|
||||
except IntegrityError:
|
||||
async_logger.warning(f"IntegrityError while processing attribute {key!r}...")
|
||||
async_logger.warning(traceback.format_exc())
|
||||
return
|
||||
|
||||
attribute.save()
|
||||
|
|
|
|||
Loading…
Reference in a new issue