2015-01-03 14:36:22 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2023-10-19 22:52:39 +00:00
|
|
|
|
2015-01-03 14:36:22 +00:00
|
|
|
class Supporter(models.Model):
|
|
|
|
"""Conservancy Supporter listing"""
|
|
|
|
|
|
|
|
display_name = models.CharField(max_length=200, blank=False)
|
2024-10-23 07:16:47 +00:00
|
|
|
display_until_date = models.DateTimeField(
|
|
|
|
"date until which this supporter name is displayed"
|
|
|
|
)
|
2015-01-03 14:36:22 +00:00
|
|
|
ledger_entity_id = models.CharField(max_length=200, blank=False)
|
|
|
|
|
|
|
|
def test(self):
|
|
|
|
return "TESTING"
|
2024-10-22 05:10:07 +00:00
|
|
|
|
2022-01-10 22:13:46 +00:00
|
|
|
def __str__(self):
|
2015-01-03 14:36:22 +00:00
|
|
|
return self.display_name
|
|
|
|
|
2023-09-07 13:15:48 +00:00
|
|
|
class Meta:
|
2015-01-04 17:10:09 +00:00
|
|
|
ordering = ('ledger_entity_id',)
|
2024-07-22 10:13:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SustainerOrder(models.Model):
|
2024-09-30 07:40:29 +00:00
|
|
|
RENEW_CHOICES = [
|
2024-10-22 05:10:07 +00:00
|
|
|
('', 'Once'),
|
2024-09-30 07:40:29 +00:00
|
|
|
('month', 'Monthly'),
|
2024-10-22 05:10:07 +00:00
|
|
|
('year', 'Annually'),
|
2024-09-30 07:40:29 +00:00
|
|
|
]
|
2024-07-22 10:13:22 +00:00
|
|
|
TSHIRT_CHOICES = [
|
|
|
|
(
|
|
|
|
'',
|
2024-10-08 15:01:32 +00:00
|
|
|
(("", "None"),),
|
2024-07-22 10:13:22 +00:00
|
|
|
),
|
|
|
|
(
|
|
|
|
"Men's",
|
|
|
|
(
|
|
|
|
("Men's S", "Men's S"),
|
|
|
|
("Men's M", "Men's M"),
|
|
|
|
("Men's L", "Men's L"),
|
|
|
|
("Men's XL", "Men's XL"),
|
|
|
|
("Men's 2XL", "Men's 2XL"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"Standard women's",
|
|
|
|
(
|
|
|
|
("Standard women's S", "Standard women's S"),
|
|
|
|
("Standard women's M", "Standard women's M"),
|
|
|
|
("Standard women's L", "Standard women's L"),
|
|
|
|
("Standard women's XL", "Standard women's XL"),
|
|
|
|
("Standard women's 2XL", "Standard women's 2XL"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"Fitted women's",
|
|
|
|
(
|
|
|
|
("Fitted women's S", "Fitted women's S"),
|
|
|
|
("Fitted women's M", "Fitted women's M"),
|
|
|
|
("Fitted women's L", "Fitted women's L"),
|
|
|
|
("Fitted women's XL", "Fitted women's XL"),
|
|
|
|
("Fitted women's 2XL", "Fitted women's 2XL"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
created_time = models.DateTimeField(auto_now_add=True)
|
2024-11-15 08:24:49 +00:00
|
|
|
stripe_customer_ref = models.CharField(max_length=50, null=True)
|
|
|
|
stripe_subscription_ref = models.CharField(max_length=50, null=True, unique=True)
|
|
|
|
stripe_initial_payment_intent_ref = models.CharField(max_length=50, null=True, unique=True)
|
|
|
|
stripe_checkout_session_data = models.JSONField(null=True)
|
2024-07-22 10:13:22 +00:00
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
email = models.EmailField()
|
2024-11-15 08:24:49 +00:00
|
|
|
amount = models.DecimalField(max_digits=7, decimal_places=2)
|
2024-10-23 07:16:47 +00:00
|
|
|
recurring = models.CharField(
|
|
|
|
max_length=10, choices=RENEW_CHOICES, blank=True, default=''
|
|
|
|
)
|
2024-10-08 15:01:32 +00:00
|
|
|
payment_method = models.CharField(max_length=10, default='Stripe')
|
2024-07-22 10:13:22 +00:00
|
|
|
paid_time = models.DateTimeField(null=True, blank=True)
|
2024-09-30 07:40:29 +00:00
|
|
|
acknowledge_publicly = models.BooleanField(default=True)
|
|
|
|
add_to_mailing_list = models.BooleanField(default=True)
|
2024-10-23 07:16:47 +00:00
|
|
|
tshirt_size = models.CharField(
|
|
|
|
'T-shirt size', max_length=50, choices=TSHIRT_CHOICES, blank=True, default=''
|
|
|
|
)
|
2024-07-22 10:13:22 +00:00
|
|
|
street = models.CharField(max_length=255, blank=True)
|
|
|
|
city = models.CharField(max_length=255, blank=True)
|
|
|
|
state = models.CharField(max_length=255, blank=True)
|
|
|
|
zip_code = models.CharField(max_length=255, blank=True)
|
|
|
|
country = models.CharField(max_length=255, blank=True)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f'Sustainer order {self.id}: {self.email}'
|
|
|
|
|
|
|
|
def paid(self):
|
|
|
|
return self.paid_time is not None
|
2024-11-15 08:24:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SustainerPayment(models.Model):
|
|
|
|
order = models.ForeignKey(SustainerOrder, on_delete=models.CASCADE)
|
|
|
|
paid_time = models.DateTimeField(auto_now_add=True)
|
|
|
|
stripe_invoice_ref = models.CharField(max_length=50, null=True, unique=True)
|
|
|
|
amount = models.DecimalField(max_digits=7, decimal_places=2)
|
|
|
|
stripe_payment_intent_ref = models.CharField(max_length=50, null=True, unique=True)
|
|
|
|
stripe_invoice_data = models.JSONField(null=True)
|