summaryrefslogtreecommitdiffstats
path: root/statuses/models
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-05 14:17:27 -0600
committerAndrew Godwin2022-11-05 14:17:27 -0600
commitd77dcf62b4005a0f36ef2fa7ba6d3651d2ef38d7 (patch)
treedd356a933b8179a22e5da6e938acd96a175ac0d6 /statuses/models
downloadtakahe-d77dcf62b4005a0f36ef2fa7ba6d3651d2ef38d7.tar.gz
takahe-d77dcf62b4005a0f36ef2fa7ba6d3651d2ef38d7.tar.bz2
takahe-d77dcf62b4005a0f36ef2fa7ba6d3651d2ef38d7.zip
Initial commit (users and statuses)
Diffstat (limited to 'statuses/models')
-rw-r--r--statuses/models/__init__.py1
-rw-r--r--statuses/models/status.py35
2 files changed, 36 insertions, 0 deletions
diff --git a/statuses/models/__init__.py b/statuses/models/__init__.py
new file mode 100644
index 0000000..84098eb
--- /dev/null
+++ b/statuses/models/__init__.py
@@ -0,0 +1 @@
+from .status import Status # noqa
diff --git a/statuses/models/status.py b/statuses/models/status.py
new file mode 100644
index 0000000..2e17a19
--- /dev/null
+++ b/statuses/models/status.py
@@ -0,0 +1,35 @@
+from django.db import models
+
+
+class Status(models.Model):
+ class StatusVisibility(models.IntegerChoices):
+ public = 0
+ unlisted = 1
+ followers = 2
+ mentioned = 3
+
+ identity = models.ForeignKey(
+ "users.Identity",
+ on_delete=models.PROTECT,
+ related_name="statuses",
+ )
+
+ local = models.BooleanField()
+ uri = models.CharField(max_length=500, blank=True, null=True)
+ visibility = models.IntegerField(
+ choices=StatusVisibility.choices,
+ default=StatusVisibility.public,
+ )
+ text = models.TextField()
+
+ created = models.DateTimeField(auto_now_add=True)
+ updated = models.DateTimeField(auto_now=True)
+ deleted = models.DateTimeField(null=True, blank=True)
+
+ @classmethod
+ def create_local(cls, identity, text: str):
+ return cls.objects.create(
+ identity=identity,
+ text=text,
+ local=True,
+ )