2022-11-05 23:51:54 +00:00
|
|
|
import urlman
|
2022-11-05 20:17:27 +00:00
|
|
|
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,
|
|
|
|
)
|
2022-11-05 23:51:54 +00:00
|
|
|
|
|
|
|
class urls(urlman.Urls):
|
2022-11-06 20:48:04 +00:00
|
|
|
view = "{self.identity.urls.view}statuses/{self.id}/"
|