示例#1
0
文件: cron.py 项目: filipp/Servo
    def notify_stock_limits(self):
        conf = Configuration.conf()

        try:
            sender = conf['default_sender']
        except KeyError:
            raise ValueError('Default sender address not defined')

        locations = Location.objects.filter(site_id=settings.SITE_ID)

        for l in locations:
            out_of_stock = Inventory.objects.filter(
                location=l,
                amount_stocked__lt=F('amount_minimum')
            )

            table = CsvTable()
            table.addheader(['Product', 'Minimum', 'Stocked'])

            for i in out_of_stock:
                table.addrow([i.product.code, i.amount_minimum, i.amount_stocked])

            subject = _(u"Products stocked below limit")

            if Configuration.notify_location():
                send_table(sender, l.email, subject, table)
            if Configuration.notify_email_address():
                send_table(sender, conf['notify_address'], subject, table)
示例#2
0
文件: cron.py 项目: luetgendorf/Servo
    def notify_aging_repairs(self):
        """
        Reports on cases that have been red for a day
        """
        now = timezone.now()
        limit = now - timedelta(days=1)

        for l in Location.objects.filter(enabled=True):
            table = CsvTable()
            subject = _(u"Repairs aging beyond limits at %s") % l.title
            table.addheader(['ORDER', 'ASSIGNED_TO', 'STATUS', 'DAYS_RED'])

            # "Aging" repairs are ones that have been red for at least a day
            orders = Order.objects.filter(location=l,
                                          state__lt=Order.STATE_CLOSED,
                                          status_limit_yellow__lt=limit)

            for o in orders:
                username = o.get_user_name() or _("Nobody")
                status_title = o.get_status_name() or _("No Status")
                days = (now - o.status_limit_yellow).days
                table.addrow([o.code, username, status_title, days])

            if Configuration.notify_location():
                recipient = l.manager.email if l.manager else l.email
                send_table(self.mail_sender, recipient, subject, table)
            if self.mail_recipient:
                send_table(self.mail_sender, self.mail_recipient, subject, table)
示例#3
0
文件: cron.py 项目: filipp/Servo
    def notify_aging_repairs(self):
        """
        Reports on cases that have been red for a day
        """
        conf = Configuration.conf()

        try:
            sender = conf['default_sender']
        except KeyError:
            raise ValueError('Default sender address not defined')

        now = timezone.now()
        limit = now - timedelta(days=1)
        locations = Location.objects.filter(site_id=settings.SITE_ID)

        for l in locations:
            table = CsvTable()
            table.addheader(['Order', 'Assigned To', 'Status', 'Days red'])

            # "Aging" repairs are ones that have been red for at least a day
            orders = Order.objects.filter(
                location=l,
                state__lt=Order.STATE_CLOSED,
                status_limit_yellow__lt=limit
            )

            for o in orders:
                username = o.get_user_name() or _("Unassigned")
                status_title = o.get_status_name() or _("No Status")
                days = (now - o.status_limit_yellow).days
                table.addrow([o.code, username, status_title, days])

            subject = _(u"Repairs aging beyond limits at %s") % l.title

            if Configuration.notify_location():
                send_table(sender, l.email, subject, table)
            if Configuration.notify_email_address():
                send_table(sender, conf['notify_address'], subject, table)
示例#4
0
文件: cron.py 项目: luetgendorf/Servo
    def notify_stock_limits(self):
        """
        Notifies the correct parties of inventory items stocking status
        """
        subject = _(u"Products stocked below limit")

        for l in Location.objects.filter(enabled=True):
            out_of_stock = Inventory.objects.filter(
                location=l,
                amount_stocked__lt=F('amount_minimum')
            )

            table = CsvTable()
            table.addheader(['PRODUCT', 'MINIMUM', 'STOCKED'])

            for i in out_of_stock:
                table.addrow([i.product.code, i.amount_minimum, i.amount_stocked])

            if Configuration.notify_location():
                recipient = l.manager.email if l.manager else l.email
                send_table(self.mail_sender, recipient, subject, table)
            if self.mail_recipient:
                send_table(self.mail_sender, self.mail_recipient, subject, table)