mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	| @@ -7,4 +7,4 @@ before_install: | |||||||
|      |      | ||||||
| script: | script: | ||||||
|     # TODO - Only perform PEP8 checks on files that have been changed in this push / PR |     # TODO - Only perform PEP8 checks on files that have been changed in this push / PR | ||||||
|     - find . -name \*.py -exec pep8 --ignore=E402,W293 {} + |     - find . -name \*.py -exec pep8 --ignore=E402,W293,E501 {} + | ||||||
| @@ -4,6 +4,7 @@ from django.db import models | |||||||
| from django.core.exceptions import ObjectDoesNotExist | from django.core.exceptions import ObjectDoesNotExist | ||||||
| from django.contrib.contenttypes.models import ContentType | from django.contrib.contenttypes.models import ContentType | ||||||
|  |  | ||||||
|  |  | ||||||
| class Company(models.Model): | class Company(models.Model): | ||||||
|     """ Abstract model representing an external company |     """ Abstract model representing an external company | ||||||
|     """ |     """ | ||||||
| @@ -26,6 +27,7 @@ class Company(models.Model): | |||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return self.name |         return self.name | ||||||
|  |  | ||||||
|  |  | ||||||
| class InvenTreeTree(models.Model): | class InvenTreeTree(models.Model): | ||||||
|     """ Provides an abstracted self-referencing tree model for data categories. |     """ Provides an abstracted self-referencing tree model for data categories. | ||||||
|     - Each Category has one parent Category, which can be blank (for a top-level Category). |     - Each Category has one parent Category, which can be blank (for a top-level Category). | ||||||
| @@ -41,7 +43,6 @@ class InvenTreeTree(models.Model): | |||||||
|                                on_delete=models.CASCADE, |                                on_delete=models.CASCADE, | ||||||
|                                blank=True, |                                blank=True, | ||||||
|                                null=True) |                                null=True) | ||||||
|                                #limit_choices_to={id: getAcceptableParents}) |  | ||||||
|      |      | ||||||
|     def getUniqueChildren(self, unique=None): |     def getUniqueChildren(self, unique=None): | ||||||
|         """ Return a flat set of all child items that exist under this node. |         """ Return a flat set of all child items that exist under this node. | ||||||
| @@ -120,7 +121,8 @@ class InvenTreeTree(models.Model): | |||||||
|         """ |         """ | ||||||
|          |          | ||||||
|         if attrname == 'parent_id': |         if attrname == 'parent_id': | ||||||
|             # If current ID is None, continue (as this object is just being created) |             # If current ID is None, continue | ||||||
|  |             # - This object is just being created | ||||||
|             if self.id is None: |             if self.id is None: | ||||||
|                 pass |                 pass | ||||||
|             # Parent cannot be set to same ID (this would cause looping) |             # Parent cannot be set to same ID (this would cause looping) | ||||||
|   | |||||||
| @@ -2,15 +2,15 @@ from django.contrib import admin | |||||||
|  |  | ||||||
| from .models import PartCategory, Part | from .models import PartCategory, Part | ||||||
|  |  | ||||||
|  |  | ||||||
| class PartAdmin(admin.ModelAdmin): | class PartAdmin(admin.ModelAdmin): | ||||||
|      |      | ||||||
|     list_display = ('name', 'IPN', 'stock', 'category') |     list_display = ('name', 'IPN', 'stock', 'category') | ||||||
|  |  | ||||||
| # Custom form for PartCategory |  | ||||||
| class PartCategoryAdmin(admin.ModelAdmin): | class PartCategoryAdmin(admin.ModelAdmin): | ||||||
|      |      | ||||||
|     list_display = ('name', 'path', 'description') |     list_display = ('name', 'path', 'description') | ||||||
|      |      | ||||||
|      |  | ||||||
| admin.site.register(Part, PartAdmin) | admin.site.register(Part, PartAdmin) | ||||||
| admin.site.register(PartCategory, PartCategoryAdmin) | admin.site.register(PartCategory, PartCategoryAdmin) | ||||||
| @@ -6,6 +6,7 @@ from django.core.exceptions import ObjectDoesNotExist | |||||||
|  |  | ||||||
| from InvenTree.models import InvenTreeTree | from InvenTree.models import InvenTreeTree | ||||||
|  |  | ||||||
|  |  | ||||||
| class PartCategory(InvenTreeTree): | class PartCategory(InvenTreeTree): | ||||||
|     """ PartCategory provides hierarchical organization of Part objects. |     """ PartCategory provides hierarchical organization of Part objects. | ||||||
|     """ |     """ | ||||||
| @@ -14,6 +15,7 @@ class PartCategory(InvenTreeTree): | |||||||
|         verbose_name = "Part Category" |         verbose_name = "Part Category" | ||||||
|         verbose_name_plural = "Part Categories" |         verbose_name_plural = "Part Categories" | ||||||
|          |          | ||||||
|  |          | ||||||
| class Part(models.Model): | class Part(models.Model): | ||||||
|     """ Represents a """ |     """ Represents a """ | ||||||
|      |      | ||||||
| @@ -74,6 +76,7 @@ class Part(models.Model): | |||||||
|                  |                  | ||||||
|         return projects |         return projects | ||||||
|  |  | ||||||
|  |  | ||||||
| class PartRevision(models.Model): | class PartRevision(models.Model): | ||||||
|     """ A PartRevision represents a change-notification to a Part |     """ A PartRevision represents a change-notification to a Part | ||||||
|     A Part may go through several revisions in its lifetime, |     A Part may go through several revisions in its lifetime, | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ from rest_framework import serializers | |||||||
|  |  | ||||||
| from .models import Part, PartCategory | from .models import Part, PartCategory | ||||||
|  |  | ||||||
|  |  | ||||||
| class PartSerializer(serializers.ModelSerializer): | class PartSerializer(serializers.ModelSerializer): | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = Part |         model = Part | ||||||
| @@ -11,6 +12,7 @@ class PartSerializer(serializers.ModelSerializer): | |||||||
|                   'category', |                   'category', | ||||||
|                   'stock') |                   'stock') | ||||||
|          |          | ||||||
|  |          | ||||||
| class PartCategorySerializer(serializers.ModelSerializer): | class PartCategorySerializer(serializers.ModelSerializer): | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = PartCategory |         model = PartCategory | ||||||
|   | |||||||
| @@ -6,24 +6,29 @@ from rest_framework import generics | |||||||
| from .models import PartCategory, Part | from .models import PartCategory, Part | ||||||
| from .serializers import PartSerializer, PartCategorySerializer | from .serializers import PartSerializer, PartCategorySerializer | ||||||
|  |  | ||||||
|  |  | ||||||
| def index(request): | def index(request): | ||||||
|     return HttpResponse("Hello world. This is the parts page") |     return HttpResponse("Hello world. This is the parts page") | ||||||
|  |  | ||||||
|  |  | ||||||
| class PartDetail(generics.RetrieveAPIView): | class PartDetail(generics.RetrieveAPIView): | ||||||
|  |  | ||||||
|     queryset = Part.objects.all() |     queryset = Part.objects.all() | ||||||
|     serializer_class = PartSerializer |     serializer_class = PartSerializer | ||||||
|  |  | ||||||
|  |  | ||||||
| class PartList(generics.ListAPIView): | class PartList(generics.ListAPIView): | ||||||
|  |  | ||||||
|     queryset = Part.objects.all() |     queryset = Part.objects.all() | ||||||
|     serializer_class = PartSerializer |     serializer_class = PartSerializer | ||||||
|  |  | ||||||
|  |  | ||||||
| class PartCategoryDetail(generics.RetrieveAPIView): | class PartCategoryDetail(generics.RetrieveAPIView): | ||||||
|      |      | ||||||
|     queryset = PartCategory.objects.all() |     queryset = PartCategory.objects.all() | ||||||
|     serializer_class = PartCategorySerializer |     serializer_class = PartCategorySerializer | ||||||
|  |  | ||||||
|  |  | ||||||
| class PartCategoryList(generics.ListAPIView): | class PartCategoryList(generics.ListAPIView): | ||||||
|  |  | ||||||
|     queryset = PartCategory.objects.all() |     queryset = PartCategory.objects.all() | ||||||
|   | |||||||
| @@ -2,12 +2,15 @@ from django.contrib import admin | |||||||
|  |  | ||||||
| from .models import ProjectCategory, Project, ProjectPart | from .models import ProjectCategory, Project, ProjectPart | ||||||
|  |  | ||||||
|  |  | ||||||
| class ProjectCategoryAdmin(admin.ModelAdmin): | class ProjectCategoryAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('name', 'path', 'description') |     list_display = ('name', 'path', 'description') | ||||||
|  |  | ||||||
|  |  | ||||||
| class ProjectAdmin(admin.ModelAdmin): | class ProjectAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('name', 'description', 'category') |     list_display = ('name', 'description', 'category') | ||||||
|  |  | ||||||
|  |  | ||||||
| class ProjectPartAdmin(admin.ModelAdmin): | class ProjectPartAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('part', 'project', 'quantity') |     list_display = ('part', 'project', 'quantity') | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ from django.db import models | |||||||
| from InvenTree.models import InvenTreeTree | from InvenTree.models import InvenTreeTree | ||||||
| from part.models import Part | from part.models import Part | ||||||
|  |  | ||||||
|  |  | ||||||
| class ProjectCategory(InvenTreeTree): | class ProjectCategory(InvenTreeTree): | ||||||
|     """ ProjectCategory provides hierarchical organization of Project objects. |     """ ProjectCategory provides hierarchical organization of Project objects. | ||||||
|     Each ProjectCategory can contain zero-or-more child categories, |     Each ProjectCategory can contain zero-or-more child categories, | ||||||
| @@ -15,6 +16,7 @@ class ProjectCategory(InvenTreeTree): | |||||||
|         verbose_name = "Project Category" |         verbose_name = "Project Category" | ||||||
|         verbose_name_plural = "Project Categories" |         verbose_name_plural = "Project Categories" | ||||||
|  |  | ||||||
|  |  | ||||||
| class Project(models.Model): | class Project(models.Model): | ||||||
|     """ A Project takes multiple Part objects. |     """ A Project takes multiple Part objects. | ||||||
|     A project can output zero-or-more Part objects |     A project can output zero-or-more Part objects | ||||||
| @@ -33,6 +35,7 @@ class Project(models.Model): | |||||||
|         """ |         """ | ||||||
|         return self.projectpart_set.all() |         return self.projectpart_set.all() | ||||||
|  |  | ||||||
|  |  | ||||||
| class ProjectPart(models.Model): | class ProjectPart(models.Model): | ||||||
|     """ A project part associates a single part with a project |     """ A project part associates a single part with a project | ||||||
|     The quantity of parts required for a single-run of that project is stored. |     The quantity of parts required for a single-run of that project is stored. | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| from django.shortcuts import render, get_object_or_404 | from django.shortcuts import render, get_object_or_404 | ||||||
| from django.http import HttpResponse | from django.http import HttpResponse | ||||||
|  |  | ||||||
|  |  | ||||||
| def index(request): | def index(request): | ||||||
|     return HttpResponse("This is the Projects page") |     return HttpResponse("This is the Projects page") | ||||||
| @@ -2,9 +2,11 @@ from django.contrib import admin | |||||||
|  |  | ||||||
| from .models import Warehouse, StockItem | from .models import Warehouse, StockItem | ||||||
|  |  | ||||||
|  |  | ||||||
| class WarehouseAdmin(admin.ModelAdmin): | class WarehouseAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('name', 'path', 'description') |     list_display = ('name', 'path', 'description') | ||||||
|  |  | ||||||
|  |  | ||||||
| class StockItemAdmin(admin.ModelAdmin): | class StockItemAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('part', 'quantity', 'location', 'status', 'updated') |     list_display = ('part', 'quantity', 'location', 'status', 'updated') | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,9 +5,11 @@ from django.db import models | |||||||
| from part.models import Part | from part.models import Part | ||||||
| from InvenTree.models import InvenTreeTree | from InvenTree.models import InvenTreeTree | ||||||
|  |  | ||||||
|  |  | ||||||
| class Warehouse(InvenTreeTree): | class Warehouse(InvenTreeTree): | ||||||
|     pass |     pass | ||||||
|      |      | ||||||
|  |  | ||||||
| class StockItem(models.Model): | class StockItem(models.Model): | ||||||
|     part = models.ForeignKey(Part, |     part = models.ForeignKey(Part, | ||||||
|                              on_delete=models.CASCADE) |                              on_delete=models.CASCADE) | ||||||
|   | |||||||
| @@ -3,10 +3,9 @@ from django.http import HttpResponse | |||||||
|  |  | ||||||
| from .models import Warehouse, StockItem | from .models import Warehouse, StockItem | ||||||
|  |  | ||||||
|  |  | ||||||
| def index(request): | def index(request): | ||||||
|      |      | ||||||
|     warehouses = Warehouse.objects.filter(parent=None) |     warehouses = Warehouse.objects.filter(parent=None) | ||||||
|      |      | ||||||
|     return render(request, 'stock/index.html', |     return render(request, 'stock/index.html', {'warehouses': warehouses}) | ||||||
|                   {'warehouses': warehouses |  | ||||||
|                   }) |  | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ from django.contrib import admin | |||||||
|  |  | ||||||
| from .models import Supplier, SupplierPart, Customer | from .models import Supplier, SupplierPart, Customer | ||||||
|  |  | ||||||
|  |  | ||||||
| class CompanyAdmin(admin.ModelAdmin): | class CompanyAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('name', 'URL', 'contact') |     list_display = ('name', 'URL', 'contact') | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,6 +14,8 @@ class Supplier(Company): | |||||||
|  |  | ||||||
|  |  | ||||||
| class Customer(Company): | class Customer(Company): | ||||||
|  |     """ Represents a customer | ||||||
|  |     """ | ||||||
|     pass |     pass | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -31,8 +33,7 @@ class SupplierPart(models.Model): | |||||||
|  |  | ||||||
|     MPN = models.CharField(max_length=100) |     MPN = models.CharField(max_length=100) | ||||||
|     URL = models.URLField(blank=True) |     URL = models.URLField(blank=True) | ||||||
|     description = models.CharField(max_length=250, |     description = models.CharField(max_length=250, blank=True) | ||||||
|                                    blank=True) |  | ||||||
|  |  | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return "{mpn} - {supplier}".format( |         return "{mpn} - {supplier}".format( | ||||||
|   | |||||||
| @@ -3,9 +3,11 @@ from django.http import HttpResponse | |||||||
|  |  | ||||||
| from .models import Supplier | from .models import Supplier | ||||||
|  |  | ||||||
|  |  | ||||||
| def index(request): | def index(request): | ||||||
|     return HttpResponse("This is the suppliers page") |     return HttpResponse("This is the suppliers page") | ||||||
|  |  | ||||||
|  |  | ||||||
| def supplierDetail(request, supplier_id): | def supplierDetail(request, supplier_id): | ||||||
|     supplier = get_object_or_404(Supplier, pk=supplier_id) |     supplier = get_object_or_404(Supplier, pk=supplier_id) | ||||||
|      |      | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ from django.contrib import admin | |||||||
|  |  | ||||||
| from .models import UniquePart | from .models import UniquePart | ||||||
|  |  | ||||||
|  |  | ||||||
| class UniquePartAdmin(admin.ModelAdmin): | class UniquePartAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('part', 'revision', 'serial', 'creation_date') |     list_display = ('part', 'revision', 'serial', 'creation_date') | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| from django.shortcuts import render, get_object_or_404 | from django.shortcuts import render, get_object_or_404 | ||||||
| from django.http import HttpResponse | from django.http import HttpResponse | ||||||
|  |  | ||||||
|  |  | ||||||
| def index(request): | def index(request): | ||||||
|     return HttpResponse("This is the Tracking page") |     return HttpResponse("This is the Tracking page") | ||||||
		Reference in New Issue
	
	Block a user