Initial commit

parent b4c2bceb
Pipeline #2553 failed with stages
from django.contrib import admin
from .models import SalesAgent, Product, Feature, Folder, PenOrganizer, Planner
# Register your models here.
class SalesAgentAdmin(admin.ModelAdmin):
model = SalesAgent
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
admin.site.register(SalesAgent, SalesAgentAdmin)
# admin.site.register(Product, ProductAdmin)
admin.site.register(Feature, FeatureAdmin)
admin.site.register(Folder, FolderAdmin)
admin.site.register(PenOrganizer, PenOrganizerAdmin)
admin.site.register(Planner, PlannerAdmin)
\ No newline at end of file
from django.apps import AppConfig
class AdminpageConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'adminpage'
# 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',
},
),
]
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)
def __str__(self):
return self.first_name + " " + self.last_name
class Meta:
db_table = "sales_agent"
class Product(models.Model):
item_id = models.AutoField(primary_key=True)
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')
# collection = models.CharField(max_length=20, choices=(("F", "Folder"), ("PO", "Pen Organizer"),("P", "Planner")))
def __str__(self):
return self.item_name
class Meta:
db_table = "product"
abstract=True
class Feature(models.Model):
feature_id = models.AutoField(primary_key=True)
feature = models.CharField(max_length=50)
# item_id = models.ForeignKey(Product, on_delete=models.CASCADE, db_column='item_id')
def __str__(self):
return self.feature
class Meta:
db_table = "feature"
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)
length = models.PositiveIntegerField(help_text='in inches')
width = models.PositiveIntegerField(help_text='in inches')
thickness = models.PositiveIntegerField(help_text='in inches')
class Meta:
db_table = "folder"
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)
slots = models.PositiveIntegerField()
class Meta:
db_table = "pen_organizer"
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)
length = models.PositiveIntegerField(help_text='in inches')
width = models.PositiveIntegerField(help_text='in inches')
thickness = models.PositiveIntegerField(help_text='in inches')
class Meta:
db_table = "planner"
# 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.test import TestCase
# Create your tests here.
from django.urls import path
from . import views
appname = "adminpage"
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, "adminpage/adminpage.html")
from django.contrib import admin
from .models import Customer, Order, OrderItem
# Register your models here.
class CustomerAdmin(admin.ModelAdmin):
model = Customer
class OrderAdmin(admin.ModelAdmin):
model = Order
class OrderItemAdmin(admin.ModelAdmin):
model = OrderItem
admin.site.register(Customer, CustomerAdmin)
admin.site.register(Order, OrderAdmin)
admin.site.register(OrderItem, OrderItemAdmin)
\ No newline at end of file
from django.apps import AppConfig
class HomepageConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'homepage'
# 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-07 23:45
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('adminpage', '0011_feature_folder_penorganizer_planner_salesagent'),
('homepage', '0014_auto_20221108_0745'),
]
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(db_column='agent_id', on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')),
],
options={
'db_table': 'customer',
},
),
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)),
('order_no', models.ForeignKey(db_column='agent_id', on_delete=django.db.models.deletion.CASCADE, to='adminpage.salesagent')),
],
options={
'db_table': 'order_item',
},
),
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)),
('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',
},
),
]
# 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.db import models
from adminpage.models import SalesAgent, Product, Folder
# 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):
Order_no = models.AutoField(primary_key=True)
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(SalesAgent, on_delete=models.CASCADE, db_column='agent_id')
customer_id = models.ForeignKey(Customer, on_delete=models.CASCADE, db_column='customer_id')
items = models.ManyToManyField(Folder, through='OrderItem', through_fields=('order_no', 'item_id'))
class Meta:
db_table = "order"
class OrderItem(models.Model):
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')
quantity = models.IntegerField(default=1)
personalization = models.CharField(max_length=254)
discount = models.IntegerField(default=0, editable=False)
discount_price = models.IntegerField(default=0, editable=False)
class Meta:
db_table = "order_item"
# 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
from django.test import TestCase
# Create your tests here.
from django.urls import path
from . import views
appname = "homepage"
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, "homepage/homepage.html")
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pixie_dust.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
"""
ASGI config for pixie_dust project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pixie_dust.settings')
application = get_asgi_application()
"""
Django settings for pixie_dust project.
Generated by 'django-admin startproject' using Django 3.2.12.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-_bq*lc^2zl_m+vd0r29m6rb*&t_h*rip90fll2edb)cvjjy7#4'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'homepage.apps.HomepageConfig',
'adminpage.apps.AdminpageConfig'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'pixie_dust.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'pixie_dust.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'pixie_dust',
'PORT': '3306',
'USER': 'root',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
"""pixie_dust URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.urls import path, include
from django.contrib import admin
urlpatterns = [
path('admin/', admin.site.urls),
path('pixieadmin/', include('adminpage.urls')),
path('homepage/', include('homepage.urls')),
]
"""
WSGI config for pixie_dust project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pixie_dust.settings')
application = get_wsgi_application()
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