mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	resort imports
This commit is contained in:
		@@ -1,12 +1,12 @@
 | 
			
		||||
from django.contrib import admin
 | 
			
		||||
 | 
			
		||||
import import_export.widgets as widgets
 | 
			
		||||
from import_export.admin import ImportExportModelAdmin
 | 
			
		||||
from import_export.fields import Field
 | 
			
		||||
from import_export.resources import ModelResource
 | 
			
		||||
import import_export.widgets as widgets
 | 
			
		||||
 | 
			
		||||
from company.models import SupplierPart
 | 
			
		||||
import part.models as models
 | 
			
		||||
from company.models import SupplierPart
 | 
			
		||||
from stock.models import StockLocation
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,53 +3,41 @@ Provides a JSON API for the Part app
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import datetime
 | 
			
		||||
 | 
			
		||||
from django.urls import include, path, re_path
 | 
			
		||||
from django.http import JsonResponse
 | 
			
		||||
from django.db.models import Q, F, Count, Min, Max, Avg
 | 
			
		||||
from django.db import transaction
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from rest_framework import status
 | 
			
		||||
from rest_framework.response import Response
 | 
			
		||||
from rest_framework import filters, serializers
 | 
			
		||||
from rest_framework import generics
 | 
			
		||||
from rest_framework.exceptions import ValidationError
 | 
			
		||||
 | 
			
		||||
from django_filters.rest_framework import DjangoFilterBackend
 | 
			
		||||
from django_filters import rest_framework as rest_filters
 | 
			
		||||
 | 
			
		||||
from djmoney.money import Money
 | 
			
		||||
from djmoney.contrib.exchange.models import convert_money
 | 
			
		||||
from djmoney.contrib.exchange.exceptions import MissingRate
 | 
			
		||||
 | 
			
		||||
from decimal import Decimal, InvalidOperation
 | 
			
		||||
 | 
			
		||||
from part.admin import PartResource
 | 
			
		||||
from django.db import transaction
 | 
			
		||||
from django.db.models import Avg, Count, F, Max, Min, Q
 | 
			
		||||
from django.http import JsonResponse
 | 
			
		||||
from django.urls import include, path, re_path
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from .models import Part, PartCategory, PartRelated
 | 
			
		||||
from .models import BomItem, BomItemSubstitute
 | 
			
		||||
from .models import PartParameter, PartParameterTemplate
 | 
			
		||||
from .models import PartAttachment, PartTestTemplate
 | 
			
		||||
from .models import PartSellPriceBreak, PartInternalPriceBreak
 | 
			
		||||
from .models import PartCategoryParameterTemplate
 | 
			
		||||
from django_filters import rest_framework as rest_filters
 | 
			
		||||
from django_filters.rest_framework import DjangoFilterBackend
 | 
			
		||||
from djmoney.contrib.exchange.exceptions import MissingRate
 | 
			
		||||
from djmoney.contrib.exchange.models import convert_money
 | 
			
		||||
from djmoney.money import Money
 | 
			
		||||
from rest_framework import filters, generics, serializers, status
 | 
			
		||||
from rest_framework.exceptions import ValidationError
 | 
			
		||||
from rest_framework.response import Response
 | 
			
		||||
 | 
			
		||||
import order.models
 | 
			
		||||
from build.models import Build, BuildItem
 | 
			
		||||
from common.models import InvenTreeSetting
 | 
			
		||||
from company.models import Company, ManufacturerPart, SupplierPart
 | 
			
		||||
 | 
			
		||||
from InvenTree.api import APIDownloadMixin, AttachmentMixin
 | 
			
		||||
from InvenTree.helpers import DownloadFile, increment, isNull, str2bool
 | 
			
		||||
from InvenTree.status_codes import (BuildStatus, PurchaseOrderStatus,
 | 
			
		||||
                                    SalesOrderStatus)
 | 
			
		||||
from part.admin import PartResource
 | 
			
		||||
from plugin.serializers import MetadataSerializer
 | 
			
		||||
from stock.models import StockItem, StockLocation
 | 
			
		||||
 | 
			
		||||
from common.models import InvenTreeSetting
 | 
			
		||||
from build.models import Build, BuildItem
 | 
			
		||||
import order.models
 | 
			
		||||
from plugin.serializers import MetadataSerializer
 | 
			
		||||
 | 
			
		||||
from . import serializers as part_serializers
 | 
			
		||||
 | 
			
		||||
from InvenTree.helpers import str2bool, isNull, increment
 | 
			
		||||
from InvenTree.helpers import DownloadFile
 | 
			
		||||
from InvenTree.api import AttachmentMixin, APIDownloadMixin
 | 
			
		||||
 | 
			
		||||
from InvenTree.status_codes import BuildStatus, PurchaseOrderStatus, SalesOrderStatus
 | 
			
		||||
from .models import (BomItem, BomItemSubstitute, Part, PartAttachment,
 | 
			
		||||
                     PartCategory, PartCategoryParameterTemplate,
 | 
			
		||||
                     PartInternalPriceBreak, PartParameter,
 | 
			
		||||
                     PartParameterTemplate, PartRelated, PartSellPriceBreak,
 | 
			
		||||
                     PartTestTemplate)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CategoryList(generics.ListCreateAPIView):
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,10 @@
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from django.db.utils import OperationalError, ProgrammingError
 | 
			
		||||
from django.apps import AppConfig
 | 
			
		||||
from django.db.utils import OperationalError, ProgrammingError
 | 
			
		||||
 | 
			
		||||
from InvenTree.ready import canAppAccessDatabase
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
logger = logging.getLogger("inventree")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -7,11 +7,11 @@ from collections import OrderedDict
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext as _
 | 
			
		||||
 | 
			
		||||
from company.models import ManufacturerPart, SupplierPart
 | 
			
		||||
from InvenTree.helpers import DownloadFile, GetExportFormats, normalize
 | 
			
		||||
 | 
			
		||||
from .admin import BomItemResource
 | 
			
		||||
from .models import BomItem
 | 
			
		||||
from company.models import ManufacturerPart, SupplierPart
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def IsValidBOMFormat(fmt):
 | 
			
		||||
 
 | 
			
		||||
@@ -7,17 +7,15 @@ from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from mptt.fields import TreeNodeChoiceField
 | 
			
		||||
 | 
			
		||||
from InvenTree.forms import HelperForm
 | 
			
		||||
from InvenTree.helpers import clean_decimal
 | 
			
		||||
from InvenTree.fields import RoundingDecimalFormField
 | 
			
		||||
 | 
			
		||||
import common.models
 | 
			
		||||
from common.forms import MatchItemForm
 | 
			
		||||
from InvenTree.fields import RoundingDecimalFormField
 | 
			
		||||
from InvenTree.forms import HelperForm
 | 
			
		||||
from InvenTree.helpers import clean_decimal
 | 
			
		||||
 | 
			
		||||
from .models import Part, PartCategory
 | 
			
		||||
from .models import PartParameterTemplate
 | 
			
		||||
from .models import PartCategoryParameterTemplate
 | 
			
		||||
from .models import PartSellPriceBreak, PartInternalPriceBreak
 | 
			
		||||
from .models import (Part, PartCategory, PartCategoryParameterTemplate,
 | 
			
		||||
                     PartInternalPriceBreak, PartParameterTemplate,
 | 
			
		||||
                     PartSellPriceBreak)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PartModelChoiceField(forms.ModelChoiceField):
 | 
			
		||||
 
 | 
			
		||||
@@ -3,64 +3,52 @@ Part database model definitions
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import decimal
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
import hashlib
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django.core.exceptions import ValidationError
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
 | 
			
		||||
from django.db import models, transaction
 | 
			
		||||
from django.db.utils import IntegrityError
 | 
			
		||||
from django.db.models import Q, Sum, UniqueConstraint
 | 
			
		||||
from django.db.models.functions import Coalesce
 | 
			
		||||
from django.core.validators import MinValueValidator
 | 
			
		||||
import os
 | 
			
		||||
from datetime import datetime
 | 
			
		||||
from decimal import Decimal, InvalidOperation
 | 
			
		||||
 | 
			
		||||
from django.contrib.auth.models import User
 | 
			
		||||
from django.core.exceptions import ValidationError
 | 
			
		||||
from django.core.validators import MinValueValidator
 | 
			
		||||
from django.db import models, transaction
 | 
			
		||||
from django.db.models import Q, Sum, UniqueConstraint
 | 
			
		||||
from django.db.models.functions import Coalesce
 | 
			
		||||
from django.db.models.signals import post_save
 | 
			
		||||
from django.db.utils import IntegrityError
 | 
			
		||||
from django.dispatch import receiver
 | 
			
		||||
 | 
			
		||||
from jinja2 import Template
 | 
			
		||||
 | 
			
		||||
from markdownx.models import MarkdownxField
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from django_cleanup import cleanup
 | 
			
		||||
 | 
			
		||||
from djmoney.contrib.exchange.exceptions import MissingRate
 | 
			
		||||
 | 
			
		||||
from mptt.models import TreeForeignKey, MPTTModel
 | 
			
		||||
from djmoney.contrib.exchange.models import convert_money
 | 
			
		||||
from jinja2 import Template
 | 
			
		||||
from markdownx.models import MarkdownxField
 | 
			
		||||
from mptt.exceptions import InvalidMove
 | 
			
		||||
from mptt.managers import TreeManager
 | 
			
		||||
 | 
			
		||||
from mptt.models import MPTTModel, TreeForeignKey
 | 
			
		||||
from stdimage.models import StdImageField
 | 
			
		||||
 | 
			
		||||
from decimal import Decimal, InvalidOperation
 | 
			
		||||
from datetime import datetime
 | 
			
		||||
import hashlib
 | 
			
		||||
from djmoney.contrib.exchange.models import convert_money
 | 
			
		||||
from common.settings import currency_code_default
 | 
			
		||||
from common.models import InvenTreeSetting
 | 
			
		||||
 | 
			
		||||
from InvenTree import helpers
 | 
			
		||||
from InvenTree import validators
 | 
			
		||||
 | 
			
		||||
import common.models
 | 
			
		||||
import InvenTree.ready
 | 
			
		||||
import InvenTree.tasks
 | 
			
		||||
 | 
			
		||||
from InvenTree.fields import InvenTreeURLField
 | 
			
		||||
from InvenTree.helpers import decimal2string, normalize, decimal2money
 | 
			
		||||
from InvenTree.models import InvenTreeTree, InvenTreeAttachment, DataImportMixin
 | 
			
		||||
from InvenTree.status_codes import BuildStatus, PurchaseOrderStatus, SalesOrderStatus
 | 
			
		||||
 | 
			
		||||
import common.models
 | 
			
		||||
from build import models as BuildModels
 | 
			
		||||
from order import models as OrderModels
 | 
			
		||||
from company.models import SupplierPart
 | 
			
		||||
import part.settings as part_settings
 | 
			
		||||
from stock import models as StockModels
 | 
			
		||||
from build import models as BuildModels
 | 
			
		||||
from common.models import InvenTreeSetting
 | 
			
		||||
from common.settings import currency_code_default
 | 
			
		||||
from company.models import SupplierPart
 | 
			
		||||
from InvenTree import helpers, validators
 | 
			
		||||
from InvenTree.fields import InvenTreeURLField
 | 
			
		||||
from InvenTree.helpers import decimal2money, decimal2string, normalize
 | 
			
		||||
from InvenTree.models import (DataImportMixin, InvenTreeAttachment,
 | 
			
		||||
                              InvenTreeTree)
 | 
			
		||||
from InvenTree.status_codes import (BuildStatus, PurchaseOrderStatus,
 | 
			
		||||
                                    SalesOrderStatus)
 | 
			
		||||
from order import models as OrderModels
 | 
			
		||||
from plugin.models import MetadataMixin
 | 
			
		||||
 | 
			
		||||
from stock import models as StockModels
 | 
			
		||||
 | 
			
		||||
logger = logging.getLogger("inventree")
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,40 +5,35 @@ JSON serializers for Part app
 | 
			
		||||
import imghdr
 | 
			
		||||
from decimal import Decimal
 | 
			
		||||
 | 
			
		||||
from django.urls import reverse_lazy
 | 
			
		||||
from django.db import models, transaction
 | 
			
		||||
from django.db.models import ExpressionWrapper, F, Q, Func
 | 
			
		||||
from django.db.models import Subquery, OuterRef, FloatField
 | 
			
		||||
 | 
			
		||||
from django.db.models import (ExpressionWrapper, F, FloatField, Func, OuterRef,
 | 
			
		||||
                              Q, Subquery)
 | 
			
		||||
from django.db.models.functions import Coalesce
 | 
			
		||||
from django.urls import reverse_lazy
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from djmoney.contrib.django_rest_framework import MoneyField
 | 
			
		||||
from rest_framework import serializers
 | 
			
		||||
from sql_util.utils import SubqueryCount, SubquerySum
 | 
			
		||||
from djmoney.contrib.django_rest_framework import MoneyField
 | 
			
		||||
 | 
			
		||||
from common.settings import currency_code_default, currency_code_mappings
 | 
			
		||||
 | 
			
		||||
from InvenTree.serializers import (DataFileUploadSerializer,
 | 
			
		||||
                                   DataFileExtractSerializer,
 | 
			
		||||
from InvenTree.serializers import (DataFileExtractSerializer,
 | 
			
		||||
                                   DataFileUploadSerializer,
 | 
			
		||||
                                   InvenTreeAttachmentSerializer,
 | 
			
		||||
                                   InvenTreeAttachmentSerializerField,
 | 
			
		||||
                                   InvenTreeDecimalField,
 | 
			
		||||
                                   InvenTreeImageSerializerField,
 | 
			
		||||
                                   InvenTreeModelSerializer,
 | 
			
		||||
                                   InvenTreeAttachmentSerializer,
 | 
			
		||||
                                   InvenTreeMoneySerializer)
 | 
			
		||||
 | 
			
		||||
from InvenTree.status_codes import (BuildStatus,
 | 
			
		||||
                                    PurchaseOrderStatus,
 | 
			
		||||
from InvenTree.status_codes import (BuildStatus, PurchaseOrderStatus,
 | 
			
		||||
                                    SalesOrderStatus)
 | 
			
		||||
 | 
			
		||||
from stock.models import StockItem
 | 
			
		||||
 | 
			
		||||
from .models import (BomItem, BomItemSubstitute,
 | 
			
		||||
                     Part, PartAttachment, PartCategory, PartRelated,
 | 
			
		||||
                     PartParameter, PartParameterTemplate, PartSellPriceBreak,
 | 
			
		||||
                     PartStar, PartTestTemplate, PartCategoryParameterTemplate,
 | 
			
		||||
                     PartInternalPriceBreak)
 | 
			
		||||
from .models import (BomItem, BomItemSubstitute, Part, PartAttachment,
 | 
			
		||||
                     PartCategory, PartCategoryParameterTemplate,
 | 
			
		||||
                     PartInternalPriceBreak, PartParameter,
 | 
			
		||||
                     PartParameterTemplate, PartRelated, PartSellPriceBreak,
 | 
			
		||||
                     PartStar, PartTestTemplate)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CategorySerializer(InvenTreeModelSerializer):
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,9 @@ import logging
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
import common.notifications
 | 
			
		||||
import InvenTree.helpers
 | 
			
		||||
import InvenTree.tasks
 | 
			
		||||
import common.notifications
 | 
			
		||||
 | 
			
		||||
import part.models
 | 
			
		||||
 | 
			
		||||
logger = logging.getLogger("inventree")
 | 
			
		||||
 
 | 
			
		||||
@@ -5,30 +5,25 @@ This module provides template tags for extra functionality,
 | 
			
		||||
over and above the built-in Django tags.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
from datetime import date, datetime
 | 
			
		||||
import logging
 | 
			
		||||
import os
 | 
			
		||||
import sys
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from django.utils.html import format_html
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django.conf import settings as djangosettings
 | 
			
		||||
from datetime import date, datetime
 | 
			
		||||
 | 
			
		||||
from django import template
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
from django.utils.safestring import mark_safe
 | 
			
		||||
from django.templatetags.static import StaticNode, static
 | 
			
		||||
from django.conf import settings as djangosettings
 | 
			
		||||
from django.core.files.storage import default_storage
 | 
			
		||||
 | 
			
		||||
from InvenTree import version, settings
 | 
			
		||||
from django.templatetags.static import StaticNode, static
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
from django.utils.html import format_html
 | 
			
		||||
from django.utils.safestring import mark_safe
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
import InvenTree.helpers
 | 
			
		||||
 | 
			
		||||
from common.models import InvenTreeSetting, ColorTheme, InvenTreeUserSetting
 | 
			
		||||
from common.models import ColorTheme, InvenTreeSetting, InvenTreeUserSetting
 | 
			
		||||
from common.settings import currency_code_default
 | 
			
		||||
 | 
			
		||||
from plugin.models import PluginSetting, NotificationUserSetting
 | 
			
		||||
from InvenTree import settings, version
 | 
			
		||||
from plugin.models import NotificationUserSetting, PluginSetting
 | 
			
		||||
 | 
			
		||||
register = template.Library()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,9 @@ Provide templates for the various model status codes.
 | 
			
		||||
 | 
			
		||||
from django import template
 | 
			
		||||
from django.utils.safestring import mark_safe
 | 
			
		||||
from InvenTree.status_codes import PurchaseOrderStatus, SalesOrderStatus
 | 
			
		||||
from InvenTree.status_codes import StockStatus, BuildStatus
 | 
			
		||||
 | 
			
		||||
from InvenTree.status_codes import (BuildStatus, PurchaseOrderStatus,
 | 
			
		||||
                                    SalesOrderStatus, StockStatus)
 | 
			
		||||
 | 
			
		||||
register = template.Library()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,21 +1,18 @@
 | 
			
		||||
import PIL
 | 
			
		||||
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
 | 
			
		||||
import PIL
 | 
			
		||||
from rest_framework import status
 | 
			
		||||
from rest_framework.test import APIClient
 | 
			
		||||
 | 
			
		||||
from InvenTree.api_tester import InvenTreeAPITestCase
 | 
			
		||||
from InvenTree.status_codes import BuildStatus, StockStatus, PurchaseOrderStatus
 | 
			
		||||
 | 
			
		||||
from part.models import Part, PartCategory
 | 
			
		||||
from part.models import BomItem, BomItemSubstitute
 | 
			
		||||
from stock.models import StockItem, StockLocation
 | 
			
		||||
from company.models import Company
 | 
			
		||||
from common.models import InvenTreeSetting
 | 
			
		||||
 | 
			
		||||
import build.models
 | 
			
		||||
import order.models
 | 
			
		||||
from common.models import InvenTreeSetting
 | 
			
		||||
from company.models import Company
 | 
			
		||||
from InvenTree.api_tester import InvenTreeAPITestCase
 | 
			
		||||
from InvenTree.status_codes import (BuildStatus, PurchaseOrderStatus,
 | 
			
		||||
                                    StockStatus)
 | 
			
		||||
from part.models import BomItem, BomItemSubstitute, Part, PartCategory
 | 
			
		||||
from stock.models import StockItem, StockLocation
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PartCategoryAPITest(InvenTreeAPITestCase):
 | 
			
		||||
 
 | 
			
		||||
@@ -4,11 +4,10 @@ Unit testing for BOM export functionality
 | 
			
		||||
 | 
			
		||||
import csv
 | 
			
		||||
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
from django.contrib.auth import get_user_model
 | 
			
		||||
from django.contrib.auth.models import Group
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BomExportTest(TestCase):
 | 
			
		||||
 
 | 
			
		||||
@@ -2,13 +2,12 @@
 | 
			
		||||
Unit testing for BOM upload / import functionality
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import tablib
 | 
			
		||||
 | 
			
		||||
from django.core.files.uploadedfile import SimpleUploadedFile
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
 | 
			
		||||
from InvenTree.api_tester import InvenTreeAPITestCase
 | 
			
		||||
import tablib
 | 
			
		||||
 | 
			
		||||
from InvenTree.api_tester import InvenTreeAPITestCase
 | 
			
		||||
from part.models import Part
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
 | 
			
		||||
from django.db import transaction
 | 
			
		||||
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
import django.core.exceptions as django_exceptions
 | 
			
		||||
from decimal import Decimal
 | 
			
		||||
 | 
			
		||||
from .models import Part, BomItem, BomItemSubstitute
 | 
			
		||||
import django.core.exceptions as django_exceptions
 | 
			
		||||
from django.db import transaction
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
 | 
			
		||||
from .models import BomItem, BomItemSubstitute, Part
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BomItemTest(TestCase):
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
from django.core.exceptions import ValidationError
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
 | 
			
		||||
from .models import Part, PartCategory, PartParameter, PartParameterTemplate
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,10 @@
 | 
			
		||||
# Tests for Part Parameters
 | 
			
		||||
 | 
			
		||||
from django.test import TestCase, TransactionTestCase
 | 
			
		||||
import django.core.exceptions as django_exceptions
 | 
			
		||||
from django.test import TestCase, TransactionTestCase
 | 
			
		||||
 | 
			
		||||
from .models import Part, PartCategory
 | 
			
		||||
from .models import PartParameter, PartParameterTemplate
 | 
			
		||||
from .models import PartCategoryParameterTemplate
 | 
			
		||||
from .models import (Part, PartCategory, PartCategoryParameterTemplate,
 | 
			
		||||
                     PartParameter, PartParameterTemplate)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TestParams(TestCase):
 | 
			
		||||
 
 | 
			
		||||
@@ -1,24 +1,23 @@
 | 
			
		||||
# Tests for the Part model
 | 
			
		||||
 | 
			
		||||
from allauth.account.models import EmailAddress
 | 
			
		||||
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
from django.contrib.auth import get_user_model
 | 
			
		||||
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
from django.core.exceptions import ValidationError
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
from .models import Part, PartCategory, PartCategoryStar, PartStar, PartTestTemplate
 | 
			
		||||
from .models import rename_part_image
 | 
			
		||||
from .templatetags import inventree_extras
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
from django.contrib.auth import get_user_model
 | 
			
		||||
from django.core.exceptions import ValidationError
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
 | 
			
		||||
from allauth.account.models import EmailAddress
 | 
			
		||||
 | 
			
		||||
import part.settings
 | 
			
		||||
 | 
			
		||||
from common.models import (InvenTreeSetting, InvenTreeUserSetting,
 | 
			
		||||
                           NotificationEntry, NotificationMessage)
 | 
			
		||||
from common.notifications import UIMessageNotification, storage
 | 
			
		||||
from InvenTree import version
 | 
			
		||||
from common.models import InvenTreeSetting, InvenTreeUserSetting, NotificationEntry, NotificationMessage
 | 
			
		||||
from common.notifications import storage, UIMessageNotification
 | 
			
		||||
 | 
			
		||||
from .models import (Part, PartCategory, PartCategoryStar, PartStar,
 | 
			
		||||
                     PartTestTemplate, rename_part_image)
 | 
			
		||||
from .templatetags import inventree_extras
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TemplateTagTest(TestCase):
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
""" Unit tests for Part Views (see views.py) """
 | 
			
		||||
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
from django.contrib.auth import get_user_model
 | 
			
		||||
from django.contrib.auth.models import Group
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
 | 
			
		||||
from .models import Part
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,6 @@ from django.urls import include, re_path
 | 
			
		||||
 | 
			
		||||
from . import views
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
part_parameter_urls = [
 | 
			
		||||
    re_path(r'^template/new/', views.PartParameterTemplateCreate.as_view(), name='part-param-template-create'),
 | 
			
		||||
    re_path(r'^template/(?P<pk>\d+)/edit/', views.PartParameterTemplateEdit.as_view(), name='part-param-template-edit'),
 | 
			
		||||
 
 | 
			
		||||
@@ -2,55 +2,44 @@
 | 
			
		||||
Django views for interacting with Part app
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
from django.core.files.base import ContentFile
 | 
			
		||||
from django.core.exceptions import ValidationError
 | 
			
		||||
from django.db import transaction
 | 
			
		||||
from django.db.utils import IntegrityError
 | 
			
		||||
from django.shortcuts import get_object_or_404
 | 
			
		||||
from django.shortcuts import HttpResponseRedirect
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
from django.views.generic import DetailView, ListView
 | 
			
		||||
from django.forms import HiddenInput
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
from django.contrib import messages
 | 
			
		||||
 | 
			
		||||
from djmoney.contrib.exchange.models import convert_money
 | 
			
		||||
from djmoney.contrib.exchange.exceptions import MissingRate
 | 
			
		||||
 | 
			
		||||
from PIL import Image
 | 
			
		||||
 | 
			
		||||
import requests
 | 
			
		||||
import os
 | 
			
		||||
import io
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
from decimal import Decimal
 | 
			
		||||
 | 
			
		||||
from .models import PartCategory, Part
 | 
			
		||||
from .models import PartParameterTemplate
 | 
			
		||||
from .models import PartCategoryParameterTemplate
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
from django.contrib import messages
 | 
			
		||||
from django.core.exceptions import ValidationError
 | 
			
		||||
from django.core.files.base import ContentFile
 | 
			
		||||
from django.db import transaction
 | 
			
		||||
from django.db.utils import IntegrityError
 | 
			
		||||
from django.forms import HiddenInput
 | 
			
		||||
from django.shortcuts import HttpResponseRedirect, get_object_or_404
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django.views.generic import DetailView, ListView
 | 
			
		||||
 | 
			
		||||
from common.models import InvenTreeSetting
 | 
			
		||||
from company.models import SupplierPart
 | 
			
		||||
from common.files import FileManager
 | 
			
		||||
from common.views import FileManagementFormView, FileManagementAjaxView
 | 
			
		||||
 | 
			
		||||
from stock.models import StockItem, StockLocation
 | 
			
		||||
import requests
 | 
			
		||||
from djmoney.contrib.exchange.exceptions import MissingRate
 | 
			
		||||
from djmoney.contrib.exchange.models import convert_money
 | 
			
		||||
from PIL import Image
 | 
			
		||||
 | 
			
		||||
import common.settings as inventree_settings
 | 
			
		||||
from common.files import FileManager
 | 
			
		||||
from common.models import InvenTreeSetting
 | 
			
		||||
from common.views import FileManagementAjaxView, FileManagementFormView
 | 
			
		||||
from company.models import SupplierPart
 | 
			
		||||
from InvenTree.helpers import str2bool
 | 
			
		||||
from InvenTree.views import (AjaxCreateView, AjaxDeleteView, AjaxUpdateView,
 | 
			
		||||
                             AjaxView, InvenTreeRoleMixin, QRCodeView)
 | 
			
		||||
from order.models import PurchaseOrderLineItem
 | 
			
		||||
from plugin.views import InvenTreePluginViewMixin
 | 
			
		||||
from stock.models import StockItem, StockLocation
 | 
			
		||||
 | 
			
		||||
from . import forms as part_forms
 | 
			
		||||
from . import settings as part_settings
 | 
			
		||||
from .bom import MakeBomTemplate, ExportBom, IsValidBOMFormat
 | 
			
		||||
from order.models import PurchaseOrderLineItem
 | 
			
		||||
 | 
			
		||||
from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView
 | 
			
		||||
from InvenTree.views import QRCodeView
 | 
			
		||||
from InvenTree.views import InvenTreeRoleMixin
 | 
			
		||||
 | 
			
		||||
from InvenTree.helpers import str2bool
 | 
			
		||||
 | 
			
		||||
from plugin.views import InvenTreePluginViewMixin
 | 
			
		||||
from .bom import ExportBom, IsValidBOMFormat, MakeBomTemplate
 | 
			
		||||
from .models import (Part, PartCategory, PartCategoryParameterTemplate,
 | 
			
		||||
                     PartParameterTemplate)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PartIndex(InvenTreeRoleMixin, ListView):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user