Add signal docstring

This commit is contained in:
sosokker 2023-11-21 03:11:19 +07:00
parent 167d943740
commit fc1134d744
2 changed files with 4 additions and 1 deletions

View File

@ -6,6 +6,7 @@ from users.models import CustomUser
@receiver(post_save, sender=CustomUser)
def create_default_board(sender, instance, created, **kwargs):
"""Signal handler to automatically create a default Board for a user upon creation."""
if created:
board = Board.objects.create(user=instance, name="My Default Board")

View File

@ -2,12 +2,13 @@ from django.db.models.signals import pre_save, post_save
from django.dispatch import receiver
from django.utils import timezone
from boards.models import ListBoard
from boards.models import ListBoard, Board
from tasks.models import Todo
@receiver(pre_save, sender=Todo)
def update_priority(sender, instance, **kwargs):
"""Update the priority of a Todo based on the Eisenhower Matrix"""
if instance.end_event:
time_until_due = (instance.end_event - timezone.now()).days
else:
@ -28,6 +29,7 @@ def update_priority(sender, instance, **kwargs):
@receiver(post_save, sender=Todo)
def assign_todo_to_listboard(sender, instance, created, **kwargs):
"""Signal handler to automatically assign a Todo to the first ListBoard in the user's Board upon creation."""
if created:
user_board = instance.user.board_set.first()