diff --git a/config/__pycache__/__init__.cpython-311.pyc b/config/__pycache__/__init__.cpython-311.pyc index 423a636..5486eea 100644 Binary files a/config/__pycache__/__init__.cpython-311.pyc and b/config/__pycache__/__init__.cpython-311.pyc differ diff --git a/config/__pycache__/settings.cpython-311.pyc b/config/__pycache__/settings.cpython-311.pyc index 96bce55..71ccc71 100644 Binary files a/config/__pycache__/settings.cpython-311.pyc and b/config/__pycache__/settings.cpython-311.pyc differ diff --git a/config/__pycache__/urls.cpython-311.pyc b/config/__pycache__/urls.cpython-311.pyc index 0b85e94..b73e6ca 100644 Binary files a/config/__pycache__/urls.cpython-311.pyc and b/config/__pycache__/urls.cpython-311.pyc differ diff --git a/config/__pycache__/wsgi.cpython-311.pyc b/config/__pycache__/wsgi.cpython-311.pyc index 9c49e09..f59fa44 100644 Binary files a/config/__pycache__/wsgi.cpython-311.pyc and b/config/__pycache__/wsgi.cpython-311.pyc differ diff --git a/core/__pycache__/__init__.cpython-311.pyc b/core/__pycache__/__init__.cpython-311.pyc index 74b1112..af42e64 100644 Binary files a/core/__pycache__/__init__.cpython-311.pyc and b/core/__pycache__/__init__.cpython-311.pyc differ diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index a5ed392..5b346eb 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/apps.cpython-311.pyc b/core/__pycache__/apps.cpython-311.pyc index 6f131d4..02a8211 100644 Binary files a/core/__pycache__/apps.cpython-311.pyc and b/core/__pycache__/apps.cpython-311.pyc differ diff --git a/core/__pycache__/context_processors.cpython-311.pyc b/core/__pycache__/context_processors.cpython-311.pyc index 75bf223..de5dcfa 100644 Binary files a/core/__pycache__/context_processors.cpython-311.pyc and b/core/__pycache__/context_processors.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index e061640..ff67477 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 5a69659..9046927 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 2a36fd6..eefb7bf 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..c1618be 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,3 +1,13 @@ from django.contrib import admin +from .models import CarAuction, Bid -# Register your models here. +@admin.register(CarAuction) +class CarAuctionAdmin(admin.ModelAdmin): + list_display = ('title', 'make', 'model', 'year', 'current_bid', 'end_date', 'seller') + list_filter = ('make', 'year', 'end_date') + search_fields = ('title', 'make', 'model', 'description') + +@admin.register(Bid) +class BidAdmin(admin.ModelAdmin): + list_display = ('auction', 'user', 'amount', 'created_at') + list_filter = ('created_at',) \ 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..94b6d60 --- /dev/null +++ b/core/migrations/0001_initial.py @@ -0,0 +1,47 @@ +# Generated by Django 5.2.7 on 2026-02-12 16:44 + +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='CarAuction', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('make', models.CharField(max_length=100)), + ('model', models.CharField(max_length=100)), + ('year', models.IntegerField()), + ('description', models.TextField()), + ('image_url', models.URLField(blank=True, max_length=500, null=True)), + ('starting_bid', models.DecimalField(decimal_places=2, max_digits=10)), + ('current_bid', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('end_date', models.DateTimeField()), + ('seller', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='auctions', to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='Bid', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('amount', models.DecimalField(decimal_places=2, max_digits=10)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('auction', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bids', to='core.carauction')), + ], + options={ + 'ordering': ['-amount'], + }, + ), + ] 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..cc12f47 Binary files /dev/null and b/core/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/core/migrations/__pycache__/__init__.cpython-311.pyc b/core/migrations/__pycache__/__init__.cpython-311.pyc index 9c833c8..b4a7897 100644 Binary files a/core/migrations/__pycache__/__init__.cpython-311.pyc and b/core/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 71a8362..c0961e9 100644 --- a/core/models.py +++ b/core/models.py @@ -1,3 +1,46 @@ from django.db import models +from django.contrib.auth.models import User +from django.utils import timezone +from datetime import timedelta -# Create your models here. +class CarAuction(models.Model): + title = models.CharField(max_length=200) + make = models.CharField(max_length=100) + model = models.CharField(max_length=100) + year = models.IntegerField() + description = models.TextField() + image_url = models.URLField(max_length=500, blank=True, null=True) + starting_bid = models.DecimalField(max_digits=10, decimal_places=2) + current_bid = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True) + seller = models.ForeignKey(User, on_delete=models.CASCADE, related_name='auctions') + created_at = models.DateTimeField(auto_now_add=True) + end_date = models.DateTimeField() + + def is_active(self): + return timezone.now() < self.end_date + + def time_left(self): + if not self.is_active(): + return "Closed" + delta = self.end_date - timezone.now() + days = delta.days + hours = delta.seconds // 3600 + minutes = (delta.seconds // 60) % 60 + if days > 0: + return f"{days}d {hours}h" + return f"{hours}h {minutes}m" + + def __str__(self): + return f"{self.year} {self.make} {self.model}" + +class Bid(models.Model): + auction = models.ForeignKey(CarAuction, on_delete=models.CASCADE, related_name='bids') + user = models.ForeignKey(User, on_delete=models.CASCADE) + amount = models.DecimalField(max_digits=10, decimal_places=2) + created_at = models.DateTimeField(auto_now_add=True) + + class Meta: + ordering = ['-amount'] + + def __str__(self): + return f"{self.user.username} - {self.amount} on {self.auction.title}" \ No newline at end of file diff --git a/core/templates/base.html b/core/templates/base.html index 1e7e5fb..5845dc1 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -1,25 +1,75 @@ +{% load static %} -
- -