Exemplo n.º 1
0
    def test_originator_customers_multiple(self):
        """
        Add a second customer to the timeline entry and check if originator_customer
        will return it.
            1) set slot count of a lesson to 5
            2) update the timeline entry (calling save()) to set it's slot count
            3) schedule a class of another customer
            4) ???
            5) check originator_customers

        """
        self.lesson.slots = 5  # set lesson slots to 5, to update timeine entry slot count
        self.lesson.save()
        self.entry.save()

        other_customer = create_customer()

        self._buy_a_lesson(customer=other_customer)
        self._schedule(customer=other_customer)

        ev = AccEvent(
            teacher=self.host,
            originator=self.entry,
            event_type='class',
        )
        ev.save()

        self.assertEqual(len(ev.originator_customers), 2)
        self.assertIn(other_customer, ev.originator_customers)
        self.assertIn(self.customer, ev.originator_customers)
Exemplo n.º 2
0
    def test_originator_customers_single(self):
        ev = AccEvent(
            teacher=self.host,
            originator=self.entry,
            event_type='class',
        )
        ev.save()

        self.assertEqual(ev.originator_customers[0], self.customer)
Exemplo n.º 3
0
    def test_originator_customers_cancellation(self):
        ev = AccEvent(
            teacher=self.host,
            originator=self.c,
            event_type='customer_inspired_cancellation',
        )
        ev.save()

        self.assertEqual(ev.originator_customers, [self.customer])
Exemplo n.º 4
0
    def test_originator_timestamp_entries_class(self):
        ev = AccEvent(
            teacher=self.host,
            originator=self.entry,
            event_type='class',
        )
        ev.save()

        self.assertEqual(ev.originator_time, self.entry.start)
Exemplo n.º 5
0
def account_class_cancellation(sender, **kwargs):
    if kwargs['src'] != 'customer':
        return

    cancelled_class = kwargs['instance']
    ev = AccEvent(
        originator=cancelled_class,
        teacher=cancelled_class.timeline.teacher,
        event_type='customer_inspired_cancellation',
    )
    ev.save()
Exemplo n.º 6
0
def bill_timeline_entries():
    for entry in TimelineEntry.objects.to_be_marked_as_finished().filter(
            taken_slots__gte=1):
        entry.is_finished = True
        entry.save()

        if not AccEvent.objects.by_originator(entry).count():
            ev = AccEvent(
                teacher=entry.teacher,
                originator=entry,
                event_type='class',
            )
            ev.save()
        else:
            logger.warning('Tried to bill already billed timeline entry')