diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 3d4feef93a..2af1077205 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -1,7 +1,5 @@ """ -Build models - -Defines the database models for part Builds +Build database model definitions """ # -*- coding: utf-8 -*- diff --git a/InvenTree/company/api.py b/InvenTree/company/api.py index d90cfdb1ee..dfa3ebfb77 100644 --- a/InvenTree/company/api.py +++ b/InvenTree/company/api.py @@ -1,3 +1,7 @@ +""" +Provides a JSON API for the Company app +""" + # -*- coding: utf-8 -*- from __future__ import unicode_literals @@ -12,6 +16,13 @@ from .serializers import CompanySerializer class CompanyList(generics.ListCreateAPIView): + """ API endpoint for accessing a list of Company objects + + Provides two methods: + + - GET: Return list of objects + - POST: Create a new Company object + """ serializer_class = CompanySerializer queryset = Company.objects.all() @@ -44,6 +55,7 @@ class CompanyList(generics.ListCreateAPIView): class CompanyDetail(generics.RetrieveUpdateDestroyAPIView): + """ API endpoint for detail of a single Company object """ queryset = Company.objects.all() serializer_class = CompanySerializer diff --git a/InvenTree/company/forms.py b/InvenTree/company/forms.py index 7fca7c7e72..7bb9e382c9 100644 --- a/InvenTree/company/forms.py +++ b/InvenTree/company/forms.py @@ -1,3 +1,7 @@ +""" +Django Forms for interacting with Company objects +""" + # -*- coding: utf-8 -*- from __future__ import unicode_literals @@ -7,6 +11,7 @@ from .models import Company class EditCompanyForm(HelperForm): + """ Form for editing a Company object """ class Meta: model = Company @@ -26,6 +31,7 @@ class EditCompanyForm(HelperForm): class CompanyImageForm(HelperForm): + """ Form for uploading a Company image """ class Meta: model = Company diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index fe97d9a90c..dcee37959d 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -1,3 +1,7 @@ +""" +Company database model definitions +""" + # -*- coding: utf-8 -*- from __future__ import unicode_literals @@ -8,6 +12,16 @@ from django.urls import reverse def rename_company_image(instance, filename): + """ Function to rename a company image after upload + + Args: + instance: Company object + filename: uploaded image filename + + Returns: + New image filename + """ + base = 'company_images' if filename.count('.') > 0: @@ -24,6 +38,9 @@ def rename_company_image(instance, filename): class Company(models.Model): + """ A Company object represents an external company. + It may be a supplier or a customer (or both). + """ name = models.CharField(max_length=100, unique=True, help_text='Company name') @@ -54,21 +71,28 @@ class Company(models.Model): is_supplier = models.BooleanField(default=True) def __str__(self): + """ Get string representation of a Company """ return "{n} - {d}".format(n=self.name, d=self.description) def get_absolute_url(self): + """ Get the web URL for the detail view for this Company """ return reverse('company-detail', kwargs={'pk': self.id}) @property def part_count(self): + """ The number of parts supplied by this company """ return self.parts.count() @property def has_parts(self): + """ Return True if this company supplies any parts """ return self.part_count > 0 class Contact(models.Model): + """ A Contact represents a person who works at a particular company. + A Company may have zero or more associated Contact objects + """ name = models.CharField(max_length=100)