Made changes on models

parent 56fea83d
## Retrieved March 22 2022 from https://github.com/github/gitignore/blob/master/Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# 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/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# Visual Studio Code
settings.json
# PyCharm
.idea/
# Database files
*.dump
\ No newline at end of file
# Generated by Django 3.2.12 on 2022-11-04 19:44
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='SalesAgent',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
],
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='salesagent',
name='id',
),
migrations.AddField(
model_name='salesagent',
name='agent_id',
field=models.AutoField(default=1, primary_key=True, serialize=False),
preserve_default=False,
),
migrations.AlterModelTable(
name='salesagent',
table='sales_agent',
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:17
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0003_delete_customer'),
('adminpage', '0002_auto_20221105_0412'),
]
operations = [
migrations.DeleteModel(
name='SalesAgent',
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:18
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('adminpage', '0003_delete_salesagent'),
]
operations = [
migrations.CreateModel(
name='SalesAgent',
fields=[
('agent_id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
],
options={
'db_table': 'sales_agent',
},
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0005_delete_customer'),
('adminpage', '0004_salesagent'),
]
operations = [
migrations.DeleteModel(
name='SalesAgent',
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:22
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('adminpage', '0005_delete_salesagent'),
]
operations = [
migrations.CreateModel(
name='SalesAgent',
fields=[
('agent_id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
],
options={
'db_table': 'sales_agent',
},
),
]
# Generated by Django 3.2.12 on 2022-11-04 21:30
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0006_salesagent'),
]
operations = [
migrations.CreateModel(
name='Product',
fields=[
('item_id', models.AutoField(primary_key=True, serialize=False)),
('item_name', models.CharField(max_length=50)),
('personalization', models.CharField(max_length=254)),
('color', models.CharField(max_length=20)),
('price', models.IntegerField()),
('collection', models.CharField(max_length=50)),
],
options={
'db_table': 'product',
},
),
]
# Generated by Django 3.2.12 on 2022-11-07 22:57
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0007_product'),
]
operations = [
migrations.CreateModel(
name='Folder',
fields=[
('folder_id', models.AutoField(primary_key=True, serialize=False)),
('length', models.PositiveIntegerField(help_text='in centimeters')),
('width', models.PositiveIntegerField(help_text='in centimeters')),
('thickness', models.PositiveIntegerField(help_text='in centimeters')),
],
options={
'db_table': 'folder',
},
),
migrations.CreateModel(
name='PenOrganizer',
fields=[
('pen_org_id', models.AutoField(primary_key=True, serialize=False)),
('slots', models.PositiveIntegerField(help_text='in centimeters')),
],
options={
'db_table': 'pen_organizer',
},
),
migrations.CreateModel(
name='Planner',
fields=[
('planner_id', models.AutoField(primary_key=True, serialize=False)),
('length', models.PositiveIntegerField(help_text='in centimeters')),
('width', models.PositiveIntegerField(help_text='in centimeters')),
('thickness', models.PositiveIntegerField(help_text='in centimeters')),
],
options={
'db_table': 'planner',
},
),
migrations.AlterField(
model_name='product',
name='collection',
field=models.CharField(choices=[('F', 'Folder'), ('PO', 'Pen Organizer'), ('P', 'Planner')], max_length=20),
),
migrations.AlterField(
model_name='product',
name='price',
field=models.PositiveIntegerField(help_text='in pesos'),
),
migrations.CreateModel(
name='Feature',
fields=[
('feature_id', models.AutoField(primary_key=True, serialize=False)),
('feature', models.CharField(max_length=50)),
('item_id', models.ForeignKey(db_column='item_id', on_delete=django.db.models.deletion.CASCADE, to='adminpage.product')),
],
options={
'db_table': 'feature',
},
),
]
# Generated by Django 3.2.12 on 2022-11-07 23:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0008_auto_20221108_0657'),
]
operations = [
migrations.AlterField(
model_name='product',
name='color',
field=models.CharField(choices=[('RED', 'Red'), ('ORANGE', 'Orange'), ('YELLOW', 'Yellow'), ('GREEN', 'Green'), ('BLUE', 'Blue'), ('PURPLE', 'Purple'), ('PINK', 'Pink'), ('BLACK', 'Black')], max_length=20),
),
]
# Generated by Django 3.2.12 on 2022-11-07 23:45
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0014_auto_20221108_0745'),
('adminpage', '0009_alter_product_color'),
]
operations = [
migrations.RemoveField(
model_name='feature',
name='item_id',
),
migrations.DeleteModel(
name='Folder',
),
migrations.DeleteModel(
name='PenOrganizer',
),
migrations.DeleteModel(
name='Planner',
),
migrations.DeleteModel(
name='SalesAgent',
),
migrations.DeleteModel(
name='Feature',
),
migrations.DeleteModel(
name='Product',
),
]
# Generated by Django 3.2.12 on 2022-11-07 23:45
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('adminpage', '0010_auto_20221108_0745'),
]
operations = [
migrations.CreateModel(
name='Feature',
fields=[
('feature_id', models.AutoField(primary_key=True, serialize=False)),
('feature', models.CharField(max_length=50)),
],
options={
'db_table': 'feature',
},
),
migrations.CreateModel(
name='Folder',
fields=[
('item_id', models.AutoField(primary_key=True, serialize=False)),
('item_name', models.CharField(max_length=50)),
('personalization', models.CharField(max_length=254)),
('color', models.CharField(choices=[('RED', 'Red'), ('ORANGE', 'Orange'), ('YELLOW', 'Yellow'), ('GREEN', 'Green'), ('BLUE', 'Blue'), ('PURPLE', 'Purple'), ('PINK', 'Pink'), ('BLACK', 'Black')], max_length=20)),
('price', models.PositiveIntegerField(help_text='in pesos')),
('collection', models.CharField(default='F', editable=False, max_length=20)),
('length', models.PositiveIntegerField(help_text='in inches')),
('width', models.PositiveIntegerField(help_text='in inches')),
('thickness', models.PositiveIntegerField(help_text='in inches')),
],
options={
'db_table': 'folder',
},
),
migrations.CreateModel(
name='PenOrganizer',
fields=[
('item_id', models.AutoField(primary_key=True, serialize=False)),
('item_name', models.CharField(max_length=50)),
('personalization', models.CharField(max_length=254)),
('color', models.CharField(choices=[('RED', 'Red'), ('ORANGE', 'Orange'), ('YELLOW', 'Yellow'), ('GREEN', 'Green'), ('BLUE', 'Blue'), ('PURPLE', 'Purple'), ('PINK', 'Pink'), ('BLACK', 'Black')], max_length=20)),
('price', models.PositiveIntegerField(help_text='in pesos')),
('collection', models.CharField(default='PO', editable=False, max_length=20)),
('slots', models.PositiveIntegerField()),
],
options={
'db_table': 'pen_organizer',
},
),
migrations.CreateModel(
name='Planner',
fields=[
('item_name', models.CharField(max_length=50)),
('personalization', models.CharField(max_length=254)),
('color', models.CharField(choices=[('RED', 'Red'), ('ORANGE', 'Orange'), ('YELLOW', 'Yellow'), ('GREEN', 'Green'), ('BLUE', 'Blue'), ('PURPLE', 'Purple'), ('PINK', 'Pink'), ('BLACK', 'Black')], max_length=20)),
('price', models.PositiveIntegerField(help_text='in pesos')),
('item_id', models.AutoField(primary_key=True, serialize=False)),
('collection', models.CharField(default='P', editable=False, max_length=20)),
('length', models.PositiveIntegerField(help_text='in inches')),
('width', models.PositiveIntegerField(help_text='in inches')),
('thickness', models.PositiveIntegerField(help_text='in inches')),
],
options={
'db_table': 'planner',
},
),
migrations.CreateModel(
name='SalesAgent',
fields=[
('agent_id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
],
options={
'db_table': 'sales_agent',
},
),
]
# Generated by Django 3.2.12 on 2022-11-18 10:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0011_feature_folder_penorganizer_planner_salesagent'),
]
operations = [
migrations.DeleteModel(
name='Planner',
),
migrations.AlterField(
model_name='folder',
name='length',
field=models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10),
),
migrations.AlterField(
model_name='folder',
name='thickness',
field=models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10),
),
migrations.AlterField(
model_name='folder',
name='width',
field=models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10),
),
]
# Generated by Django 3.2.12 on 2022-11-18 10:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0012_auto_20221118_1849'),
]
operations = [
migrations.CreateModel(
name='Planner',
fields=[
('item_id', models.AutoField(primary_key=True, serialize=False)),
('item_name', models.CharField(max_length=50)),
('personalization', models.CharField(max_length=254)),
('color', models.CharField(choices=[('RED', 'Red'), ('ORANGE', 'Orange'), ('YELLOW', 'Yellow'), ('GREEN', 'Green'), ('BLUE', 'Blue'), ('PURPLE', 'Purple'), ('PINK', 'Pink'), ('BLACK', 'Black')], max_length=20)),
('price', models.PositiveIntegerField(help_text='in pesos')),
('collection', models.CharField(default='P', editable=False, max_length=20)),
('length', models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10)),
('width', models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10)),
('thickness', models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10)),
],
options={
'db_table': 'planner',
},
),
]
# Generated by Django 3.2.12 on 2022-11-18 11:01
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0013_planner'),
]
operations = [
migrations.CreateModel(
name='Description',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('feature_item_id', models.ForeignKey(db_column='feature_id', null=True, on_delete=django.db.models.deletion.CASCADE, to='adminpage.feature')),
('folder_id', models.ForeignKey(db_column='folder_id', null=True, on_delete=django.db.models.deletion.CASCADE, to='adminpage.folder')),
('pen_organizer_id', models.ForeignKey(db_column='pen_organizer_id', null=True, on_delete=django.db.models.deletion.CASCADE, to='adminpage.penorganizer')),
('planner_id', models.ForeignKey(db_column='planner_id', null=True, on_delete=django.db.models.deletion.CASCADE, to='adminpage.planner')),
],
),
]
# Generated by Django 3.2.12 on 2022-11-18 11:04
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0014_description'),
]
operations = [
migrations.AlterModelTable(
name='description',
table='desciption',
),
]
# Generated by Django 3.2.12 on 2022-11-04 19:44
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('adminpage', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Customer',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('sales_agent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')),
],
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='customer',
name='id',
),
migrations.AddField(
model_name='customer',
name='customer_id',
field=models.AutoField(default=1, primary_key=True, serialize=False),
preserve_default=False,
),
migrations.AlterModelTable(
name='customer',
table='customer',
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:17
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_auto_20221105_0412'),
]
operations = [
migrations.DeleteModel(
name='Customer',
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:18
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('adminpage', '0004_salesagent'),
('homepage', '0003_delete_customer'),
]
operations = [
migrations.CreateModel(
name='Customer',
fields=[
('customer_id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('sales_agent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')),
],
options={
'db_table': 'customer',
},
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0004_customer'),
]
operations = [
migrations.DeleteModel(
name='Customer',
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:22
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('adminpage', '0006_salesagent'),
('homepage', '0005_delete_customer'),
]
operations = [
migrations.CreateModel(
name='Customer',
fields=[
('customer_id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('sales_agent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')),
],
options={
'db_table': 'customer',
},
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:28
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0006_customer'),
]
operations = [
migrations.DeleteModel(
name='Customer',
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:28
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('adminpage', '0006_salesagent'),
('homepage', '0007_delete_customer'),
]
operations = [
migrations.CreateModel(
name='Customer',
fields=[
('customer_id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('agent_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')),
],
options={
'db_table': 'customer',
},
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:30
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0008_customer'),
]
operations = [
migrations.DeleteModel(
name='Customer',
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:30
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('adminpage', '0006_salesagent'),
('homepage', '0009_delete_customer'),
]
operations = [
migrations.CreateModel(
name='Customer',
fields=[
('customer_id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('agent_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent', verbose_name='agent_id')),
],
options={
'db_table': 'customer',
},
),
]
# Generated by Django 3.2.12 on 2022-11-04 20:53
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0006_salesagent'),
('homepage', '0010_customer'),
]
operations = [
migrations.AlterField(
model_name='customer',
name='agent_id',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent'),
),
migrations.CreateModel(
name='Order',
fields=[
('Order_no', models.AutoField(primary_key=True, serialize=False)),
('Order_date', models.DateField(auto_now_add=True)),
('delivery_date', models.DateField()),
('delivery_address', models.CharField(max_length=254)),
('gift', models.BooleanField()),
('recipient', models.CharField(max_length=50)),
('agent_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')),
('customer_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.customer')),
],
),
]
# Generated by Django 3.2.12 on 2022-11-04 21:03
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0006_salesagent'),
('homepage', '0011_auto_20221105_0453'),
]
operations = [
migrations.AlterField(
model_name='customer',
name='agent_id',
field=models.ForeignKey(db_column='agent_id', on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent'),
),
migrations.AlterField(
model_name='order',
name='agent_id',
field=models.ForeignKey(db_column='agent_id', on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent'),
),
migrations.AlterField(
model_name='order',
name='customer_id',
field=models.ForeignKey(db_column='customer_id', on_delete=django.db.models.deletion.CASCADE, to='homepage.customer'),
),
migrations.AlterModelTable(
name='order',
table='order',
),
]
# Generated by Django 3.2.12 on 2022-11-04 21:30
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0007_product'),
('homepage', '0012_auto_20221105_0503'),
]
operations = [
migrations.AddField(
model_name='order',
name='amount_due',
field=models.IntegerField(default=0, editable=False),
),
migrations.CreateModel(
name='OrderItem',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('personalization', models.CharField(max_length=254)),
('discount', models.IntegerField(default=0)),
('discount_price', models.IntegerField(default=0)),
('item_id', models.ForeignKey(db_column='item_id', on_delete=django.db.models.deletion.CASCADE, to='adminpage.product')),
('order_no', models.ForeignKey(db_column='agent_id', on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')),
],
options={
'db_table': 'order_item',
},
),
]
# Generated by Django 3.2.12 on 2022-11-07 23:45
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0013_auto_20221105_0530'),
]
operations = [
migrations.RemoveField(
model_name='order',
name='agent_id',
),
migrations.RemoveField(
model_name='order',
name='customer_id',
),
migrations.RemoveField(
model_name='orderitem',
name='item_id',
),
migrations.RemoveField(
model_name='orderitem',
name='order_no',
),
migrations.DeleteModel(
name='Customer',
),
migrations.DeleteModel(
name='Order',
),
migrations.DeleteModel(
name='OrderItem',
),
]
# Generated by Django 3.2.12 on 2022-11-08 00:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0011_feature_folder_penorganizer_planner_salesagent'),
('homepage', '0015_customer_order_orderitem'),
]
operations = [
migrations.AddField(
model_name='orderitem',
name='items',
field=models.ManyToManyField(to='adminpage.Folder'),
),
]
# Generated by Django 3.2.12 on 2022-11-08 02:49
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('adminpage', '0011_feature_folder_penorganizer_planner_salesagent'),
('homepage', '0016_orderitem_items'),
]
operations = [
migrations.RemoveField(
model_name='orderitem',
name='items',
),
migrations.AddField(
model_name='order',
name='items',
field=models.ManyToManyField(through='homepage.OrderItem', to='adminpage.Folder'),
),
migrations.AddField(
model_name='orderitem',
name='item_id',
field=models.ForeignKey(db_column='item_id', default=1, on_delete=django.db.models.deletion.CASCADE, to='adminpage.folder'),
preserve_default=False,
),
migrations.AddField(
model_name='orderitem',
name='quantity',
field=models.IntegerField(default=1),
),
migrations.AlterField(
model_name='orderitem',
name='discount',
field=models.IntegerField(default=0, editable=False),
),
migrations.AlterField(
model_name='orderitem',
name='discount_price',
field=models.IntegerField(default=0, editable=False),
),
migrations.AlterField(
model_name='orderitem',
name='order_no',
field=models.ForeignKey(db_column='order_no', on_delete=django.db.models.deletion.CASCADE, to='homepage.order'),
),
]
from django.contrib import admin from django.contrib import admin
from .models import Customer, Order, OrderItem from .models import Order, OrderItem
# Register your models here. # Register your models here.
class CustomerAdmin(admin.ModelAdmin):
model = Customer
class OrderAdmin(admin.ModelAdmin): class OrderAdmin(admin.ModelAdmin):
model = Order model = Order
...@@ -12,6 +9,5 @@ class OrderItemAdmin(admin.ModelAdmin): ...@@ -12,6 +9,5 @@ class OrderItemAdmin(admin.ModelAdmin):
model = OrderItem model = OrderItem
admin.site.register(Customer, CustomerAdmin)
admin.site.register(Order, OrderAdmin) admin.site.register(Order, OrderAdmin)
admin.site.register(OrderItem, OrderItemAdmin) admin.site.register(OrderItem, OrderItemAdmin)
\ No newline at end of file
from django.apps import AppConfig from django.apps import AppConfig
class HomepageConfig(AppConfig): class OrdersConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField' default_auto_field = 'django.db.models.BigAutoField'
name = 'homepage' name = 'orders'
# Generated by Django 3.2.12 on 2022-11-07 23:45 # Generated by Django 3.2.12 on 2022-11-20 02:03
import django.core.validators
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
...@@ -9,51 +10,46 @@ class Migration(migrations.Migration): ...@@ -9,51 +10,46 @@ class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = [
('adminpage', '0011_feature_folder_penorganizer_planner_salesagent'), ('users', '0001_initial'),
('homepage', '0014_auto_20221108_0745'), ('products', '0001_initial'),
] ]
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='Customer', name='Order',
fields=[ fields=[
('customer_id', models.AutoField(primary_key=True, serialize=False)), ('order_no', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)), ('order_date', models.DateField(auto_now_add=True)),
('last_name', models.CharField(max_length=50)), ('delivery_schedule', models.DateTimeField()),
('agent_id', models.ForeignKey(db_column='agent_id', on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')), ('delivery_address', models.CharField(max_length=254)),
('gift', models.BooleanField()),
('recipient', models.CharField(max_length=50)),
('amount_due', models.IntegerField(default=0, editable=False)),
('customer_id', models.ForeignKey(db_column='customer_id', on_delete=django.db.models.deletion.CASCADE, to='users.customer')),
], ],
options={ options={
'db_table': 'customer', 'db_table': 'order',
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='OrderItem', name='OrderItem',
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('color', models.CharField(choices=[('RED', 'Red'), ('ORANGE', 'Orange'), ('YELLOW', 'Yellow'), ('GREEN', 'Green'), ('BLUE', 'Blue'), ('PURPLE', 'Purple'), ('PINK', 'Pink'), ('BLACK', 'Black')], max_length=20)),
('quantity', models.IntegerField(default=1, validators=[django.core.validators.MaxValueValidator(99), django.core.validators.MinValueValidator(0)])),
('personalization', models.CharField(max_length=254)), ('personalization', models.CharField(max_length=254)),
('discount', models.IntegerField(default=0)), ('discount', models.IntegerField(default=0, editable=False)),
('discount_price', models.IntegerField(default=0)), ('discount_price', models.IntegerField(default=0, editable=False)),
('order_no', models.ForeignKey(db_column='agent_id', on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')), ('item_id', models.ForeignKey(db_column='item_id', on_delete=django.db.models.deletion.CASCADE, to='products.product')),
('order_no', models.ForeignKey(db_column='order_no', on_delete=django.db.models.deletion.CASCADE, to='orders.order')),
], ],
options={ options={
'db_table': 'order_item', 'db_table': 'order_item',
}, },
), ),
migrations.CreateModel( migrations.AddField(
name='Order', model_name='order',
fields=[ name='items',
('Order_no', models.AutoField(primary_key=True, serialize=False)), field=models.ManyToManyField(through='orders.OrderItem', to='products.Product'),
('Order_date', models.DateField(auto_now_add=True)),
('delivery_date', models.DateField()),
('delivery_address', models.CharField(max_length=254)),
('gift', models.BooleanField()),
('recipient', models.CharField(max_length=50)),
('amount_due', models.IntegerField(default=0, editable=False)),
('agent_id', models.ForeignKey(db_column='agent_id', on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')),
('customer_id', models.ForeignKey(db_column='customer_id', on_delete=django.db.models.deletion.CASCADE, to='homepage.customer')),
],
options={
'db_table': 'order',
},
), ),
] ]
from django.db import models from django.db import models
from adminpage.models import SalesAgent, Product, Folder from products.models import Product
from users.models import Customer
from django.core.validators import MaxValueValidator, MinValueValidator
# Create your models here. # Create your models here.
class Customer(models.Model):
customer_id = models.AutoField(primary_key=True)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
agent_id = models.ForeignKey(SalesAgent, on_delete=models.CASCADE, db_column='agent_id')
def __str__(self):
return self.first_name + " " + self.last_name
class Meta:
db_table = "customer"
class Order(models.Model): class Order(models.Model):
Order_no = models.AutoField(primary_key=True) order_no = models.AutoField(primary_key=True)
Order_date = models.DateField(auto_now_add=True) order_date = models.DateField(auto_now_add=True)
delivery_date = models.DateField() customer_id = models.ForeignKey(Customer, on_delete=models.CASCADE, db_column='customer_id')
items = models.ManyToManyField(Product, through='OrderItem', through_fields=('order_no', 'item_id'))
delivery_schedule = models.DateTimeField()
delivery_address = models.CharField(max_length=254) delivery_address = models.CharField(max_length=254)
gift = models.BooleanField() gift = models.BooleanField()
recipient = models.CharField(max_length=50) recipient = models.CharField(max_length=50)
amount_due = models.IntegerField(default=0, editable=False) amount_due = models.IntegerField(default=0, editable=False)
agent_id = models.ForeignKey(SalesAgent, on_delete=models.CASCADE, db_column='agent_id') def __str__(self):
customer_id = models.ForeignKey(Customer, on_delete=models.CASCADE, db_column='customer_id') return str(self.order_no)
items = models.ManyToManyField(Folder, through='OrderItem', through_fields=('order_no', 'item_id'))
class Meta: class Meta:
db_table = "order" db_table = "order"
class OrderItem(models.Model): class OrderItem(models.Model):
order_no = models.ForeignKey(Order, on_delete=models.CASCADE, db_column='order_no') order_no = models.ForeignKey(Order, on_delete=models.CASCADE, db_column='order_no')
item_id = models.ForeignKey(Folder, on_delete=models.CASCADE, db_column='item_id') item_id = models.ForeignKey(Product, on_delete=models.CASCADE, db_column='item_id')
quantity = models.IntegerField(default=1) 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)])
personalization = models.CharField(max_length=254) personalization = models.CharField(max_length=254)
discount = models.IntegerField(default=0, editable=False) discount = models.IntegerField(default=0, editable=False)
discount_price = models.IntegerField(default=0, editable=False) discount_price = models.IntegerField(default=0, editable=False)
def __str__(self):
return str(self.quantity) + " pcs. of " + str(self.item_id) + " added to order #" + str(self.order_no)
class Meta: class Meta:
db_table = "order_item" db_table = "order_item"
\ No newline at end of file
# Order(Order_no, Order_date, Delivery_Date, Delivery_Address, Gift?, Recipient, Amount_Due, Agent_ID, Customer_ID)
# OrderItem(Order_no, itemID, personalization, Discount, Discount Price)
\ No newline at end of file
<h1>This is the orders html</h1>
from django.urls import path from django.urls import path
from . import views from . import views
appname = "homepage" appname = "orders"
urlpatterns = [ urlpatterns = [
path('', views.index, name="index"), path('', views.index, name="index"),
] ]
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
# Create your views here. # Create your views here.
def index(request): def index(request):
return render(request, "homepage/homepage.html") return render(request, "orders/orders.html")
\ No newline at end of file
...@@ -38,8 +38,9 @@ INSTALLED_APPS = [ ...@@ -38,8 +38,9 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'homepage.apps.HomepageConfig', 'users.apps.UsersConfig',
'adminpage.apps.AdminpageConfig' 'products.apps.ProductsConfig',
'orders.apps.OrdersConfig',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
...@@ -19,7 +19,7 @@ from django.contrib import admin ...@@ -19,7 +19,7 @@ from django.contrib import admin
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('pixieadmin/', include('adminpage.urls')), path('admin-pd/', include('users.urls')),
path('homepage/', include('homepage.urls')), path('admin-pd/products', include('products.urls')),
path('admin-pd/orders', include('orders.urls')),
] ]
from django.contrib import admin from django.contrib import admin
from .models import SalesAgent, Product, Feature, Folder, PenOrganizer, Planner, Description from django.db.models.functions import Lower
from .models import Product, Feature, Folder, PenOrganizer, Planner, Description, Inventory
# Register your models here. # Register your models here.
class SalesAgentAdmin(admin.ModelAdmin):
model = SalesAgent
class ProductAdmin(admin.ModelAdmin): class ProductAdmin(admin.ModelAdmin):
model = Product model = Product
...@@ -23,11 +21,12 @@ class PlannerAdmin(admin.ModelAdmin): ...@@ -23,11 +21,12 @@ class PlannerAdmin(admin.ModelAdmin):
class DescriptionAdmin(admin.ModelAdmin): class DescriptionAdmin(admin.ModelAdmin):
model = Description model = Description
class InventoryAdmin(admin.ModelAdmin):
model = Inventory
admin.site.register(SalesAgent, SalesAgentAdmin)
# admin.site.register(Product, ProductAdmin)
admin.site.register(Feature, FeatureAdmin) admin.site.register(Feature, FeatureAdmin)
admin.site.register(Folder, FolderAdmin) admin.site.register(Folder, FolderAdmin)
admin.site.register(PenOrganizer, PenOrganizerAdmin) admin.site.register(PenOrganizer, PenOrganizerAdmin)
admin.site.register(Planner, PlannerAdmin) admin.site.register(Planner, PlannerAdmin)
admin.site.register(Description, DescriptionAdmin) admin.site.register(Description, DescriptionAdmin)
admin.site.register(Inventory, InventoryAdmin)
\ No newline at end of file
from django.apps import AppConfig from django.apps import AppConfig
class AdminpageConfig(AppConfig): class ProductsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField' default_auto_field = 'django.db.models.BigAutoField'
name = 'adminpage' name = 'products'
# Generated by Django 3.2.12 on 2022-11-20 02:02
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
def populate_products(apps, schema_editor):
Folder = apps.get_model('products', 'Folder')
PenOrganizer = apps.get_model('products', 'PenOrganizer')
Planner = apps.get_model('products', 'Planner')
obj = Folder(item_name="Flipper", price=745, personalization=8, length=13.5, width=10.25, thickness=0.75)
obj.save()
obj = Folder(item_name="Filer", price=995, personalization=8, length=14, width=11, thickness=1.5)
obj.save()
obj = PenOrganizer(item_name="Slinger", price=95, personalization=5, slots=6)
obj.save()
obj = PenOrganizer(item_name="Shifter", price=295, personalization=8, slots=15)
obj.save()
obj = Planner(item_name="Doodler", price=595, personalization=8, length=8, width=6, thickness=0.75)
obj.save()
obj = Planner(item_name="Scribler", price=595, personalization=8, length=8, width=6, thickness=0.75)
obj.save()
feature_model = apps.get_model('products', 'Feature')
features = ["Reversible", "Slim and compact", "Leatherette material", "Magnetic corners", "Magnetic clipboard",
"Envelope pocket", "Pen loop (2)",
"Multi-function portfolio organizer", "Leather exterior", "Magnetic flap", "3-ring binder",
"Sleeves for papers", "Pen loop" "Concealable handles",
"Magnetic lock", "Dual ribbon straps with velcro", "Water repellent", "No tear interior lining",
"Triple zipper", "Expandable bin", "Velcro locked pockets",
"Smyth sewn hardbound", "Premium 120 gsm paper", "Monthly spread", "Weekly, daily views",
"Non-lined, colorable pages", "Leisure list", "Money tracker", "Back pocket",
"Premium 100 gsm paper", "Weekly spread", "Lined notes pages", "Monthly watercolor artwork",
"Leisure activities list", "Optional sleeve (+185)"]
for f in features:
obj = feature_model(feature=f)
obj.save()
def add_feature_to_products(apps, schema_editor):
import products.models as product_app
Description = product_app.Description
for x in range(7):
obj = Description(feature_id = product_app.Feature.objects.get(pk=x+1), item_id=product_app.Product.objects.get(item_id=1))
obj.save()
for x in range(7):
obj = Description(feature_id = product_app.Feature.objects.get(pk=x+8), item_id=product_app.Product.objects.get(item_id=2))
obj.save()
for x in range(4):
obj = Description(feature_id = product_app.Feature.objects.get(pk=x+15), item_id=product_app.Product.objects.get(item_id=3))
obj.save()
for x in range(3):
obj = Description(feature_id = product_app.Feature.objects.get(pk=x+19), item_id=product_app.Product.objects.get(item_id=4))
obj.save()
obj = Description(feature_id = product_app.Feature.objects.get(pk=17), item_id=product_app.Product.objects.get(item_id=4))
obj.save()
for x in range(7):
obj = Description(feature_id = product_app.Feature.objects.get(pk=x+22), item_id=product_app.Product.objects.get(item_id=5))
obj.save()
obj = Description(feature_id = product_app.Feature.objects.get(pk=22), item_id=product_app.Product.objects.get(item_id=6))
obj.save()
obj = Description(feature_id = product_app.Feature.objects.get(pk=24), item_id=product_app.Product.objects.get(item_id=6))
obj.save()
for x in range(6):
obj = Description(feature_id = product_app.Feature.objects.get(pk=x+29), item_id=product_app.Product.objects.get(item_id=6))
obj.save()
def supply_inventory(apps, schema_editor):
import products.models as product_app
Inventory = product_app.Inventory
colors = ["RED", "ORANGE","YELLOW", "GREEN", "BLUE", "PURPLE", "PINK", "BLACK"]
for i in range(6):
for c in colors:
obj = Inventory(item_id=product_app.Product.objects.get(item_id=i+1), color=c, quantity=99)
obj.save()
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Description',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
],
options={
'db_table': 'description',
},
),
migrations.CreateModel(
name='Product',
fields=[
('item_id', models.AutoField(primary_key=True, serialize=False)),
('item_name', models.CharField(max_length=50)),
('price', models.PositiveIntegerField(help_text='in pesos')),
('personalization', models.PositiveIntegerField(help_text='up how many letters?')),
],
options={
'db_table': 'product',
},
),
migrations.CreateModel(
name='Folder',
fields=[
('product_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='products.product')),
('collection', models.CharField(default='F', editable=False, max_length=20)),
('length', models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10)),
('width', models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10)),
('thickness', models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10)),
],
options={
'db_table': 'folder',
},
bases=('products.product',),
),
migrations.CreateModel(
name='PenOrganizer',
fields=[
('product_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='products.product')),
('collection', models.CharField(default='PO', editable=False, max_length=20)),
('slots', models.PositiveIntegerField()),
],
options={
'db_table': 'pen_organizer',
},
bases=('products.product',),
),
migrations.CreateModel(
name='Planner',
fields=[
('product_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='products.product')),
('collection', models.CharField(default='P', editable=False, max_length=20)),
('length', models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10)),
('width', models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10)),
('thickness', models.DecimalField(decimal_places=2, help_text='in inches', max_digits=10)),
],
options={
'db_table': 'planner',
},
bases=('products.product',),
),
migrations.CreateModel(
name='Inventory',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('color', models.CharField(choices=[('RED', 'Red'), ('ORANGE', 'Orange'), ('YELLOW', 'Yellow'), ('GREEN', 'Green'), ('BLUE', 'Blue'), ('PURPLE', 'Purple'), ('PINK', 'Pink'), ('BLACK', 'Black')], max_length=20)),
('quantity', models.IntegerField(default=1, validators=[django.core.validators.MaxValueValidator(99), django.core.validators.MinValueValidator(0)])),
('item_id', models.ForeignKey(db_column='item_id', on_delete=django.db.models.deletion.CASCADE, to='products.product')),
],
options={
'db_table': 'Inventory',
},
),
migrations.CreateModel(
name='Feature',
fields=[
('feature_id', models.AutoField(primary_key=True, serialize=False)),
('feature', models.CharField(max_length=50)),
('Product', models.ManyToManyField(through='products.Description', to='products.Product')),
],
options={
'db_table': 'feature',
},
),
migrations.AddField(
model_name='description',
name='feature_id',
field=models.ForeignKey(db_column='feature_id', on_delete=django.db.models.deletion.CASCADE, to='products.feature'),
),
migrations.AddField(
model_name='description',
name='item_id',
field=models.ForeignKey(db_column='item_id', on_delete=django.db.models.deletion.CASCADE, to='products.product'),
),
migrations.RunPython(populate_products),
migrations.RunPython(add_feature_to_products),
migrations.RunPython(supply_inventory),
]
from django.db import models from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator
# Create your models here. # Create your models here.
class SalesAgent(models.Model):
agent_id = models.AutoField(primary_key=True)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
def __str__(self):
return self.first_name + " " + self.last_name
class Meta:
db_table = "sales_agent"
class Product(models.Model): class Product(models.Model):
item_id = models.AutoField(primary_key=True) item_id = models.AutoField(primary_key=True)
item_name = models.CharField(max_length=50) item_name = models.CharField(max_length=50)
personalization = models.CharField(max_length=254) #why is there 2 personalization attribute?
color = models.CharField(max_length=20, choices=(("RED","Red"), ("ORANGE","Orange"), ("YELLOW", "Yellow"),
("GREEN", "Green"), ("BLUE", "Blue"), ("PURPLE", "Purple"), ("PINK", "Pink"), ("BLACK", "Black")))
price = models.PositiveIntegerField(help_text='in pesos') price = models.PositiveIntegerField(help_text='in pesos')
# collection = models.CharField(max_length=20, choices=(("F", "Folder"), ("PO", "Pen Organizer"),("P", "Planner"))) personalization = models.PositiveIntegerField(help_text='up how many letters?')
def __str__(self): def __str__(self):
return self.item_name return "#" + str(self.item_id) + " (" + self.item_name + ")"
class Meta: class Meta:
db_table = "product" db_table = "product"
abstract=True
class Feature(models.Model): class Feature(models.Model):
feature_id = models.AutoField(primary_key=True) feature_id = models.AutoField(primary_key=True)
feature = models.CharField(max_length=50) feature = models.CharField(max_length=50)
# item_id = models.ForeignKey(Product, on_delete=models.CASCADE, db_column='item_id') Product = models.ManyToManyField(Product, through='Description', through_fields=('feature_id', 'item_id'))
def __str__(self): def __str__(self):
return self.feature return "#" + str(self.feature_id) + " (" + self.feature + ")"
class Meta: class Meta:
db_table = "feature" db_table = "feature"
class Folder(Product): class Folder(Product):
# item_id = models.AutoField(primary_key=True) #folder_id instead of f_item_id
collection = models.CharField(max_length=20, default="F", editable=False) collection = models.CharField(max_length=20, default="F", editable=False)
length = 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') 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') thickness = models.DecimalField(max_digits=10, decimal_places=2, help_text='in inches')
class Meta: class Meta:
db_table = "folder" db_table = "folder"
class PenOrganizer(Product): class PenOrganizer(Product):
# item_id = models.AutoField(primary_key=True) #pen_org_id instead of po_item_id
collection = models.CharField(max_length=20, default="PO", editable=False) collection = models.CharField(max_length=20, default="PO", editable=False)
slots = models.PositiveIntegerField() slots = models.PositiveIntegerField()
class Meta: class Meta:
db_table = "pen_organizer" db_table = "pen_organizer"
class Planner(Product): class Planner(Product):
# item_id = models.AutoField(primary_key=True) #planner_id instead of p_item_id
collection = models.CharField(max_length=20, default="P", editable=False) collection = models.CharField(max_length=20, default="P", editable=False)
length = 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') 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') thickness = models.DecimalField(max_digits=10, decimal_places=2, help_text='in inches')
class Meta: class Meta:
db_table = "planner" db_table = "planner"
class Description(models.Model): class Description(models.Model):
feature_item_id = models.ForeignKey(Feature, on_delete=models.CASCADE, db_column='feature_id', null=True) item_id = models.ForeignKey(Product, on_delete=models.CASCADE, db_column='item_id')
folder_id = models.ForeignKey(Folder, on_delete=models.CASCADE, db_column='folder_id', null=True) feature_id = models.ForeignKey(Feature, on_delete=models.CASCADE, db_column='feature_id')
pen_organizer_id = models.ForeignKey(PenOrganizer, on_delete=models.CASCADE, db_column='pen_organizer_id', null=True) def __str__(self):
planner_id = models.ForeignKey(Planner, on_delete=models.CASCADE, db_column='planner_id', null=True) return "Feature " + str(self.feature_id) + " added to item " + str(self.item_id)
class Meta: class Meta:
db_table = "desciption" 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)])
def __str__(self):
return str(self.quantity) + " pcs of " + self.color.lower() + " " + self.item_id.item_name + "'s left"
class Meta:
db_table = "Inventory"
# Sales_Agent(Agent_ID, First_Name, Last_Name)
# Product(itemID, itemName, personalization, color, price, collection)
# Feature(FeatureID, feature, itemID)
# Folder(F_itemID, length, width, thickness)
# PenOrganizer(PO_itemID, slots)
# Planner(P_itemID, length, width, thickness)
\ No newline at end of file
from django.urls import path from django.urls import path
from . import views from . import views
appname = "adminpage" appname = "products"
urlpatterns = [ urlpatterns = [
path('', views.index, name="index"), path('', views.index, name="index"),
] ]
\ No newline at end of file
...@@ -2,5 +2,4 @@ from django.shortcuts import render ...@@ -2,5 +2,4 @@ from django.shortcuts import render
# Create your views here. # Create your views here.
def index(request): def index(request):
return render(request, "adminpage/adminpage.html") return render(request, "products/products.html")
\ No newline at end of file
from django.contrib import admin
from .models import SalesAgent, Customer
# Register your models here.
class SalesAgentAdmin(admin.ModelAdmin):
model = SalesAgent
class CustomerAdmin(admin.ModelAdmin):
model = Customer
admin.site.register(SalesAgent, SalesAgentAdmin)
admin.site.register(Customer, CustomerAdmin)
\ No newline at end of file
from django.apps import AppConfig
class UsersConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'users'
# Generated by Django 3.2.12 on 2022-11-20 02:03
from django.db import migrations, models
import django.db.models.deletion
def populate_agents(apps, schema_editor):
ag_first_names = ["Bryan Carlo", "Elmo Lenard"]
ag_last_names = ["Guanlao", "Gumapos"]
Agent = apps.get_model('users', 'SalesAgent')
for i in range(2):
obj = Agent(first_name=ag_first_names[i], last_name=ag_last_names[i])
obj.save()
def populate_customers(apps, schema_editor):
import users.models as u
cus_first_names = ["Erick Gabriel", "Mikael Giannes", "Luis Mikhael"]
cus_last_names = ["Lopez", "Bernardino", "Gonzales"]
customer = u.Customer
for i in range(3):
obj = customer(first_name=cus_first_names[i], last_name=cus_last_names[i])
obj.save()
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='SalesAgent',
fields=[
('agent_id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('customer_served', models.PositiveIntegerField(default=0, editable=False)),
],
options={
'db_table': 'sales_agent',
},
),
migrations.CreateModel(
name='Customer',
fields=[
('customer_id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('agent_id', models.ForeignKey(db_column='agent_id', default=1, editable=False, on_delete=django.db.models.deletion.CASCADE, to='users.salesagent')),
],
options={
'db_table': 'customer',
},
),
migrations.RunPython(populate_agents),
migrations.RunPython(populate_customers)
]
from django.db import models
# Create your models here.
class SalesAgent(models.Model):
agent_id = models.AutoField(primary_key=True)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
customer_served = models.PositiveIntegerField(default=0, editable=False)
def __str__(self):
return self.first_name + " " + self.last_name
class Meta:
db_table = "sales_agent"
class Customer(models.Model):
customer_id = models.AutoField(primary_key=True)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
agent_id = models.ForeignKey(SalesAgent, on_delete=models.CASCADE, db_column='agent_id', default=1, editable=False)
def save(self, *args, **kwargs):
agents = SalesAgent.objects.all()
min_ag= SalesAgent.objects.first()
min_served = agents[0].customer_served
for agent in agents:
if(agent.customer_served < min_served):
min_ag = agent
min_served = agent.customer_served
self.agent_id = min_ag
# agnt = SalesAgent.objects.get(pk=min_id)
min_ag.customer_served = min_ag.customer_served + 1
min_ag.save()
return super().save(*args, **kwargs)
def __str__(self):
return self.first_name + " " + self.last_name
class Meta:
db_table = "customer"
\ No newline at end of file
<h1>This is the users html</h1>
from django.test import TestCase
# Create your tests here.
from django.urls import path
from . import views
appname = "users"
urlpatterns = [
path('', views.index, name="index"),
]
\ No newline at end of file
from django.shortcuts import render
# Create your views here.
def index(request):
return render(request, "users/users.html")
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