From bf54019b297e25e3ff9d8ae937faa34d61627cb8 Mon Sep 17 00:00:00 2001 From: Lance Tan <63096217+ltan02@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:33:59 -0700 Subject: [PATCH] Update user and unit models (#8) --- README.md | 7 +- backend/auction/admin.py | 8 - backend/auction/migrations/0001_initial.py | 24 +- ...uction_identifier_auction_name_and_more.py | 50 ---- backend/bid/admin.py | 3 + backend/bid/migrations/0001_initial.py | 31 +- ...0002_remove_bid_identifier_alter_bid_id.py | 28 -- backend/bid/models.py | 15 +- backend/user/admin.py | 4 + backend/user/models.py | 45 ++- backend/vehicle/admin.py | 10 + backend/vehicle/migrations/0001_initial.py | 280 +++++++++++++++--- ...fier_remove_vehicle_identifier_and_more.py | 58 ---- backend/vehicle/models.py | 71 ++++- 14 files changed, 399 insertions(+), 235 deletions(-) delete mode 100644 backend/auction/migrations/0002_remove_auction_identifier_auction_name_and_more.py delete mode 100644 backend/bid/migrations/0002_remove_bid_identifier_alter_bid_id.py delete mode 100644 backend/vehicle/migrations/0002_remove_brand_identifier_remove_vehicle_identifier_and_more.py diff --git a/README.md b/README.md index c1ee494..5db27b2 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,10 @@ To get a local copy up and running follow these simple steps. #### Django Backend 1. `cd` into backend folder -2. run `pipenv install` to install dependencies -3. run `pipenv shell` to enter virtual environment -4. run `pipenv run start` +2. Make a copy of sample.env, rename it to .env, and fill out the environment variables. +3. run `pipenv install` to install dependencies +4. run `pipenv shell` to enter virtual environment +5. run `pipenv run start` #### NextJS Frontend diff --git a/backend/auction/admin.py b/backend/auction/admin.py index e34bda8..bf901ee 100644 --- a/backend/auction/admin.py +++ b/backend/auction/admin.py @@ -1,14 +1,6 @@ from django.contrib import admin from auction.models import Auction -from bid.models import Bid -from user.models import User -from vehicle.models import Brand, Vehicle, VehicleType # Register your models here. admin.site.register(Auction) -admin.site.register(Vehicle) -admin.site.register(Brand) -admin.site.register(VehicleType) -admin.site.register(Bid) -admin.site.register(User) diff --git a/backend/auction/migrations/0001_initial.py b/backend/auction/migrations/0001_initial.py index 871437b..562e784 100644 --- a/backend/auction/migrations/0001_initial.py +++ b/backend/auction/migrations/0001_initial.py @@ -1,8 +1,7 @@ -# Generated by Django 4.2.5 on 2023-10-07 23:50 - -import uuid +# Generated by Django 4.2.6 on 2023-10-24 19:15 from django.db import migrations, models +import uuid class Migration(migrations.Migration): @@ -16,20 +15,19 @@ class Migration(migrations.Migration): fields=[ ( "id", - models.BigAutoField( - auto_created=True, + models.UUIDField( + default=uuid.uuid4, + editable=False, primary_key=True, serialize=False, - verbose_name="ID", + unique=True, ), ), - ( - "identifier", - models.UUIDField(default=uuid.uuid4, editable=False, unique=True), - ), - ("created_at", models.DateTimeField(editable=False)), - ("updated_at", models.DateTimeField()), - ("end_date", models.DateTimeField(editable=False)), + ("created_at", models.DateTimeField(auto_now_add=True)), + ("updated_at", models.DateTimeField(auto_now=True)), + ("name", models.CharField(max_length=150)), + ("start_date", models.DateTimeField()), + ("end_date", models.DateTimeField()), ], options={ "ordering": ["-created_at"], diff --git a/backend/auction/migrations/0002_remove_auction_identifier_auction_name_and_more.py b/backend/auction/migrations/0002_remove_auction_identifier_auction_name_and_more.py deleted file mode 100644 index 347c802..0000000 --- a/backend/auction/migrations/0002_remove_auction_identifier_auction_name_and_more.py +++ /dev/null @@ -1,50 +0,0 @@ -# Generated by Django 4.2.6 on 2023-10-22 02:26 - -import datetime -from django.db import migrations, models -import uuid - - -class Migration(migrations.Migration): - dependencies = [ - ("auction", "0001_initial"), - ] - - operations = [ - migrations.RemoveField( - model_name="auction", - name="identifier", - ), - migrations.AddField( - model_name="auction", - name="name", - field=models.CharField(default="Auction", max_length=150), - preserve_default=False, - ), - migrations.AddField( - model_name="auction", - name="start_date", - field=models.DateTimeField( - default=datetime.datetime( - 2023, 10, 22, 2, 26, 16, 722675, tzinfo=datetime.timezone.utc - ) - ), - preserve_default=False, - ), - migrations.AlterField( - model_name="auction", - name="end_date", - field=models.DateTimeField(), - ), - migrations.AlterField( - model_name="auction", - name="id", - field=models.UUIDField( - default=uuid.uuid4, - editable=False, - primary_key=True, - serialize=False, - unique=True, - ), - ), - ] diff --git a/backend/bid/admin.py b/backend/bid/admin.py index 8c38f3f..61899f8 100644 --- a/backend/bid/admin.py +++ b/backend/bid/admin.py @@ -1,3 +1,6 @@ from django.contrib import admin +from .models import Bid + # Register your models here. +admin.site.register(Bid) diff --git a/backend/bid/migrations/0001_initial.py b/backend/bid/migrations/0001_initial.py index ce687ba..ff44874 100644 --- a/backend/bid/migrations/0001_initial.py +++ b/backend/bid/migrations/0001_initial.py @@ -1,17 +1,16 @@ -# Generated by Django 4.2.5 on 2023-10-07 23:50 +# Generated by Django 4.2.6 on 2023-10-24 19:21 -import uuid - -import django.db.models.deletion from django.db import migrations, models +import django.db.models.deletion +import uuid class Migration(migrations.Migration): initial = True dependencies = [ + ("contenttypes", "0002_remove_content_type_name"), ("user", "__first__"), - ("vehicle", "0001_initial"), ] operations = [ @@ -20,31 +19,29 @@ class Migration(migrations.Migration): fields=[ ( "id", - models.BigAutoField( - auto_created=True, + models.UUIDField( + default=uuid.uuid4, + editable=False, primary_key=True, serialize=False, - verbose_name="ID", + unique=True, ), ), - ( - "identifier", - models.UUIDField(default=uuid.uuid4, editable=False, unique=True), - ), - ("created_at", models.DateTimeField(editable=False)), - ("updated_at", models.DateTimeField()), + ("created_at", models.DateTimeField(auto_now_add=True)), + ("updated_at", models.DateTimeField(auto_now=True)), ("amount", models.IntegerField()), + ("object_id", models.UUIDField()), ( "bidder", models.ForeignKey( - on_delete=django.db.models.deletion.PROTECT, to="user.user" + on_delete=django.db.models.deletion.PROTECT, to="user.bidder" ), ), ( - "vehicle", + "content_type", models.ForeignKey( on_delete=django.db.models.deletion.PROTECT, - to="vehicle.vehicle", + to="contenttypes.contenttype", ), ), ], diff --git a/backend/bid/migrations/0002_remove_bid_identifier_alter_bid_id.py b/backend/bid/migrations/0002_remove_bid_identifier_alter_bid_id.py deleted file mode 100644 index 6730f1d..0000000 --- a/backend/bid/migrations/0002_remove_bid_identifier_alter_bid_id.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by Django 4.2.6 on 2023-10-22 02:26 - -from django.db import migrations, models -import uuid - - -class Migration(migrations.Migration): - dependencies = [ - ("bid", "0001_initial"), - ] - - operations = [ - migrations.RemoveField( - model_name="bid", - name="identifier", - ), - migrations.AlterField( - model_name="bid", - name="id", - field=models.UUIDField( - default=uuid.uuid4, - editable=False, - primary_key=True, - serialize=False, - unique=True, - ), - ), - ] diff --git a/backend/bid/models.py b/backend/bid/models.py index d5f0f21..bf465d7 100644 --- a/backend/bid/models.py +++ b/backend/bid/models.py @@ -1,11 +1,18 @@ +from django.contrib.contenttypes.fields import GenericForeignKey +from django.contrib.contenttypes.models import ContentType from django.db import models from core.models import MainModel -from user.models import User -from vehicle.models import Vehicle +from user.models import Bidder class Bid(MainModel): + """ + created_at field on MainModel will be used to determine when the bid was + """ + amount = models.IntegerField(null=False) - vehicle = models.ForeignKey(Vehicle, on_delete=models.PROTECT) - bidder = models.ForeignKey(User, on_delete=models.PROTECT) + bidder = models.ForeignKey(Bidder, on_delete=models.PROTECT) + content_type = models.ForeignKey(ContentType, on_delete=models.PROTECT) + object_id = models.UUIDField() + content_object = GenericForeignKey("content_type", "object_id") diff --git a/backend/user/admin.py b/backend/user/admin.py index 8c38f3f..45c64b9 100644 --- a/backend/user/admin.py +++ b/backend/user/admin.py @@ -1,3 +1,7 @@ from django.contrib import admin +from .models import Admin, Bidder + # Register your models here. +admin.site.register(Admin) +admin.site.register(Bidder) diff --git a/backend/user/models.py b/backend/user/models.py index f2d7e82..2b2330a 100644 --- a/backend/user/models.py +++ b/backend/user/models.py @@ -1,19 +1,46 @@ +import random + from django.db import models from core.models import MainModel # Create your models here. -class User(MainModel): - """ - The model used for handling users, this includes bidders and admins. - A user will become a bidder if their manytomanyfield contains the - auction in question. An auction will have many bidders, and a bidder - will be in many auctions. +class Admin(MainModel): + email = models.CharField(max_length=150, null=False) + password = models.CharField(max_length=50, null=False) + first_name = models.CharField(max_length=150, null=False) + last_name = models.CharField(max_length=150, null=False) + permission_level = models.IntegerField(default=0) + def __str__(self): + return f"Admin: {self.first_name} {self.last_name}" - """ - name = models.CharField(max_length=150, null=False) +class Bidder(MainModel): email = models.CharField(max_length=150, null=False) - auction = models.ManyToManyField("auction.Auction", related_name="auction") + password = models.CharField(max_length=50, null=False) + first_name = models.CharField(max_length=150, null=False) + last_name = models.CharField(max_length=150, null=False) + company_name = models.CharField(max_length=150) + bidder_number = models.IntegerField(unique=True, null=False) + is_verified = models.BooleanField(default=False) + is_blacklisted = models.BooleanField(default=False) + + def save(self, *args, **kwargs): + # Check if the bidder_number is not set yet + if not self.bidder_number: + # Generate a unique 8-digit number + bidder_number = self.generate_unique_bidder_number() + self.bidder_number = bidder_number + super(Bidder, self).save(*args, **kwargs) + + def generate_unique_bidder_number(self): + # Generate an 8-digit number and check if it's unique + while True: + bidder_number = random.randint(10000000, 99999999) + if not Bidder.objects.filter(bidder_number=bidder_number).exists(): + return bidder_number + + def __str__(self): + return f"Bidder: {self.first_name} {self.last_name}" diff --git a/backend/vehicle/admin.py b/backend/vehicle/admin.py index 8c38f3f..cd36804 100644 --- a/backend/vehicle/admin.py +++ b/backend/vehicle/admin.py @@ -1,3 +1,13 @@ from django.contrib import admin +from .models import ( + Brand, Equipment, Supplier, Trailer, Type, UnitImage, Vehicle) + # Register your models here. +admin.site.register(Brand) +admin.site.register(Type) +admin.site.register(Vehicle) +admin.site.register(Equipment) +admin.site.register(Supplier) +admin.site.register(Trailer) +admin.site.register(UnitImage) diff --git a/backend/vehicle/migrations/0001_initial.py b/backend/vehicle/migrations/0001_initial.py index 12fc4b0..6db22b4 100644 --- a/backend/vehicle/migrations/0001_initial.py +++ b/backend/vehicle/migrations/0001_initial.py @@ -1,16 +1,15 @@ -# Generated by Django 4.2.5 on 2023-10-07 23:50 +# Generated by Django 4.2.6 on 2023-10-24 19:15 -import uuid - -import django.db.models.deletion from django.db import migrations, models +import django.db.models.deletion +import uuid class Migration(migrations.Migration): initial = True dependencies = [ - ("auction", "0001_initial"), + ("contenttypes", "0002_remove_content_type_name"), ] operations = [ @@ -19,19 +18,16 @@ class Migration(migrations.Migration): fields=[ ( "id", - models.BigAutoField( - auto_created=True, + models.UUIDField( + default=uuid.uuid4, + editable=False, primary_key=True, serialize=False, - verbose_name="ID", + unique=True, ), ), - ( - "identifier", - models.UUIDField(default=uuid.uuid4, editable=False, unique=True), - ), - ("created_at", models.DateTimeField(editable=False)), - ("updated_at", models.DateTimeField()), + ("created_at", models.DateTimeField(auto_now_add=True)), + ("updated_at", models.DateTimeField(auto_now=True)), ("name", models.CharField(max_length=150)), ], options={ @@ -40,23 +36,42 @@ class Migration(migrations.Migration): }, ), migrations.CreateModel( - name="VehicleType", + name="Supplier", fields=[ ( "id", - models.BigAutoField( - auto_created=True, + models.UUIDField( + default=uuid.uuid4, + editable=False, primary_key=True, serialize=False, - verbose_name="ID", + unique=True, ), ), + ("created_at", models.DateTimeField(auto_now_add=True)), + ("updated_at", models.DateTimeField(auto_now=True)), + ("name", models.CharField(max_length=150)), + ], + options={ + "ordering": ["-created_at"], + "abstract": False, + }, + ), + migrations.CreateModel( + name="Type", + fields=[ ( - "identifier", - models.UUIDField(default=uuid.uuid4, editable=False, unique=True), + "id", + models.UUIDField( + default=uuid.uuid4, + editable=False, + primary_key=True, + serialize=False, + unique=True, + ), ), - ("created_at", models.DateTimeField(editable=False)), - ("updated_at", models.DateTimeField()), + ("created_at", models.DateTimeField(auto_now_add=True)), + ("updated_at", models.DateTimeField(auto_now=True)), ("name", models.CharField(max_length=150)), ], options={ @@ -69,31 +84,221 @@ class Migration(migrations.Migration): fields=[ ( "id", - models.BigAutoField( - auto_created=True, + models.UUIDField( + default=uuid.uuid4, + editable=False, + primary_key=True, + serialize=False, + unique=True, + ), + ), + ("created_at", models.DateTimeField(auto_now_add=True)), + ("updated_at", models.DateTimeField(auto_now=True)), + ("unicode_id", models.IntegerField(unique=True)), + ( + "model_number", + models.CharField(blank=True, max_length=10, null=True), + ), + ( + "chassis_number", + models.CharField(blank=True, max_length=50, null=True), + ), + ("description", models.CharField(max_length=2000)), + ("minimum_price", models.IntegerField(blank=True, null=True)), + ("is_sold", models.BooleanField(default=False)), + ("remarks", models.CharField(blank=True, max_length=2000, null=True)), + ( + "classification_type", + models.CharField(blank=True, max_length=50, null=True), + ), + ( + "engine_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "transmission_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "differentials_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "brake_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "electrical_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "operating_system_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "chassis_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "body_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "brand", + models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, to="vehicle.brand" + ), + ), + ( + "vehicle_type", + models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, to="vehicle.type" + ), + ), + ], + options={ + "ordering": ["-created_at"], + "abstract": False, + }, + ), + migrations.CreateModel( + name="UnitImage", + fields=[ + ( + "id", + models.UUIDField( + default=uuid.uuid4, + editable=False, primary_key=True, serialize=False, - verbose_name="ID", + unique=True, ), ), + ("created_at", models.DateTimeField(auto_now_add=True)), + ("updated_at", models.DateTimeField(auto_now=True)), + ("image_url", models.CharField(max_length=500)), + ("object_id", models.UUIDField()), ( - "identifier", - models.UUIDField(default=uuid.uuid4, editable=False, unique=True), + "content_type", + models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, + to="contenttypes.contenttype", + ), + ), + ], + options={ + "ordering": ["-created_at"], + "abstract": False, + }, + ), + migrations.CreateModel( + name="Trailer", + fields=[ + ( + "id", + models.UUIDField( + default=uuid.uuid4, + editable=False, + primary_key=True, + serialize=False, + unique=True, + ), + ), + ("created_at", models.DateTimeField(auto_now_add=True)), + ("updated_at", models.DateTimeField(auto_now=True)), + ("unicode_id", models.IntegerField(unique=True)), + ( + "chassis_number", + models.CharField(blank=True, max_length=50, null=True), ), - ("created_at", models.DateTimeField(editable=False)), - ("updated_at", models.DateTimeField()), - ("date", models.DateTimeField(editable=False)), - ("asking_price", models.IntegerField()), ("description", models.CharField(max_length=2000)), - ("unicode_id", models.IntegerField()), - ("model_number", models.IntegerField()), + ("number_of_axles", models.IntegerField()), ( - "auction", + "supplier", models.ForeignKey( on_delete=django.db.models.deletion.PROTECT, - to="auction.auction", + to="vehicle.supplier", + ), + ), + ( + "trailer_type", + models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, to="vehicle.type" + ), + ), + ], + options={ + "ordering": ["-created_at"], + "abstract": False, + }, + ), + migrations.CreateModel( + name="Equipment", + fields=[ + ( + "id", + models.UUIDField( + default=uuid.uuid4, + editable=False, + primary_key=True, + serialize=False, + unique=True, ), ), + ("created_at", models.DateTimeField(auto_now_add=True)), + ("updated_at", models.DateTimeField(auto_now=True)), + ("unicode_id", models.IntegerField(unique=True)), + ("prefix_id", models.CharField(max_length=10)), + ( + "chassis_number", + models.CharField(blank=True, max_length=50, null=True), + ), + ( + "engine_number", + models.CharField(blank=True, max_length=50, null=True), + ), + ("description", models.CharField(max_length=2000)), + ("location", models.CharField(blank=True, max_length=50, null=True)), + ( + "classification_type", + models.CharField(blank=True, max_length=50, null=True), + ), + ( + "engine_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "transmission_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "differentials_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "brake_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "electrical_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "hydraulic_cylindar_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "hydraulic_hoses_and_chrome_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "chassis_condition", + models.CharField(blank=True, max_length=100, null=True), + ), + ( + "body_condition", + models.CharField(blank=True, max_length=100, null=True), + ), ( "brand", models.ForeignKey( @@ -101,10 +306,9 @@ class Migration(migrations.Migration): ), ), ( - "vehicle_type", + "equipment_type", models.ForeignKey( - on_delete=django.db.models.deletion.PROTECT, - to="vehicle.vehicletype", + on_delete=django.db.models.deletion.PROTECT, to="vehicle.type" ), ), ], diff --git a/backend/vehicle/migrations/0002_remove_brand_identifier_remove_vehicle_identifier_and_more.py b/backend/vehicle/migrations/0002_remove_brand_identifier_remove_vehicle_identifier_and_more.py deleted file mode 100644 index e0f1e8f..0000000 --- a/backend/vehicle/migrations/0002_remove_brand_identifier_remove_vehicle_identifier_and_more.py +++ /dev/null @@ -1,58 +0,0 @@ -# Generated by Django 4.2.6 on 2023-10-22 02:26 - -from django.db import migrations, models -import uuid - - -class Migration(migrations.Migration): - dependencies = [ - ("vehicle", "0001_initial"), - ] - - operations = [ - migrations.RemoveField( - model_name="brand", - name="identifier", - ), - migrations.RemoveField( - model_name="vehicle", - name="identifier", - ), - migrations.RemoveField( - model_name="vehicletype", - name="identifier", - ), - migrations.AlterField( - model_name="brand", - name="id", - field=models.UUIDField( - default=uuid.uuid4, - editable=False, - primary_key=True, - serialize=False, - unique=True, - ), - ), - migrations.AlterField( - model_name="vehicle", - name="id", - field=models.UUIDField( - default=uuid.uuid4, - editable=False, - primary_key=True, - serialize=False, - unique=True, - ), - ), - migrations.AlterField( - model_name="vehicletype", - name="id", - field=models.UUIDField( - default=uuid.uuid4, - editable=False, - primary_key=True, - serialize=False, - unique=True, - ), - ), - ] diff --git a/backend/vehicle/models.py b/backend/vehicle/models.py index 2259656..0e2c63f 100644 --- a/backend/vehicle/models.py +++ b/backend/vehicle/models.py @@ -1,3 +1,5 @@ +from django.contrib.contenttypes.fields import GenericForeignKey +from django.contrib.contenttypes.models import ContentType from django.db import models from core.models import MainModel @@ -7,16 +9,71 @@ class Brand(MainModel): name = models.CharField(max_length=150, null=False) -class VehicleType(MainModel): +class Type(MainModel): name = models.CharField(max_length=150, null=False) class Vehicle(MainModel): - date = models.DateTimeField(editable=False) - asking_price = models.IntegerField(null=False) + unicode_id = models.IntegerField(unique=True) + model_number = models.CharField(max_length=10, blank=True, null=True) + chassis_number = models.CharField(max_length=50, blank=True, null=True) + description = models.CharField(max_length=2000) + brand = models.ForeignKey(Brand, on_delete=models.PROTECT) + vehicle_type = models.ForeignKey(Type, on_delete=models.PROTECT) + minimum_price = models.IntegerField(blank=True, null=True) + is_sold = models.BooleanField(default=False) + remarks = models.CharField(max_length=2000, blank=True, null=True) + classification_type = models.CharField(max_length=50, blank=True, null=True) + engine_condition = models.CharField(max_length=100, blank=True, null=True) + transmission_condition = models.CharField(max_length=100, blank=True, null=True) + differentials_condition = models.CharField(max_length=100, blank=True, null=True) + brake_condition = models.CharField(max_length=100, blank=True, null=True) + electrical_condition = models.CharField(max_length=100, blank=True, null=True) + operating_system_condition = models.CharField(max_length=100, blank=True, null=True) + chassis_condition = models.CharField(max_length=100, blank=True, null=True) + body_condition = models.CharField(max_length=100, blank=True, null=True) + + +class Equipment(MainModel): + unicode_id = models.IntegerField(unique=True) + prefix_id = models.CharField(max_length=10) + chassis_number = models.CharField(max_length=50, blank=True, null=True) + engine_number = models.CharField(max_length=50, blank=True, null=True) + description = models.CharField(max_length=2000) brand = models.ForeignKey(Brand, on_delete=models.PROTECT) + equipment_type = models.ForeignKey(Type, on_delete=models.PROTECT) + location = models.CharField(max_length=50, blank=True, null=True) + classification_type = models.CharField(max_length=50, blank=True, null=True) + engine_condition = models.CharField(max_length=100, blank=True, null=True) + transmission_condition = models.CharField(max_length=100, blank=True, null=True) + differentials_condition = models.CharField(max_length=100, blank=True, null=True) + brake_condition = models.CharField(max_length=100, blank=True, null=True) + electrical_condition = models.CharField(max_length=100, blank=True, null=True) + hydraulic_cylindar_condition = models.CharField( + max_length=100, blank=True, null=True + ) + hydraulic_hoses_and_chrome_condition = models.CharField( + max_length=100, blank=True, null=True + ) + chassis_condition = models.CharField(max_length=100, blank=True, null=True) + body_condition = models.CharField(max_length=100, blank=True, null=True) + + +class Supplier(MainModel): + name = models.CharField(max_length=150, null=False) + + +class Trailer(MainModel): + unicode_id = models.IntegerField(unique=True) + chassis_number = models.CharField(max_length=50, blank=True, null=True) description = models.CharField(max_length=2000) - auction = models.ForeignKey("auction.Auction", on_delete=models.PROTECT) - unicode_id = models.IntegerField() - model_number = models.IntegerField() - vehicle_type = models.ForeignKey(VehicleType, on_delete=models.PROTECT) + supplier = models.ForeignKey(Supplier, on_delete=models.PROTECT) + trailer_type = models.ForeignKey(Type, on_delete=models.PROTECT) + number_of_axles = models.IntegerField() + + +class UnitImage(MainModel): + image_url = models.CharField(max_length=500, null=False) + content_type = models.ForeignKey(ContentType, on_delete=models.PROTECT) + object_id = models.UUIDField() + content_object = GenericForeignKey("content_type", "object_id")