Adding auto update user story finish date on all task close and task finished_date on task close
parent
8cb299c218
commit
ecd27d822d
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
@ -569,6 +571,19 @@ def user_story_ref_handler(sender, instance, **kwargs):
|
||||||
instance.ref = ref_uniquely(instance.project, 'last_us_ref', instance.__class__)
|
instance.ref = ref_uniquely(instance.project, 'last_us_ref', instance.__class__)
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(models.signals.pre_save, sender=Task, dispatch_uid='tasks_close_handler')
|
||||||
|
def tasks_close_handler(sender, instance, **kwargs):
|
||||||
|
"""
|
||||||
|
Automatically assignes a seguent reference code to a
|
||||||
|
user story if that is not created.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if instance.id and sender.objects.get(id=instance.id).status.is_closed == False and instance.status.is_closed == True:
|
||||||
|
instance.finished_date = datetime.now()
|
||||||
|
if all([task.status.is_closed for task in instance.user_story.tasks.exclude(id=instance.id)]):
|
||||||
|
instance.user_story.finish_date = datetime.now()
|
||||||
|
instance.user_story.save()
|
||||||
|
|
||||||
# Email alerts signals handlers
|
# Email alerts signals handlers
|
||||||
# TODO: temporary commented (Pending refactor)
|
# TODO: temporary commented (Pending refactor)
|
||||||
# from . import sigdispatch
|
# from . import sigdispatch
|
||||||
|
|
Loading…
Reference in New Issue