mirror of
https://github.com/inventree/InvenTree.git
synced 2025-12-14 08:19:54 +00:00
Docstring checks in QC checks (#3089)
* Add pre-commit to the stack * exclude static * Add locales to excludes * fix style errors * rename pipeline steps * also wait on precommit * make template matching simpler * Use the same code for python setup everywhere * use step and cache for python setup * move regular settings up into general envs * just use full update * Use invoke instead of static references * make setup actions more similar * use python3 * refactor names to be similar * fix runner version * fix references * remove incidential change * use matrix for os * Github can't do this right now * ignore docstyle errors * Add seperate docstring test * update flake call * do not fail on docstring * refactor setup into workflow * update reference * switch to action * resturcture * add bash statements * remove os from cache * update input checks * make code cleaner * fix boolean * no relative paths * install wheel by python * switch to install * revert back to simple wheel * refactor import export tests * move setup keys back to not disturbe tests * remove docstyle till that is fixed * update references * continue on error * add docstring test * use relativ action references * Change step / job docstrings * update to merge * reformat comments 1 * fix docstrings 2 * fix docstrings 3 * fix docstrings 4 * fix docstrings 5 * fix docstrings 6 * fix docstrings 7 * fix docstrings 8 * fix docstirns 9 * fix docstrings 10 * docstring adjustments * update the remaining docstrings * small docstring changes * fix function name * update support files for docstrings * Add missing args to docstrings * Remove outdated function * Add docstrings for the 'build' app * Make API code cleaner * add more docstrings for plugin app * Remove dead code for plugin settings No idea what that was even intended for * ignore __init__ files for docstrings * More docstrings * Update docstrings for the 'part' directory * Fixes for related_part functionality * Fix removed stuff from merge99676ee* make more consistent * Show statistics for docstrings * add more docstrings * move specific register statements to make them clearer to understant * More docstrings for common * and more docstrings * and more * simpler call * docstrings for notifications * docstrings for common/tests * Add docs for common/models * Revert "move specific register statements to make them clearer to understant" This reverts commitca96654622. * use typing here * Revert "Make API code cleaner" This reverts commit24fb68bd3e. * docstring updates for the 'users' app * Add generic Meta info to simple Meta classes * remove unneeded unique_together statements * More simple metas * Remove unnecessary format specifier * Remove extra json format specifiers * Add docstrings for the 'plugin' app * Docstrings for the 'label' app * Add missing docstrings for the 'report' app * Fix build test regression * Fix top-level files * docstrings for InvenTree/InvenTree * reduce unneeded code * add docstrings * and more docstrings * more docstrings * more docstrings for stock * more docstrings * docstrings for order/views * Docstrings for various files in the 'order' app * Docstrings for order/test_api.py * Docstrings for order/serializers.py * Docstrings for order/admin.py * More docstrings for the order app * Add docstrings for the 'company' app * Add unit tests for rebuilding the reference fields * Prune out some more dead code * remove more dead code Co-authored-by: Oliver Walters <oliver.henry.walters@gmail.com>
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
"""
|
||||
Django views for interacting with Stock app
|
||||
"""
|
||||
"""Django views for interacting with Stock app."""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
@@ -21,13 +19,14 @@ from .models import StockItem, StockItemTracking, StockLocation
|
||||
|
||||
|
||||
class StockIndex(InvenTreeRoleMixin, InvenTreePluginViewMixin, ListView):
|
||||
""" StockIndex view loads all StockLocation and StockItem object
|
||||
"""
|
||||
"""StockIndex view loads all StockLocation and StockItem object."""
|
||||
|
||||
model = StockItem
|
||||
template_name = 'stock/location.html'
|
||||
context_obect_name = 'locations'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Extend template context."""
|
||||
context = super().get_context_data(**kwargs).copy()
|
||||
|
||||
# Return all top-level locations
|
||||
@@ -48,9 +47,7 @@ class StockIndex(InvenTreeRoleMixin, InvenTreePluginViewMixin, ListView):
|
||||
|
||||
|
||||
class StockLocationDetail(InvenTreeRoleMixin, InvenTreePluginViewMixin, DetailView):
|
||||
"""
|
||||
Detailed view of a single StockLocation object
|
||||
"""
|
||||
"""Detailed view of a single StockLocation object."""
|
||||
|
||||
context_object_name = 'location'
|
||||
template_name = 'stock/location.html'
|
||||
@@ -58,7 +55,7 @@ class StockLocationDetail(InvenTreeRoleMixin, InvenTreePluginViewMixin, DetailVi
|
||||
model = StockLocation
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
||||
"""Extend template context."""
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
context['ownership_enabled'] = common.models.InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL')
|
||||
@@ -69,9 +66,7 @@ class StockLocationDetail(InvenTreeRoleMixin, InvenTreePluginViewMixin, DetailVi
|
||||
|
||||
|
||||
class StockItemDetail(InvenTreeRoleMixin, InvenTreePluginViewMixin, DetailView):
|
||||
"""
|
||||
Detailed view of a single StockItem object
|
||||
"""
|
||||
"""Detailed view of a single StockItem object."""
|
||||
|
||||
context_object_name = 'item'
|
||||
template_name = 'stock/item.html'
|
||||
@@ -79,11 +74,7 @@ class StockItemDetail(InvenTreeRoleMixin, InvenTreePluginViewMixin, DetailView):
|
||||
model = StockItem
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""
|
||||
Add information on the "next" and "previous" StockItem objects,
|
||||
based on the serial numbers.
|
||||
"""
|
||||
|
||||
"""Add information on the "next" and "previous" StockItem objects, based on the serial numbers."""
|
||||
data = super().get_context_data(**kwargs)
|
||||
|
||||
if self.object.serialized:
|
||||
@@ -103,8 +94,7 @@ class StockItemDetail(InvenTreeRoleMixin, InvenTreePluginViewMixin, DetailView):
|
||||
return data
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
""" check if item exists else return to stock index """
|
||||
|
||||
"""Check if item exists else return to stock index."""
|
||||
stock_pk = kwargs.get('pk', None)
|
||||
|
||||
if stock_pk:
|
||||
@@ -120,14 +110,14 @@ class StockItemDetail(InvenTreeRoleMixin, InvenTreePluginViewMixin, DetailView):
|
||||
|
||||
|
||||
class StockLocationQRCode(QRCodeView):
|
||||
""" View for displaying a QR code for a StockLocation object """
|
||||
"""View for displaying a QR code for a StockLocation object."""
|
||||
|
||||
ajax_form_title = _("Stock Location QR code")
|
||||
|
||||
role_required = ['stock_location.view', 'stock.view']
|
||||
|
||||
def get_qr_data(self):
|
||||
""" Generate QR code data for the StockLocation """
|
||||
"""Generate QR code data for the StockLocation."""
|
||||
try:
|
||||
loc = StockLocation.objects.get(id=self.pk)
|
||||
return loc.format_barcode()
|
||||
@@ -136,9 +126,7 @@ class StockLocationQRCode(QRCodeView):
|
||||
|
||||
|
||||
class StockItemReturnToStock(AjaxUpdateView):
|
||||
"""
|
||||
View for returning a stock item (which is assigned to a customer) to stock.
|
||||
"""
|
||||
"""View for returning a stock item (which is assigned to a customer) to stock."""
|
||||
|
||||
model = StockItem
|
||||
ajax_form_title = _("Return to Stock")
|
||||
@@ -146,29 +134,28 @@ class StockItemReturnToStock(AjaxUpdateView):
|
||||
form_class = StockForms.ReturnStockItemForm
|
||||
|
||||
def validate(self, item, form, **kwargs):
|
||||
|
||||
"""Make sure required data is there."""
|
||||
location = form.cleaned_data.get('location', None)
|
||||
|
||||
if not location:
|
||||
form.add_error('location', _('Specify a valid location'))
|
||||
|
||||
def save(self, item, form, **kwargs):
|
||||
|
||||
"""Return stock."""
|
||||
location = form.cleaned_data.get('location', None)
|
||||
|
||||
if location:
|
||||
item.returnFromCustomer(location, self.request.user)
|
||||
|
||||
def get_data(self):
|
||||
"""Set success message."""
|
||||
return {
|
||||
'success': _('Stock item returned from customer')
|
||||
}
|
||||
|
||||
|
||||
class StockItemDeleteTestData(AjaxUpdateView):
|
||||
"""
|
||||
View for deleting all test data
|
||||
"""
|
||||
"""View for deleting all test data."""
|
||||
|
||||
model = StockItem
|
||||
form_class = ConfirmForm
|
||||
@@ -177,10 +164,11 @@ class StockItemDeleteTestData(AjaxUpdateView):
|
||||
role_required = ['stock.change', 'stock.delete']
|
||||
|
||||
def get_form(self):
|
||||
"""Require confirm."""
|
||||
return ConfirmForm()
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
||||
"""Delete test data."""
|
||||
valid = False
|
||||
|
||||
stock_item = StockItem.objects.get(pk=self.kwargs['pk'])
|
||||
@@ -203,13 +191,13 @@ class StockItemDeleteTestData(AjaxUpdateView):
|
||||
|
||||
|
||||
class StockItemQRCode(QRCodeView):
|
||||
""" View for displaying a QR code for a StockItem object """
|
||||
"""View for displaying a QR code for a StockItem object."""
|
||||
|
||||
ajax_form_title = _("Stock Item QR Code")
|
||||
role_required = 'stock.view'
|
||||
|
||||
def get_qr_data(self):
|
||||
""" Generate QR code data for the StockItem """
|
||||
"""Generate QR code data for the StockItem."""
|
||||
try:
|
||||
item = StockItem.objects.get(id=self.pk)
|
||||
return item.format_barcode()
|
||||
@@ -218,9 +206,7 @@ class StockItemQRCode(QRCodeView):
|
||||
|
||||
|
||||
class StockItemConvert(AjaxUpdateView):
|
||||
"""
|
||||
View for 'converting' a StockItem to a variant of its current part.
|
||||
"""
|
||||
"""View for 'converting' a StockItem to a variant of its current part."""
|
||||
|
||||
model = StockItem
|
||||
form_class = StockForms.ConvertStockItemForm
|
||||
@@ -229,10 +215,7 @@ class StockItemConvert(AjaxUpdateView):
|
||||
context_object_name = 'item'
|
||||
|
||||
def get_form(self):
|
||||
"""
|
||||
Filter the available parts.
|
||||
"""
|
||||
|
||||
"""Filter the available parts."""
|
||||
form = super().get_form()
|
||||
item = self.get_object()
|
||||
|
||||
@@ -241,7 +224,7 @@ class StockItemConvert(AjaxUpdateView):
|
||||
return form
|
||||
|
||||
def save(self, obj, form):
|
||||
|
||||
"""Convert item to variant."""
|
||||
stock_item = self.get_object()
|
||||
|
||||
variant = form.cleaned_data.get('part', None)
|
||||
@@ -252,8 +235,8 @@ class StockItemConvert(AjaxUpdateView):
|
||||
|
||||
|
||||
class StockLocationDelete(AjaxDeleteView):
|
||||
"""
|
||||
View to delete a StockLocation
|
||||
"""View to delete a StockLocation.
|
||||
|
||||
Presents a deletion confirmation form to the user
|
||||
"""
|
||||
|
||||
@@ -265,8 +248,8 @@ class StockLocationDelete(AjaxDeleteView):
|
||||
|
||||
|
||||
class StockItemDelete(AjaxDeleteView):
|
||||
"""
|
||||
View to delete a StockItem
|
||||
"""View to delete a StockItem.
|
||||
|
||||
Presents a deletion confirmation form to the user
|
||||
"""
|
||||
|
||||
@@ -278,8 +261,8 @@ class StockItemDelete(AjaxDeleteView):
|
||||
|
||||
|
||||
class StockItemTrackingDelete(AjaxDeleteView):
|
||||
"""
|
||||
View to delete a StockItemTracking object
|
||||
"""View to delete a StockItemTracking object.
|
||||
|
||||
Presents a deletion confirmation form to the user
|
||||
"""
|
||||
|
||||
@@ -289,7 +272,7 @@ class StockItemTrackingDelete(AjaxDeleteView):
|
||||
|
||||
|
||||
class StockItemTrackingEdit(AjaxUpdateView):
|
||||
""" View for editing a StockItemTracking object """
|
||||
"""View for editing a StockItemTracking object."""
|
||||
|
||||
model = StockItemTracking
|
||||
ajax_form_title = _('Edit Stock Tracking Entry')
|
||||
@@ -297,15 +280,14 @@ class StockItemTrackingEdit(AjaxUpdateView):
|
||||
|
||||
|
||||
class StockItemTrackingCreate(AjaxCreateView):
|
||||
""" View for creating a new StockItemTracking object.
|
||||
"""
|
||||
"""View for creating a new StockItemTracking object."""
|
||||
|
||||
model = StockItemTracking
|
||||
ajax_form_title = _("Add Stock Tracking Entry")
|
||||
form_class = StockForms.TrackingEntryForm
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
||||
"""Create StockItemTracking object."""
|
||||
self.request = request
|
||||
self.form = self.get_form()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user