1
Fork 0
e11sync/app/signup/models.py

23 lines
630 B
Python
Raw Normal View History

2024-01-12 01:31:38 +02:00
from django.db import models
2024-01-12 00:58:20 +02:00
2024-01-15 09:09:39 +02:00
2023-12-14 18:27:56 +02:00
class Signup(models.Model):
email = models.EmailField()
2024-01-15 09:09:39 +02:00
created_at = models.DateTimeField(auto_now_add=True)
2023-12-14 18:27:56 +02:00
anonymized_ip = models.GenericIPAddressField()
2024-01-15 09:09:39 +02:00
user_agent = models.CharField(max_length=255)
geoip = models.JSONField(null=True, blank=True)
2023-12-14 18:27:56 +02:00
class Meta:
constraints = [
2024-01-15 09:09:39 +02:00
models.UniqueConstraint(name="unique_email", fields=["email"]),
2023-12-14 18:27:56 +02:00
]
def __str__(self):
return self.email
2024-01-12 00:58:20 +02:00
2024-01-12 07:43:04 +02:00
def place_name(self):
2024-01-12 12:12:13 +02:00
if geoip := self.geoip:
return "{}, {}".format(geoip["city"], geoip["country_name"])
2024-01-12 07:43:04 +02:00
return "??"