feat: add Offer model and migration
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.
This commit is contained in:
parent
1e1b590803
commit
0d3f1c3733
3 changed files with 88 additions and 2 deletions
65
caffeinateddomains/domains/migrations/0004_offer.py
Normal file
65
caffeinateddomains/domains/migrations/0004_offer.py
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
# Generated by Django 5.0.7 on 2024-08-02 15:33
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
(
|
||||||
|
"domains",
|
||||||
|
"0003_domain_accept_offers_domain_additional_info_request_and_more",
|
||||||
|
),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="Offer",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("offered_price", models.DecimalField(decimal_places=2, max_digits=10)),
|
||||||
|
("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(
|
||||||
|
choices=[
|
||||||
|
("pending", "Pending"),
|
||||||
|
("accepted", "Accepted"),
|
||||||
|
("rejected", "Rejected"),
|
||||||
|
],
|
||||||
|
default="pending",
|
||||||
|
max_length=20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"domain",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="offers",
|
||||||
|
to="domains.domain",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"user",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="offers",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -29,6 +29,27 @@ class Domain(models.Model):
|
||||||
return self.name
|
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):
|
class DNSRecord(models.Model):
|
||||||
RECORD_TYPE_CHOICES = [
|
RECORD_TYPE_CHOICES = [
|
||||||
("A", "A"),
|
("A", "A"),
|
||||||
|
|
|
@ -2,6 +2,6 @@ from django.urls import path
|
||||||
from .views import DomainListCreateView, OfferListCreateView
|
from .views import DomainListCreateView, OfferListCreateView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('domains/', DomainListCreateView.as_view(), name='domain_list_create'),
|
path("domains/", DomainListCreateView.as_view(), name="domain_list_create"),
|
||||||
path('offers/', OfferListCreateView.as_view(), name='offer_list_create'),
|
path("offers/", OfferListCreateView.as_view(), name="offer_list_create"),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue