0.0.1
This commit is contained in:
parent
17de42ccb4
commit
b4bdae6d89
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,45 @@
|
||||
from django.contrib import admin
|
||||
from .models import Plant, Category, Product, Inventory, Machine, WorkOrder, Inspection
|
||||
|
||||
# Register your models here.
|
||||
@admin.register(Plant)
|
||||
class PlantAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'location')
|
||||
search_fields = ('name', 'location')
|
||||
|
||||
@admin.register(Category)
|
||||
class CategoryAdmin(admin.ModelAdmin):
|
||||
list_display = ('name',)
|
||||
|
||||
@admin.register(Product)
|
||||
class ProductAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'sku', 'category')
|
||||
search_fields = ('name', 'sku')
|
||||
list_filter = ('category',)
|
||||
|
||||
@admin.register(Inventory)
|
||||
class InventoryAdmin(admin.ModelAdmin):
|
||||
list_display = ('product', 'plant', 'quantity', 'lot_number')
|
||||
list_filter = ('plant', 'product')
|
||||
search_fields = ('lot_number',)
|
||||
|
||||
@admin.register(Machine)
|
||||
class MachineAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'plant', 'status', 'last_maintenance')
|
||||
list_filter = ('plant', 'status')
|
||||
search_fields = ('name',)
|
||||
|
||||
class InspectionInline(admin.TabularInline):
|
||||
model = Inspection
|
||||
extra = 1
|
||||
|
||||
@admin.register(WorkOrder)
|
||||
class WorkOrderAdmin(admin.ModelAdmin):
|
||||
list_display = ('order_number', 'plant', 'product', 'quantity', 'status', 'start_date')
|
||||
list_filter = ('plant', 'status', 'product')
|
||||
search_fields = ('order_number',)
|
||||
inlines = [InspectionInline]
|
||||
|
||||
@admin.register(Inspection)
|
||||
class InspectionAdmin(admin.ModelAdmin):
|
||||
list_display = ('work_order', 'result', 'inspector', 'timestamp')
|
||||
list_filter = ('result', 'timestamp')
|
||||
0
core/management/__init__.py
Normal file
0
core/management/__init__.py
Normal file
BIN
core/management/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
core/management/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
0
core/management/commands/__init__.py
Normal file
0
core/management/commands/__init__.py
Normal file
BIN
core/management/commands/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
core/management/commands/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
core/management/commands/__pycache__/seed_data.cpython-311.pyc
Normal file
BIN
core/management/commands/__pycache__/seed_data.cpython-311.pyc
Normal file
Binary file not shown.
75
core/management/commands/seed_data.py
Normal file
75
core/management/commands/seed_data.py
Normal file
@ -0,0 +1,75 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.auth.models import User
|
||||
from core.models import Plant, Category, Product, Inventory, Machine, WorkOrder, Inspection
|
||||
import random
|
||||
from datetime import date, timedelta
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Seeds the database with initial demo data for the ERP'
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
self.stdout.write('Seeding data...')
|
||||
|
||||
# Ensure we have an admin user
|
||||
if not User.objects.filter(username='admin').exists():
|
||||
User.objects.create_superuser('admin', 'admin@example.com', 'admin')
|
||||
self.stdout.write('Superuser "admin" created.')
|
||||
|
||||
# Plants
|
||||
p1, _ = Plant.objects.get_or_create(name='Istanbul Facility', location='Istanbul, TR')
|
||||
p2, _ = Plant.objects.get_or_create(name='Ankara Facility', location='Ankara, TR')
|
||||
p3, _ = Plant.objects.get_or_create(name='Izmir Facility', location='Izmir, TR')
|
||||
|
||||
# Categories
|
||||
cat_raw, _ = Category.objects.get_or_create(name='Raw Materials')
|
||||
cat_final, _ = Category.objects.get_or_create(name='Finished Goods')
|
||||
cat_comp, _ = Category.objects.get_or_create(name='Components')
|
||||
|
||||
# Products
|
||||
prod1, _ = Product.objects.get_or_create(name='Steel Plate', sku='RAW-001', category=cat_raw)
|
||||
prod2, _ = Product.objects.get_or_create(name='Microchip A1', sku='COMP-101', category=cat_comp)
|
||||
prod3, _ = Product.objects.get_or_create(name='Smart Widget', sku='FIN-505', category=cat_final)
|
||||
|
||||
# Inventory
|
||||
for p in [p1, p2, p3]:
|
||||
for prod in [prod1, prod2, prod3]:
|
||||
Inventory.objects.get_or_create(
|
||||
plant=p,
|
||||
product=prod,
|
||||
lot_number=f"LOT-{random.randint(1000, 9999)}",
|
||||
defaults={'quantity': random.uniform(10, 500)}
|
||||
)
|
||||
|
||||
# Machines
|
||||
m1, _ = Machine.objects.get_or_create(name='Laser Cutter X1', plant=p1, status='active')
|
||||
m2, _ = Machine.objects.get_or_create(name='Assembly Line 3', plant=p2, status='active')
|
||||
m3, _ = Machine.objects.get_or_create(name='Quality Tester T8', plant=p3, status='maintenance')
|
||||
|
||||
# Work Orders
|
||||
wo1, _ = WorkOrder.objects.get_or_create(
|
||||
order_number='WO-2026-001',
|
||||
plant=p1,
|
||||
product=prod3,
|
||||
quantity=100,
|
||||
machine=m1,
|
||||
status='in_progress'
|
||||
)
|
||||
wo2, _ = WorkOrder.objects.get_or_create(
|
||||
order_number='WO-2026-002',
|
||||
plant=p2,
|
||||
product=prod3,
|
||||
quantity=50,
|
||||
machine=m2,
|
||||
status='planned'
|
||||
)
|
||||
|
||||
# Inspections
|
||||
admin_user = User.objects.get(username='admin')
|
||||
Inspection.objects.get_or_create(
|
||||
work_order=wo1,
|
||||
inspector=admin_user,
|
||||
result='pass',
|
||||
notes='All systems nominal.'
|
||||
)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS('Successfully seeded demo data.'))
|
||||
94
core/migrations/0001_initial.py
Normal file
94
core/migrations/0001_initial.py
Normal file
@ -0,0 +1,94 @@
|
||||
# Generated by Django 5.2.7 on 2026-02-05 08:46
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Category',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=100)),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Categories',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Plant',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('location', models.CharField(blank=True, max_length=255)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Machine',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('status', models.CharField(choices=[('active', 'Active'), ('maintenance', 'Maintenance'), ('broken', 'Broken')], default='active', max_length=20)),
|
||||
('last_maintenance', models.DateField(blank=True, null=True)),
|
||||
('plant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='machines', to='core.plant')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Product',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('sku', models.CharField(max_length=100, unique=True)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('category', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.category')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='WorkOrder',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('order_number', models.CharField(max_length=50, unique=True)),
|
||||
('quantity', models.PositiveIntegerField()),
|
||||
('status', models.CharField(choices=[('planned', 'Planned'), ('in_progress', 'In Progress'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], default='planned', max_length=20)),
|
||||
('start_date', models.DateTimeField(blank=True, null=True)),
|
||||
('end_date', models.DateTimeField(blank=True, null=True)),
|
||||
('machine', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.machine')),
|
||||
('plant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.plant')),
|
||||
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.product')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Inspection',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('result', models.CharField(choices=[('pass', 'Pass'), ('fail', 'Fail')], max_length=10)),
|
||||
('notes', models.TextField(blank=True)),
|
||||
('timestamp', models.DateTimeField(auto_now_add=True)),
|
||||
('inspector', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
|
||||
('work_order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inspections', to='core.workorder')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Inventory',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('quantity', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
|
||||
('lot_number', models.CharField(blank=True, max_length=100)),
|
||||
('plant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inventory', to='core.plant')),
|
||||
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.product')),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Inventory',
|
||||
'unique_together': {('plant', 'product', 'lot_number')},
|
||||
},
|
||||
),
|
||||
]
|
||||
BIN
core/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
BIN
core/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
Binary file not shown.
@ -1,3 +1,87 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
# Create your models here.
|
||||
class Plant(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
location = models.CharField(max_length=255, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Category(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Categories"
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Product(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
sku = models.CharField(max_length=100, unique=True)
|
||||
category = models.ForeignKey(Category, on_delete=models.SET_NULL, null=True)
|
||||
description = models.TextField(blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.sku})"
|
||||
|
||||
class Inventory(models.Model):
|
||||
plant = models.ForeignKey(Plant, on_delete=models.CASCADE, related_name='inventory')
|
||||
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
||||
quantity = models.DecimalField(max_digits=12, decimal_places=2, default=0)
|
||||
lot_number = models.CharField(max_length=100, blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Inventory"
|
||||
unique_together = ('plant', 'product', 'lot_number')
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.product.name} at {self.plant.name} - Lot: {self.lot_number or 'N/A'}"
|
||||
|
||||
class Machine(models.Model):
|
||||
STATUS_CHOICES = [
|
||||
('active', 'Active'),
|
||||
('maintenance', 'Maintenance'),
|
||||
('broken', 'Broken'),
|
||||
]
|
||||
name = models.CharField(max_length=255)
|
||||
plant = models.ForeignKey(Plant, on_delete=models.CASCADE, related_name='machines')
|
||||
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='active')
|
||||
last_maintenance = models.DateField(null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.plant.name})"
|
||||
|
||||
class WorkOrder(models.Model):
|
||||
STATUS_CHOICES = [
|
||||
('planned', 'Planned'),
|
||||
('in_progress', 'In Progress'),
|
||||
('completed', 'Completed'),
|
||||
('cancelled', 'Cancelled'),
|
||||
]
|
||||
order_number = models.CharField(max_length=50, unique=True)
|
||||
plant = models.ForeignKey(Plant, on_delete=models.CASCADE)
|
||||
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
||||
quantity = models.PositiveIntegerField()
|
||||
machine = models.ForeignKey(Machine, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='planned')
|
||||
start_date = models.DateTimeField(null=True, blank=True)
|
||||
end_date = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.order_number
|
||||
|
||||
class Inspection(models.Model):
|
||||
RESULT_CHOICES = [
|
||||
('pass', 'Pass'),
|
||||
('fail', 'Fail'),
|
||||
]
|
||||
work_order = models.ForeignKey(WorkOrder, on_delete=models.CASCADE, related_name='inspections')
|
||||
inspector = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
|
||||
result = models.CharField(max_length=10, choices=RESULT_CHOICES)
|
||||
notes = models.TextField(blank=True)
|
||||
timestamp = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"Inspection for {self.work_order.order_number} - {self.result}"
|
||||
@ -1,25 +1,166 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% block title %}Knowledge Base{% endblock %}</title>
|
||||
{% if project_description %}
|
||||
<meta name="description" content="{{ project_description }}">
|
||||
<meta property="og:description" content="{{ project_description }}">
|
||||
<meta property="twitter:description" content="{{ project_description }}">
|
||||
{% endif %}
|
||||
{% if project_image_url %}
|
||||
<meta property="og:image" content="{{ project_image_url }}">
|
||||
<meta property="twitter:image" content="{{ project_image_url }}">
|
||||
{% endif %}
|
||||
{% load static %}
|
||||
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
|
||||
{% block head %}{% endblock %}
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}Multi-Plant ERP{% endblock %}</title>
|
||||
{% load static %}
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--primary: #2563eb;
|
||||
--primary-hover: #1d4ed8;
|
||||
--bg-main: #f1f5f9;
|
||||
--bg-card: #ffffff;
|
||||
--text-main: #0f172a;
|
||||
--text-muted: #64748b;
|
||||
--border: #e2e8f0;
|
||||
--sidebar-width: 260px;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-color: var(--bg-main);
|
||||
color: var(--text-main);
|
||||
margin: 0;
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
.sidebar {
|
||||
width: var(--sidebar-width);
|
||||
background: #1e293b;
|
||||
color: white;
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
padding: 2rem 1.5rem;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.025em;
|
||||
border-bottom: 1px solid #334155;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
flex: 1;
|
||||
padding: 1.5rem 1rem;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.75rem 1rem;
|
||||
color: #94a3b8;
|
||||
text-decoration: none;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 0.5rem;
|
||||
transition: all 0.2s;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.nav-link:hover, .nav-link.active {
|
||||
background: #334155;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Main Content */
|
||||
.main-wrapper {
|
||||
margin-left: var(--sidebar-width);
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.top-bar {
|
||||
height: 64px;
|
||||
background: white;
|
||||
border-bottom: 1px solid var(--border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
padding: 0 2rem;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.content-area {
|
||||
padding: 2rem;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Common Components */
|
||||
.card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.625rem 1.25rem;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
text-decoration: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: var(--primary-hover);
|
||||
}
|
||||
|
||||
{% block extra_css %}{% endblock %}
|
||||
</style>
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
Manufacturing ERP
|
||||
</div>
|
||||
<nav class="nav-links">
|
||||
<a href="{% url 'home' %}" class="nav-link">Dashboard</a>
|
||||
<a href="#" class="nav-link">Facilities</a>
|
||||
<a href="#" class="nav-link">Inventory</a>
|
||||
<a href="#" class="nav-link">Work Orders</a>
|
||||
<a href="#" class="nav-link">Machines</a>
|
||||
<a href="#" class="nav-link">Quality Control</a>
|
||||
</nav>
|
||||
<div style="padding: 1.5rem; border-top: 1px solid #334155;">
|
||||
<a href="/admin/" class="nav-link" style="font-size: 0.875rem;">Admin Panel</a>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
</html>
|
||||
<div class="main-wrapper">
|
||||
<header class="top-bar">
|
||||
<div style="display: flex; align-items: center; gap: 1rem;">
|
||||
<span style="font-size: 0.875rem; color: var(--text-muted);">{{ user.username }}</span>
|
||||
<div style="width: 32px; height: 32px; background: #e2e8f0; border-radius: 50%;"></div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="content-area">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,145 +1,146 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ project_name }}{% endblock %}
|
||||
{% block title %}Dashboard | Multi-Plant ERP{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
{% block extra_css %}
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'><path d='M-10 10L110 10M10 -10L10 110' stroke-width='1' stroke='rgba(255,255,255,0.05)'/></svg>");
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
@keyframes bg-pan {
|
||||
0% {
|
||||
background-position: 0% 0%;
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
||||
gap: 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-position: 100% 100%;
|
||||
.stat-card {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2.5rem 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: clamp(2.2rem, 3vw + 1.2rem, 3.2rem);
|
||||
font-weight: 700;
|
||||
margin: 0 0 1.2rem;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
.loader {
|
||||
margin: 1.5rem auto;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border: 4px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
.stat-label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.025em;
|
||||
}
|
||||
}
|
||||
|
||||
.runtime code {
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
padding: 0.15rem 0.45rem;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
.stat-value {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
color: var(--primary);
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
border: 0;
|
||||
}
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 0.85rem;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
text-align: left;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
padding: 1rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 1rem;
|
||||
font-size: 0.875rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.badge {
|
||||
padding: 0.25rem 0.625rem;
|
||||
border-radius: 9999px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.badge-pass { background: #dcfce7; color: #166534; }
|
||||
.badge-fail { background: #fee2e2; color: #991b1b; }
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your app…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
<div class="section-header">
|
||||
<div>
|
||||
<h1 style="margin: 0; font-size: 1.875rem; font-weight: 700;">Operational Dashboard</h1>
|
||||
<p style="color: var(--text-muted); margin-top: 0.25rem;">Real-time manufacturing insights across all facilities.</p>
|
||||
</div>
|
||||
<p class="hint">AppWizzy AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will refresh automatically as the plan is implemented.</p>
|
||||
<p class="runtime">
|
||||
Runtime: Django <code>{{ django_version }}</code> · Python <code>{{ python_version }}</code>
|
||||
— UTC <code>{{ current_time|date:"Y-m-d H:i:s" }}</code>
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC)
|
||||
</footer>
|
||||
<div style="display: flex; gap: 0.75rem;">
|
||||
<button class="btn" style="background: white; border: 1px solid var(--border);">Download Report</button>
|
||||
<a href="/admin/" class="btn btn-primary">Add New Order</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="card stat-card">
|
||||
<div class="stat-label">Active Facilities</div>
|
||||
<div class="stat-value">{{ stats.plants_count }}</div>
|
||||
</div>
|
||||
<div class="card stat-card">
|
||||
<div class="stat-label">Total Stock Items</div>
|
||||
<div class="stat-value">{{ stats.inventory_count }}</div>
|
||||
</div>
|
||||
<div class="card stat-card">
|
||||
<div class="stat-label">Production Machines</div>
|
||||
<div class="stat-value">{{ stats.machines_count }}</div>
|
||||
</div>
|
||||
<div class="card stat-card">
|
||||
<div class="stat-label">Running Work Orders</div>
|
||||
<div class="stat-value">{{ stats.active_work_orders }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" style="padding: 1.5rem;">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title">Recent Quality Inspections</h2>
|
||||
<a href="#" style="font-size: 0.875rem; color: var(--primary); font-weight: 600; text-decoration: none;">View All</a>
|
||||
</div>
|
||||
|
||||
{% if stats.recent_inspections %}
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Work Order</th>
|
||||
<th>Facility</th>
|
||||
<th>Result</th>
|
||||
<th>Inspector</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for inspection in stats.recent_inspections %}
|
||||
<tr>
|
||||
<td style="font-weight: 600;">{{ inspection.work_order.order_number }}</td>
|
||||
<td>{{ inspection.work_order.plant.name }}</td>
|
||||
<td>
|
||||
<span class="badge {% if inspection.result == 'pass' %}badge-pass{% else %}badge-fail{% endif %}">
|
||||
{{ inspection.result|upper }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ inspection.inspector.username }}</td>
|
||||
<td>{{ inspection.timestamp|date:"M d, Y H:i" }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p style="color: var(--text-muted); padding: 1rem 0;">No recent inspections recorded.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -4,22 +4,31 @@ import platform
|
||||
from django import get_version as django_version
|
||||
from django.shortcuts import render
|
||||
from django.utils import timezone
|
||||
|
||||
from .models import Plant, Product, Inventory, Machine, WorkOrder, Inspection
|
||||
|
||||
def home(request):
|
||||
"""Render the landing screen with loader and environment details."""
|
||||
"""Render the ERP dashboard with summary statistics."""
|
||||
host_name = request.get_host().lower()
|
||||
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
|
||||
now = timezone.now()
|
||||
|
||||
# ERP Stats
|
||||
stats = {
|
||||
"plants_count": Plant.objects.count(),
|
||||
"products_count": Product.objects.count(),
|
||||
"inventory_count": Inventory.objects.count(),
|
||||
"machines_count": Machine.objects.count(),
|
||||
"active_work_orders": WorkOrder.objects.filter(status='in_progress').count(),
|
||||
"recent_inspections": Inspection.objects.order_by('-timestamp')[:5],
|
||||
}
|
||||
|
||||
context = {
|
||||
"project_name": "New Style",
|
||||
"project_name": "Multi-Plant ERP",
|
||||
"agent_brand": agent_brand,
|
||||
"django_version": django_version(),
|
||||
"python_version": platform.python_version(),
|
||||
"current_time": now,
|
||||
"host_name": host_name,
|
||||
"project_description": os.getenv("PROJECT_DESCRIPTION", ""),
|
||||
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
|
||||
"stats": stats,
|
||||
}
|
||||
return render(request, "core/index.html", context)
|
||||
return render(request, "core/index.html", context)
|
||||
Loading…
x
Reference in New Issue
Block a user