Exemplo n.º 1
0
 def save(self, commit=True):
     book_timeoff = super(BookTimeOffForm, self).save(commit)
     status = ApproverQueue.in_queue_status()
     
     booktimeoff_inqueue_history = BookTimeOfffHistory(book_timeoff=book_timeoff, book_timeoff_status=status)
     booktimeoff_inqueue_history.save()
     
     return book_timeoff
Exemplo n.º 2
0
def post_final_status_update(sender, **kwargs):
    """
        Post the final status to be updated
        Called by signal
    """
    book_timeoff = kwargs['instance']
    booktimeoff_inqueue_history = BookTimeOfffHistory(book_timeoff=book_timeoff, book_timeoff_status=kwargs['status'])
    booktimeoff_inqueue_history.save()
    #decrement time-remaining
    
    policies = UserTimeOffPolicy.objects.policies(book_timeoff.user, book_timeoff.timeoff_type.id)
    for policy in policies:
        policy.time_remaining -= book_timeoff.number_of_days
        #overdrawn, attempt to remove from overdraw property. if overdraw becomes negative, throw exception
        if policy.time_remaining < 0:
            policy.max_overdraw_limit += policy.time_remaining
            policy.time_remaining = 0
            
        policy.save()