diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index a5ed392..cb46a21 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index e061640..5c3c750 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 2a36fd6..26ee8f4 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 8c38f3f..80b8c10 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,3 +1,23 @@ from django.contrib import admin +from .models import Worker, Project, Team, WorkLog -# Register your models here. +@admin.register(Worker) +class WorkerAdmin(admin.ModelAdmin): + list_display = ('name', 'id_no', 'phone_no', 'monthly_salary', 'day_rate') + search_fields = ('name', 'id_no', 'phone_no') + +@admin.register(Project) +class ProjectAdmin(admin.ModelAdmin): + list_display = ('name', 'created_at') + search_fields = ('name',) + +@admin.register(Team) +class TeamAdmin(admin.ModelAdmin): + list_display = ('name', 'created_at') + filter_horizontal = ('workers',) + +@admin.register(WorkLog) +class WorkLogAdmin(admin.ModelAdmin): + list_display = ('date', 'project') + list_filter = ('date', 'project') + filter_horizontal = ('workers',) \ No newline at end of file diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py new file mode 100644 index 0000000..676e74c --- /dev/null +++ b/core/migrations/0001_initial.py @@ -0,0 +1,56 @@ +# Generated by Django 5.2.7 on 2026-02-03 15:47 + +import django.core.validators +import django.db.models.deletion +from decimal import Decimal +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Project', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ('description', models.TextField(blank=True)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ], + ), + migrations.CreateModel( + name='Worker', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ('id_no', models.CharField(max_length=50, unique=True, verbose_name='ID Number')), + ('phone_no', models.CharField(max_length=20, verbose_name='Phone Number')), + ('monthly_salary', models.DecimalField(decimal_places=2, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.00'))])), + ('created_at', models.DateTimeField(auto_now_add=True)), + ], + ), + migrations.CreateModel( + name='Team', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('workers', models.ManyToManyField(related_name='teams', to='core.worker')), + ], + ), + migrations.CreateModel( + name='WorkLog', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date', models.DateField()), + ('notes', models.TextField(blank=True)), + ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='logs', to='core.project')), + ('workers', models.ManyToManyField(related_name='work_logs', to='core.worker')), + ], + ), + ] diff --git a/core/migrations/__pycache__/0001_initial.cpython-311.pyc b/core/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000..9f9088d Binary files /dev/null and b/core/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 71a8362..524f06e 100644 --- a/core/models.py +++ b/core/models.py @@ -1,3 +1,42 @@ from django.db import models +from django.core.validators import MinValueValidator +from decimal import Decimal -# Create your models here. +class Project(models.Model): + name = models.CharField(max_length=200) + description = models.TextField(blank=True) + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return self.name + +class Worker(models.Model): + name = models.CharField(max_length=200) + id_no = models.CharField(max_length=50, unique=True, verbose_name="ID Number") + phone_no = models.CharField(max_length=20, verbose_name="Phone Number") + monthly_salary = models.DecimalField(max_digits=10, decimal_places=2, validators=[MinValueValidator(Decimal('0.00'))]) + created_at = models.DateTimeField(auto_now_add=True) + + @property + def day_rate(self): + return self.monthly_salary / Decimal('20.0') + + def __str__(self): + return self.name + +class Team(models.Model): + name = models.CharField(max_length=200) + workers = models.ManyToManyField(Worker, related_name='teams') + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return self.name + +class WorkLog(models.Model): + date = models.DateField() + project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='logs') + workers = models.ManyToManyField(Worker, related_name='work_logs') + notes = models.TextField(blank=True) + + def __str__(self): + return f"{self.date} - {self.project.name}" \ No newline at end of file diff --git a/core/templates/base.html b/core/templates/base.html index 1e7e5fb..a19c620 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -1,25 +1,37 @@ -
- -