Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PixieDust-LastMinuteSurpluss
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Erick Gabriel T. Lopez
PixieDust-LastMinuteSurpluss
Commits
d2fb0a10
Commit
d2fb0a10
authored
Dec 06, 2022
by
Bryan Carlo Guanlao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed quantity to stock in inventory model
parent
8927c5ba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
18 deletions
+92
-18
0002_alter_orderitem_discount.py
...e_dust/orders/migrations/0002_alter_orderitem_discount.py
+19
-0
admin.py
pixie_dust/products/admin.py
+11
-2
0002_auto_20221206_1304.py
pixie_dust/products/migrations/0002_auto_20221206_1304.py
+17
-0
models.py
pixie_dust/products/models.py
+45
-16
No files found.
pixie_dust/orders/migrations/0002_alter_orderitem_discount.py
0 → 100644
View file @
d2fb0a10
# 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
)]),
),
]
pixie_dust/products/admin.py
View file @
d2fb0a10
...
...
@@ -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
)
pixie_dust/products/migrations/0002_auto_20221206_1304.py
0 → 100644
View file @
d2fb0a10
# 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'
)
]
pixie_dust/products/models.py
View file @
d2fb0a10
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment