2019-06-27 06:09:51 +00:00
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
# Create your models here.
|
|
|
|
class Bookmark(models.Model):
|
|
|
|
url = models.TextField()
|
|
|
|
title = models.CharField(max_length=512)
|
|
|
|
description = models.TextField()
|
2019-06-28 17:37:41 +00:00
|
|
|
website_title = models.CharField(max_length=512)
|
|
|
|
website_description = models.TextField()
|
2019-06-27 06:09:51 +00:00
|
|
|
unread = models.BooleanField(default=True)
|
|
|
|
date_added = models.DateTimeField()
|
|
|
|
owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
|
|
|
|
|
2019-06-28 17:37:41 +00:00
|
|
|
@property
|
|
|
|
def resolved_title(self):
|
|
|
|
return self.website_title if not self.title else self.title
|
|
|
|
|
|
|
|
@property
|
|
|
|
def resolved_description(self):
|
|
|
|
return self.website_description if not self.description else self.description
|
|
|
|
|
2019-06-27 06:09:51 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.title + ' (' + self.url[:30] + '...)'
|