Exemplo n.º 1
0
    def test_list_of_students_to_add(self):
        """
        Check the student selector for adding to the timeline entry
        """
        c1 = Class(
            customer=self.customer,
            lesson_type=self.lesson.get_contenttype(),
        )

        other_customer = create_customer()
        c2 = Class(
            customer=other_customer,
            lesson_type=self.lesson.get_contenttype(),
        )

        c1.assign_entry(self.entry)
        c1.save()

        c2.save()
        response = self.c.get(self.entry.get_absolute_url())
        with self.assertHTML(response, 'select.add-a-student__selector>option') as options:
            self.assertEqual(len(options), 2)  # the first one is 'zero-option'
            self.assertEqual(options[1].attrib.get('value'), reverse('timeline:add_customer', kwargs={
                'username': self.teacher.user.username,
                'pk': self.entry.pk,
                'customer': other_customer.pk,
            }))  # the second — is the student with c2
Exemplo n.º 2
0
 def _buy_a_lesson(self, lesson):
     c = Class(
         customer=self.customer,
         lesson_type=lesson.get_contenttype(),
     )
     c.save()
     return c
Exemplo n.º 3
0
    def test_single_class_name(self):
        lesson = products.OrdinaryLesson.get_default()
        c = Class(customer=self.customer, lesson_type=lesson.get_contenttype())
        c.save()

        self.assertEqual(
            str(c.name_for_user), 'Curated lesson'
        )  # feel free to change if you've renamed OrdinaryLesson
Exemplo n.º 4
0
 def _buy_a_lesson(self):
     c = Class(
         customer=self.customer,
         lesson_type=self.lesson.get_contenttype(),
     )
     c.save()
     self.assertFalse(c.is_fully_used)
     self.assertFalse(c.is_scheduled)
     return c
Exemplo n.º 5
0
    def test_can_schedule_classes(self):
        customer = create_customer()

        self.assertFalse(customer.can_schedule_classes())
        c = Class(
            lesson_type=lessons.OrdinaryLesson.get_contenttype(),
            customer=customer
        )
        c.save()
        self.assertTrue(customer.can_schedule_classes())
Exemplo n.º 6
0
 def _buy_a_lesson(self, customer=None):
     if customer is None:
         customer = self.customer
     c = Class(
         customer=customer,
         lesson_type=self.lesson.get_contenttype(),
         buy_price=random.randint(100, 500),
     )
     c.save()
     self.assertFalse(c.is_fully_used)
     self.assertFalse(c.is_scheduled)
     return c
Exemplo n.º 7
0
    def test_template_context(self):
        c = Class(
            customer=self.customer,
            lesson_type=self.lesson.get_contenttype(),
        )
        c.assign_entry(self.entry)
        c.save()

        response = self.c.get(self.entry.get_absolute_url())

        with self.assertHTML(response, 'dd') as inf:
            self.assertEquals(inf[0].text, self.teacher.user.crm.full_name)

        with self.assertHTML(response, '.page-header>h1') as (title,):
            self.assertEquals(title.text, str(self.entry))

        with self.assertHTML(response, 'td.timeline-student-list__student>a') as (student, staff):
            self.assertIn(self.customer.full_name, student.text)

        with self.assertHTML(response, 'a.timeline-student-list__actions') as (a,):
            del_url = reverse('timeline:delete_customer', kwargs={
                'username': self.teacher.user.username,
                'pk': self.entry.pk,
                'customer': self.customer.pk,
            })
            self.assertEqual(a.attrib.get('href'), del_url)
Exemplo n.º 8
0
    def test_del_student(self):
        c = Class(
            customer=self.customer,
            lesson_type=self.lesson.get_contenttype(),
        )
        c.assign_entry(self.entry)
        c.save()

        self.assertEqual(self.entry.taken_slots, 1)
        self.assertTrue(c.is_scheduled)

        url = reverse('timeline:delete_customer', kwargs={
            'username': self.teacher.user.username,
            'pk': self.entry.pk,
            'customer': self.customer.pk,
        })
        response = self.c.get(url)
        self.assertEqual(response.status_code, 302)
        self.entry.refresh_from_db()
        c.refresh_from_db()

        self.assertEqual(self.entry.taken_slots, 0)
        self.assertFalse(c.is_scheduled)
Exemplo n.º 9
0
    def test_schedule_2_people_to_a_paired_lesson(self):
        customer1 = create_customer()
        customer2 = create_customer()

        paired_lesson = mixer.blend(lessons.PairedLesson, slots=2, host=self.host)

        customer1_class = Class(
            customer=customer1,
            lesson_type=paired_lesson.get_contenttype(),
        )
        customer1_class.save()

        customer2_class = Class(
            customer=customer2,
            lesson_type=paired_lesson.get_contenttype(),
        )
        customer2_class.save()

        timeline_entry = mixer.blend(TimelineEntry, lesson=paired_lesson, teacher=self.host, start=self.tzdatetime(2032, 12, 1))

        customer1_class.assign_entry(timeline_entry)
        customer1_class.save()

        customer2_class.assign_entry(timeline_entry)
        customer2_class.save()

        self.assertTrue(customer1_class.is_scheduled)
        self.assertTrue(customer2_class.is_scheduled)
        self.assertEqual(timeline_entry.taken_slots, 2)

        customer2_class.cancel()
        self.assertEqual(timeline_entry.taken_slots, 1)
Exemplo n.º 10
0
 def _buy_a_lesson(self):
     c = Class(customer=self.customer, lesson_type=self.lesson)
     c.save()
     return c
Exemplo n.º 11
0
 def _buy_a_lesson(self, lesson):
     c = Class(customer=self.customer, lesson=lesson)
     c.save()
     return c