aboutsummaryrefslogtreecommitdiff
path: root/apps/accounts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/accounts')
-rw-r--r--apps/accounts/models.py2
-rw-r--r--apps/accounts/signals.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/apps/accounts/models.py b/apps/accounts/models.py
index d000e3e..1b62ffd 100644
--- a/apps/accounts/models.py
+++ b/apps/accounts/models.py
@@ -26,4 +26,4 @@ class UserProfile(models.Model):
@cached_property
def get_notebook_list(self):
- return Notebook.objects.filter(owner=self.user).select_related()[:8]
+ return Notebook.objects.filter(owner=self.user).select_related().annotate(note_count=models.Count('note'))[:8]
diff --git a/apps/accounts/signals.py b/apps/accounts/signals.py
index 837a7ed..7c7f7c9 100644
--- a/apps/accounts/signals.py
+++ b/apps/accounts/signals.py
@@ -2,6 +2,7 @@ from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import User, UserProfile
+from notes.models import Notebook
@receiver(post_save, sender=User)
@@ -10,3 +11,5 @@ def create_profile(sender, update_fields, created, instance, **kwargs):
if created:
user_profile = UserProfile.objects.create(user=instance)
user_profile.save()
+ user_trash_notebook = Notebook.objects.create(owner=instance, name="Trash")
+ user_trash_notebook.save()