aboutsummaryrefslogtreecommitdiff
path: root/apps/notes/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'apps/notes/models.py')
-rw-r--r--apps/notes/models.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/apps/notes/models.py b/apps/notes/models.py
index 95c1c96..9dc4f13 100644
--- a/apps/notes/models.py
+++ b/apps/notes/models.py
@@ -25,6 +25,10 @@ class LuxTag(TagBase):
verbose_name = _("Tag")
verbose_name_plural = _("Tags")
+ @cached_property
+ def get_absolute_url(self):
+ return reverse("notes:tags", kwargs={"slug": self.slug})
+
class TaggedNotes(GenericTaggedItemBase):
tag = models.ForeignKey(LuxTag, related_name="%(app_label)s_%(class)s_items", on_delete=models.CASCADE)
@@ -55,6 +59,15 @@ class Notebook(models.Model):
def get_absolute_url(self):
return reverse("notebooks:detail", kwargs={"slug": self.slug})
+ @cached_property
+ def color_rgba(self, opacity=".5"):
+ try:
+ color = self.color_rgb.split('(')[1].split(')')[0]
+ rgba = "rgba(%s,%s)" % (color, opacity)
+ except AttributeError:
+ rgba = self.color_rgb
+ return rgba
+
class Note(models.Model):
unique_id = models.UUIDField(default=uuid.uuid4, editable=False)
@@ -88,3 +101,19 @@ class Note(models.Model):
if self._state.adding:
self.slug = unique_slug_generator(self)
super(Note, self).save()
+
+
+class Annotation(models.Model):
+ unique_id = models.UUIDField(default=uuid.uuid4, editable=False)
+ owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
+ date_created = models.DateTimeField(blank=True, auto_now_add=True, editable=False)
+ date_updated = models.DateTimeField(blank=True, auto_now=True, editable=False)
+ highlight_text = models.TextField(null=True)
+ body_text = models.TextField(null=True)
+ body_html = models.TextField(null=True, blank=True)
+ body_qjson = JSONField(null=True, blank=True)
+ note = models.ForeignKey(Note, null=True, blank=True, on_delete=models.SET_NULL)
+ is_public = models.BooleanField(default=False)
+
+ def __str__(self):
+ return self.body_text[:30]