aboutsummaryrefslogtreecommitdiff
path: root/apps/accounts/models.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2018-11-29 16:57:26 -0600
committerluxagraf <sng@luxagraf.net>2018-11-29 16:57:26 -0600
commit4974eb58480f413c67f5f6e8fac430186eda2b62 (patch)
tree7402ecba682dbda38db4b6db221cc8378a390977 /apps/accounts/models.py
parent0c2a092e8d8ad33a1c306ee9efca0da96eb56415 (diff)
uploading all recent changes ahead of sys upgrade
Diffstat (limited to 'apps/accounts/models.py')
-rw-r--r--apps/accounts/models.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/apps/accounts/models.py b/apps/accounts/models.py
index 5ed7634..d000e3e 100644
--- a/apps/accounts/models.py
+++ b/apps/accounts/models.py
@@ -1,5 +1,8 @@
from django.db import models
from django.contrib.auth.models import AbstractUser
+from django.utils.functional import cached_property
+
+from notes.models import Notebook
class User(AbstractUser):
@@ -10,7 +13,7 @@ class User(AbstractUser):
class UserProfile(models.Model):
- user = models.OneToOneField(User, on_delete=models.CASCADE)
+ user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
photo = models.ImageField(upload_to='profile', null=True, blank=True)
website = models.CharField(max_length=300, null=True, blank=True, default='')
location = models.CharField(max_length=300, null=True, blank=True, default='')
@@ -20,3 +23,7 @@ class UserProfile(models.Model):
def __str__(self):
return self.user.username
+
+ @cached_property
+ def get_notebook_list(self):
+ return Notebook.objects.filter(owner=self.user).select_related()[:8]