Commit d2fb0a10 authored by Bryan Carlo Guanlao's avatar Bryan Carlo Guanlao

renamed quantity to stock in inventory model

parent 8927c5ba
# Generated by Django 3.2.12 on 2022-12-06 04:56
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('orders', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='orderitem',
name='discount',
field=models.IntegerField(default=0, validators=[django.core.validators.MaxValueValidator(100), django.core.validators.MinValueValidator(0)]),
),
]
......@@ -3,31 +3,40 @@ from django.db.models.functions import Lower
from .models import Product, Feature, Folder, PenOrganizer, Planner, Description, Inventory
# Register your models here.
class ProductAdmin(admin.ModelAdmin):
model = Product
class FeatureAdmin(admin.ModelAdmin):
model = Feature
class FolderAdmin(admin.ModelAdmin):
model = Folder
class PenOrganizerAdmin(admin.ModelAdmin):
model = PenOrganizer
class PlannerAdmin(admin.ModelAdmin):
model = Planner
class DescriptionAdmin(admin.ModelAdmin):
model = Description
class InventoryAdmin(admin.ModelAdmin):
model = Inventory
list_display = ('quantity', 'item_id', 'color', )
list_display = ('stock', 'item_id', 'color', )
admin.site.register(Feature, FeatureAdmin)
admin.site.register(Folder, FolderAdmin)
admin.site.register(PenOrganizer, PenOrganizerAdmin)
admin.site.register(Planner, PlannerAdmin)
admin.site.register(Description, DescriptionAdmin)
admin.site.register(Inventory, InventoryAdmin)
\ No newline at end of file
admin.site.register(Inventory, InventoryAdmin)
# Generated by Django 3.2.12 on 2022-12-06 05:04
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('products', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='Inventory',
old_name='quantity',
new_name='stock')
]
......@@ -2,13 +2,18 @@ from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator
# Create your models here.
class Product(models.Model):
item_id = models.AutoField(primary_key=True)
item_name = models.CharField(max_length=50)
price = models.PositiveIntegerField(help_text='in pesos')
personalization_limit = models.PositiveIntegerField(help_text='up how many letters?')
personalization_limit = models.PositiveIntegerField(
help_text='up how many letters?')
def __str__(self):
return "#" + str(self.item_id) + " (" + self.item_name + ")"
class Meta:
db_table = "product"
......@@ -16,49 +21,73 @@ class Product(models.Model):
class Feature(models.Model):
feature_id = models.AutoField(primary_key=True)
feature = models.CharField(max_length=50)
Product = models.ManyToManyField(Product, through='Description', through_fields=('feature_id', 'item_id'))
Product = models.ManyToManyField(
Product, through='Description', through_fields=('feature_id', 'item_id'))
def __str__(self):
return "#" + str(self.feature_id) + " (" + self.feature + ")"
class Meta:
db_table = "feature"
class Folder(Product):
collection = models.CharField(max_length=20, default="F", editable=False)
length = models.DecimalField(max_digits=10, decimal_places=2, help_text='in inches')
width = models.DecimalField(max_digits=10, decimal_places=2, help_text='in inches')
thickness = models.DecimalField(max_digits=10, decimal_places=2, help_text='in inches')
length = models.DecimalField(
max_digits=10, decimal_places=2, help_text='in inches')
width = models.DecimalField(
max_digits=10, decimal_places=2, help_text='in inches')
thickness = models.DecimalField(
max_digits=10, decimal_places=2, help_text='in inches')
class Meta:
db_table = "folder"
class PenOrganizer(Product):
collection = models.CharField(max_length=20, default="PO", editable=False)
slots = models.PositiveIntegerField()
class Meta:
db_table = "pen_organizer"
class Planner(Product):
collection = models.CharField(max_length=20, default="P", editable=False)
length = models.DecimalField(max_digits=10, decimal_places=2, help_text='in inches')
width = models.DecimalField(max_digits=10, decimal_places=2, help_text='in inches')
thickness = models.DecimalField(max_digits=10, decimal_places=2, help_text='in inches')
length = models.DecimalField(
max_digits=10, decimal_places=2, help_text='in inches')
width = models.DecimalField(
max_digits=10, decimal_places=2, help_text='in inches')
thickness = models.DecimalField(
max_digits=10, decimal_places=2, help_text='in inches')
class Meta:
db_table = "planner"
class Description(models.Model):
item_id = models.ForeignKey(Product, on_delete=models.CASCADE, db_column='item_id')
feature_id = models.ForeignKey(Feature, on_delete=models.CASCADE, db_column='feature_id')
item_id = models.ForeignKey(
Product, on_delete=models.CASCADE, db_column='item_id')
feature_id = models.ForeignKey(
Feature, on_delete=models.CASCADE, db_column='feature_id')
def __str__(self):
return "Feature " + str(self.feature_id) + " added to item " + str(self.item_id)
class Meta:
db_table = "description"
class Inventory(models.Model):
item_id = models.ForeignKey(Product, on_delete=models.CASCADE, db_column='item_id')
color = models.CharField(max_length=20, choices=(("RED","Red"), ("ORANGE","Orange"), ("YELLOW", "Yellow"),
("GREEN", "Green"), ("BLUE", "Blue"), ("PURPLE", "Purple"), ("PINK", "Pink"), ("BLACK", "Black")))
quantity = models.IntegerField(default=1, validators=[MaxValueValidator(99), MinValueValidator(0)])
item_id = models.ForeignKey(
Product, on_delete=models.CASCADE, db_column='item_id')
color = models.CharField(max_length=20, choices=(("RED", "Red"), ("ORANGE", "Orange"), ("YELLOW", "Yellow"),
("GREEN", "Green"), ("BLUE", "Blue"), ("PURPLE", "Purple"), ("PINK", "Pink"), ("BLACK", "Black")))
stock = models.IntegerField(default=1, validators=[
MaxValueValidator(99), MinValueValidator(0)])
def __str__(self):
return str(self.quantity) + " pcs of " + self.color.lower() + " " + self.item_id.item_name + "'s left"
return str(self.stock) + " pcs of " + self.color.lower() + " " + self.item_id.item_name + "'s left"
class Meta:
db_table = "Inventory"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment