From 14f60e12926848ef119be184037389ec0817729c Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 28 Mar 2017 23:29:00 +1100 Subject: [PATCH] Pepsi --- .travis.yml | 2 +- InvenTree/InvenTree/models.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2b3ac04c3c..2c432d58d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,4 @@ before_install: script: # TODO - Only perform PEP8 checks on files that have been changed in this push / PR - - find . -name \*.py -exec pep8 --ignore=E402,W293 {} + \ No newline at end of file + - find . -name \*.py -exec pep8 --ignore=E402,W293,E501 {} + \ No newline at end of file diff --git a/InvenTree/InvenTree/models.py b/InvenTree/InvenTree/models.py index efbddf5fc6..471f1b17d7 100644 --- a/InvenTree/InvenTree/models.py +++ b/InvenTree/InvenTree/models.py @@ -4,6 +4,7 @@ from django.db import models from django.core.exceptions import ObjectDoesNotExist from django.contrib.contenttypes.models import ContentType + class Company(models.Model): """ Abstract model representing an external company """ @@ -22,10 +23,11 @@ class Company(models.Model): blank=True) notes = models.CharField(max_length=500, blank=True) - + def __str__(self): return self.name + class InvenTreeTree(models.Model): """ 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). @@ -58,7 +60,7 @@ class InvenTreeTree(models.Model): # Some magic to get around the limitations of abstract models contents = ContentType.objects.get_for_model(type(self)) - children = contents.get_all_objects_for_this_type(parent = self.id) + children = contents.get_all_objects_for_this_type(parent=self.id) for child in children: child.getUniqueChildren(unique) @@ -120,7 +122,8 @@ class InvenTreeTree(models.Model): """ 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: pass # Parent cannot be set to same ID (this would cause looping) @@ -134,13 +137,13 @@ class InvenTreeTree(models.Model): kids = self.getUniqueChildren() if val in kids: return - + # Prohibit certain characters from tree node names elif attrname == 'name': val = val.translate({ord(c): None for c in "!@#$%^&*'\"\\/[]{}<>,|+=~`"}) super(InvenTreeTree, self).__setattr__(attrname, val) - + def __str__(self): """ String representation of a category is the full path to that category @@ -148,4 +151,4 @@ class InvenTreeTree(models.Model): This is recursive - Make it not so. """ - return self.path \ No newline at end of file + return self.path