diff --git a/caffeinateddomains/domains/migrations/0004_offer.py b/caffeinateddomains/domains/migrations/0004_offer.py new file mode 100644 index 0000000..37e0e46 --- /dev/null +++ b/caffeinateddomains/domains/migrations/0004_offer.py @@ -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, + ), + ), + ], + ), + ] diff --git a/caffeinateddomains/domains/models.py b/caffeinateddomains/domains/models.py index eb8820b..631252c 100644 --- a/caffeinateddomains/domains/models.py +++ b/caffeinateddomains/domains/models.py @@ -29,6 +29,27 @@ class Domain(models.Model): 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"), diff --git a/caffeinateddomains/domains/urls.py b/caffeinateddomains/domains/urls.py index 2a16df8..d28e6d8 100644 --- a/caffeinateddomains/domains/urls.py +++ b/caffeinateddomains/domains/urls.py @@ -2,6 +2,6 @@ from django.urls import path from .views import DomainListCreateView, OfferListCreateView urlpatterns = [ - path('domains/', DomainListCreateView.as_view(), name='domain_list_create'), - path('offers/', OfferListCreateView.as_view(), name='offer_list_create'), + path("domains/", DomainListCreateView.as_view(), name="domain_list_create"), + path("offers/", OfferListCreateView.as_view(), name="offer_list_create"), ]