Kumi
0d3f1c3733
Introduce the Offer model to manage domain purchase offers. The new model includes fields for offered price, messages, intended use, and status with choices for 'pending', 'accepted', and 'rejected', linked to both the Domain and User models. Updated URLs to support offer creation and listing. This change facilitates better tracking and management of offers made on domains, enabling more robust domain transactions.
103 lines
3.5 KiB
Python
103 lines
3.5 KiB
Python
from django.db import models
|
|
from django.contrib.auth import get_user_model
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
class Domain(models.Model):
|
|
STATUS_CHOICES = [
|
|
("available", "Available"),
|
|
("parked", "Parked"),
|
|
("leased", "Leased"),
|
|
("for_sale", "For Sale"),
|
|
]
|
|
|
|
name = models.CharField(max_length=255, unique=True)
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES)
|
|
owner = models.ForeignKey(User, on_delete=models.CASCADE, related_name="domains")
|
|
registration_date = models.DateField()
|
|
expiration_date = models.DateField()
|
|
price = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)
|
|
description = models.TextField(blank=True, null=True)
|
|
accept_offers = models.BooleanField(default=False)
|
|
buy_now_price = models.DecimalField(
|
|
max_digits=10, decimal_places=2, null=True, blank=True
|
|
)
|
|
additional_info_request = models.TextField(blank=True, null=True)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
|
|
class Offer(models.Model):
|
|
domain = models.ForeignKey(Domain, on_delete=models.CASCADE, related_name="offers")
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="offers")
|
|
offered_price = models.DecimalField(max_digits=10, decimal_places=2)
|
|
message = models.TextField(blank=True, null=True)
|
|
intended_use = models.TextField(blank=True, null=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
status = models.CharField(
|
|
max_length=20,
|
|
choices=[
|
|
("pending", "Pending"),
|
|
("accepted", "Accepted"),
|
|
("rejected", "Rejected"),
|
|
],
|
|
default="pending",
|
|
)
|
|
|
|
def __str__(self):
|
|
return f"Offer for {self.domain.name} by {self.user.email}"
|
|
|
|
|
|
class DNSRecord(models.Model):
|
|
RECORD_TYPE_CHOICES = [
|
|
("A", "A"),
|
|
("CNAME", "CNAME"),
|
|
("MX", "MX"),
|
|
# TODO: Add other record types as needed
|
|
]
|
|
|
|
domain = models.ForeignKey(
|
|
Domain, on_delete=models.CASCADE, related_name="dns_records"
|
|
)
|
|
record_type = models.CharField(max_length=10, choices=RECORD_TYPE_CHOICES)
|
|
record_value = models.CharField(max_length=255)
|
|
ttl = models.IntegerField(default=3600)
|
|
priority = models.IntegerField(null=True, blank=True)
|
|
|
|
|
|
class LeaseAgreement(models.Model):
|
|
STATUS_CHOICES = [
|
|
("active", "Active"),
|
|
("expired", "Expired"),
|
|
("terminated", "Terminated"),
|
|
]
|
|
|
|
domain = models.ForeignKey(
|
|
Domain, on_delete=models.CASCADE, related_name="lease_agreements"
|
|
)
|
|
lessee = models.ForeignKey(
|
|
get_user_model(), on_delete=models.CASCADE, related_name="leases"
|
|
)
|
|
start_date = models.DateField()
|
|
end_date = models.DateField()
|
|
payment_terms = models.CharField(max_length=255)
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES)
|
|
|
|
|
|
class Payment(models.Model):
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="payments")
|
|
amount = models.DecimalField(max_digits=10, decimal_places=2)
|
|
payment_date = models.DateTimeField(auto_now_add=True)
|
|
payment_method = models.CharField(max_length=50)
|
|
transaction_id = models.CharField(max_length=255)
|
|
status = models.CharField(max_length=20)
|
|
|
|
|
|
class Registrar(models.Model):
|
|
name = models.CharField(max_length=255)
|
|
api_key = models.CharField(max_length=255)
|
|
api_secret = models.CharField(max_length=255)
|
|
contact_info = models.TextField()
|
|
supported_tlds = models.TextField()
|