mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Added Project category
This commit is contained in:
parent
8229f02db6
commit
5420f83114
@ -39,6 +39,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
'part.apps.PartConfig',
|
||||
'project.apps.ProjectConfig',
|
||||
'stock.apps.StockConfig',
|
||||
'supplier.apps.SupplierConfig',
|
||||
'track.apps.TrackConfig'
|
||||
|
@ -24,5 +24,6 @@ urlpatterns = [
|
||||
url(r'^part/', include('part.urls')),
|
||||
url(r'^supplier/', include('supplier.urls')),
|
||||
url(r'^track/', include('track.urls')),
|
||||
url(r'^project/', include('project.urls')),
|
||||
url(r'^admin/', admin.site.urls),
|
||||
]
|
||||
|
0
InvenTree/project/__init__.py
Normal file
0
InvenTree/project/__init__.py
Normal file
7
InvenTree/project/admin.py
Normal file
7
InvenTree/project/admin.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import ProjectCategory, Project, ProjectPart
|
||||
|
||||
admin.site.register(ProjectCategory)
|
||||
admin.site.register(Project)
|
||||
admin.site.register(ProjectPart)
|
7
InvenTree/project/apps.py
Normal file
7
InvenTree/project/apps.py
Normal file
@ -0,0 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ProjectConfig(AppConfig):
|
||||
name = 'project'
|
54
InvenTree/project/models.py
Normal file
54
InvenTree/project/models.py
Normal file
@ -0,0 +1,54 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
|
||||
from InvenTree.models import InvenTreeTree
|
||||
from part.models import Part
|
||||
|
||||
class ProjectCategory(InvenTreeTree):
|
||||
""" ProjectCategory provides hierarchical organization of Project objects.
|
||||
Each ProjectCategory can contain zero-or-more child categories,
|
||||
and in turn can have zero-or-one parent category.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Project Category"
|
||||
verbose_name_plural = "Project Categories"
|
||||
|
||||
class Project(models.Model):
|
||||
""" A Project takes multiple Part objects.
|
||||
A project can output zero-or-more Part objects
|
||||
"""
|
||||
|
||||
name = models.CharField(max_length=100)
|
||||
description = models.CharField(max_length=500, blank=True)
|
||||
category = models.ForeignKey(ProjectCategory, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class ProjectPart(models.Model):
|
||||
""" 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 overage is the number of extra parts that are generally used for a single run.
|
||||
"""
|
||||
|
||||
# Overage types
|
||||
OVERAGE_PERCENT = 0
|
||||
OVERAGE_ABSOLUTE = 1
|
||||
|
||||
part = models.ForeignKey(Part, on_delete=models.CASCADE)
|
||||
project = models.ForeignKey(Project, on_delete=models.CASCADE)
|
||||
quantity = models.IntegerField()
|
||||
overage = models.FloatField()
|
||||
overage_type = models.IntegerField(
|
||||
choices=[
|
||||
(OVERAGE_PERCENT, "Percent"),
|
||||
(OVERAGE_ABSOLUTE, "Absolute")
|
||||
])
|
||||
|
||||
def __str__(self):
|
||||
return "{quan} x {name}".format(
|
||||
name = self.part.name,
|
||||
quan = self.quantity)
|
3
InvenTree/project/tests.py
Normal file
3
InvenTree/project/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
7
InvenTree/project/urls.py
Normal file
7
InvenTree/project/urls.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.index, name='index')
|
||||
]
|
5
InvenTree/project/views.py
Normal file
5
InvenTree/project/views.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.http import HttpResponse
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("This is the Projects page")
|
7
InvenTree/track/urls.py
Normal file
7
InvenTree/track/urls.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.index, name='index')
|
||||
]
|
Loading…
Reference in New Issue
Block a user