Added PartCategory

- Parent can be null (top-level category)
- Parent can be other PartCategory
This commit is contained in:
Oliver Walters 2017-03-25 23:07:43 +11:00
parent 2863ea1b70
commit bb4fc9820f
10 changed files with 47 additions and 63 deletions

64
.gitignore vendored
View File

@ -3,9 +3,6 @@ __pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
@ -24,66 +21,9 @@ var/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# IPython Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# dotenv
.env
# virtualenv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
*.sqlite3
**/migrations/*

View File

@ -37,6 +37,8 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'part.apps.PartConfig'
]
MIDDLEWARE = [

View File

@ -13,9 +13,10 @@ Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^part/', include('part.urls')),
url(r'^admin/', admin.site.urls),
]

View File

5
InvenTree/part/admin.py Normal file
View File

@ -0,0 +1,5 @@
from django.contrib import admin
from .models import PartCategory
admin.site.register(PartCategory)

7
InvenTree/part/apps.py Normal file
View File

@ -0,0 +1,7 @@
from __future__ import unicode_literals
from django.apps import AppConfig
class PartConfig(AppConfig):
name = 'part'

14
InvenTree/part/models.py Normal file
View File

@ -0,0 +1,14 @@
from __future__ import unicode_literals
from django.db import models
class PartCategory(models.Model):
name = models.CharField(max_length=128)
description = models.CharField(max_length=512)
parent = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True)
def __str__(self):
if self.parent:
return str(self.parent) + "/" + self.name
else:
return self.name

3
InvenTree/part/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
InvenTree/part/urls.py Normal file
View File

@ -0,0 +1,7 @@
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index')
]

5
InvenTree/part/views.py Normal file
View File

@ -0,0 +1,5 @@
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello world. This is the parts page")