def time_difference(self):
     '''Calculates the difference between this tracking entry and the user's
     shiftlength'''
     value = round_down(self.total_working_time()) - \
             self.user.shiftlength_as_float()
     debug_log.debug("Time difference:" + str(value))
     return value
 def time_difference(self):
     '''Calculates the difference between this tracking entry and the user's
     shiftlength'''
     value = round_down(self.total_working_time()) - \
             self.user.shiftlength_as_float()
     debug_log.debug("Time difference:" + str(value))
     return value
 def totalhours(self):
     '''Total hours calculated for this tracking entry'''
     td = dt.timedelta(hours=self.end_time.hour,
                       minutes=self.end_time.minute)
     td -= dt.timedelta(hours=self.start_time.hour,
                        minutes=self.start_time.minute)
     td += dt.timedelta(hours=self.breaks.hour, minutes=self.breaks.minute)
     debug_log.debug(str((td.seconds / 60.0) / 60.0))
     return ((td.seconds / 60.0) / 60.0)
 def totalhours(self):
     '''Total hours calculated for this tracking entry'''
     td = dt.timedelta(hours=self.end_time.hour,
                       minutes=self.end_time.minute)
     td -= dt.timedelta(hours=self.start_time.hour,
                        minutes=self.start_time.minute)
     td += dt.timedelta(hours=self.breaks.hour,
                        minutes=self.breaks.minute)
     debug_log.debug(str((td.seconds / 60.0) / 60.0))
     return ((td.seconds / 60.0) / 60.0)
Beispiel #5
0
    def send_notifications(self):
        '''Send the associated notifications for this tracking entry.
        For example, if this entry is an overtime entry, it will generate and
        send out the e-mails as per the rules.'''

        if self.daytype == "WKDAY" and self.is_overtime() or \
                self.daytype in ["PUWRK", "SATUR"]:
            debug_log.debug("Overtime created: " + self.user.name())
            send_overtime_notification(self)
        if self.is_undertime() and self.sending_undertime():
            send_undertime_notification(self)
 def normalized_break(self): # pragma: no cover
     '''Returns the shorter of breaklengths between the users actual break
     length and the one for this entry.'''
     breaklength = dt.timedelta(hours=self.breaks.hour,
                                minutes=self.breaks.minute)
     breaklength_reg = dt.timedelta(hours=self.user.breaklength.hour,
                                    minutes=self.user.breaklength.minute)
     if breaklength.seconds > breaklength_reg.seconds:
         debug_log.debug("Returning regular break.")
         return breaklength_reg
     else:
         debug_log.debug("Returning actual break.")
         return breaklength
 def normalized_break(self):  # pragma: no cover
     '''Returns the shorter of breaklengths between the users actual break
     length and the one for this entry.'''
     breaklength = dt.timedelta(hours=self.breaks.hour,
                                minutes=self.breaks.minute)
     breaklength_reg = dt.timedelta(hours=self.user.breaklength.hour,
                                    minutes=self.user.breaklength.minute)
     if breaklength.seconds > breaklength_reg.seconds:
         debug_log.debug("Returning regular break.")
         return breaklength_reg
     else:
         debug_log.debug("Returning actual break.")
         return breaklength
 def send_notifications(self): # pragma: no cover
     '''Send the associated notifications for this tracking entry.
     For example, if this entry is an overtime entry, it will generate and
     send out the e-mails as per the rules.'''
     debug_log.debug("Send Overtime?:" + \
                     str(self.overtime_notification_check())
     )
     if self.daytype == "HOLIS":
         return self.holiday_approval_notification()
     if self.overtime_notification_check():
         debug_log.debug("Overtime created: " + self.user.name())
         send_overtime_notification(self)
         return
     if self.undertime_notification_check():
         send_undertime_notification(self)
         return
 def send_notifications(self):  # pragma: no cover
     '''Send the associated notifications for this tracking entry.
     For example, if this entry is an overtime entry, it will generate and
     send out the e-mails as per the rules.'''
     debug_log.debug("Send Overtime?:" + \
                     str(self.overtime_notification_check())
     )
     if self.daytype == "HOLIS":
         return self.holiday_approval_notification()
     if self.overtime_notification_check():
         debug_log.debug("Overtime created: " + self.user.name())
         send_overtime_notification(self)
         return
     if self.undertime_notification_check():
         send_undertime_notification(self)
         return
 def send_overtime_notification(*args, **kwargs):
     '''Not implemented'''
     debug_log.debug("default implementation of send_overtime_notification.")
from timetracker.loggers import debug_log, suspicious_log, cache_log


try:
    # The modules which provide these functions should be provided for by
    # the setup environment, this is due to the fact that some notifications
    # may include business-specific details, we can override by simply incl-
    # uding a local notifications.py in this directory with the required fu-
    # nctions we need.
    from timetracker.tracker.notifications import (
        send_overtime_notification, send_pending_overtime_notification,
        send_undertime_notification
        )
# pragma: no cover
except ImportError as e:
    debug_log.debug(str(e))
    #pylint: disable=W0613
    def send_overtime_notification(*args, **kwargs):
        '''Not implemented'''
        debug_log.debug("default implementation of send_overtime_notification.")
    def send_pending_overtime_notification(*args, **kwargs):
        '''Not implemented'''
    def send_undertime_notification(*args, **kwargs):
        '''Not implemented'''


class TrackingEntry(models.Model):

    '''Model which is used to enter working logs into the database.

    A tracking entry consists of several fields:-
 def send_overtime_notification(*args, **kwargs):
     '''Not implemented'''
     debug_log.debug(
         "default implementation of send_overtime_notification.")
from timetracker.loggers import debug_log, suspicious_log, cache_log

try:
    # The modules which provide these functions should be provided for by
    # the setup environment, this is due to the fact that some notifications
    # may include business-specific details, we can override by simply incl-
    # uding a local notifications.py in this directory with the required fu-
    # nctions we need.
    from timetracker.tracker.notifications import (
        send_overtime_notification, send_pending_overtime_notification,
        send_undertime_notification)


# pragma: no cover
except ImportError as e:
    debug_log.debug(str(e))

    #pylint: disable=W0613
    def send_overtime_notification(*args, **kwargs):
        '''Not implemented'''
        debug_log.debug(
            "default implementation of send_overtime_notification.")

    def send_pending_overtime_notification(*args, **kwargs):
        '''Not implemented'''

    def send_undertime_notification(*args, **kwargs):
        '''Not implemented'''


class TrackingEntry(models.Model):