-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
399 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
backend/auction/migrations/0002_remove_auction_identifier_auction_name_and_more.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Bid | ||
|
||
# Register your models here. | ||
admin.site.register(Bid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
backend/bid/migrations/0002_remove_bid_identifier_alter_bid_id.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Oops, something went wrong.