Ejemplo n.º 1
0
 def test_other_discounts_set(self, stylist_data: Stylist):
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_other_discounts_set'] is False
     )
     stylist_data.first_time_book_discount_percent = 10
     stylist_data.save()
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_other_discounts_set'] is True
     )
     stylist_data.first_time_book_discount_percent = 0
     stylist_data.rebook_within_1_week_discount_percent = 10
     stylist_data.save()
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_other_discounts_set'] is True
     )
     stylist_data.first_time_book_discount_percent = 0
     stylist_data.rebook_within_1_week_discount_percent = 0
     stylist_data.save()
     G(
         StylistDateRangeDiscount, stylist=stylist_data,
         dates=DateRange(datetime.date(2018, 4, 8), datetime.date(2018, 4, 10))
     )
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_other_discounts_set'] is True
     )
Ejemplo n.º 2
0
 def test_completed_profile(self, stylist_data: Stylist):
     user = stylist_data.user
     assert(
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_personal_data'] is True
     )
     user.first_name = ''
     user.last_name = ''
     user.phone = ''
     user.save()
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_personal_data'] is False
     )
     user.phone = '12345'
     user.save()
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_personal_data'] is False
     )
     user.first_name = 'Fred'
     user.save()
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_personal_data'] is True
     )
     salon = stylist_data.salon
     salon.address = ''
     salon.save()
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_personal_data'] is False
     )
Ejemplo n.º 3
0
 def test_weekday_discounts_set(self, stylist_data: Stylist):
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_weekday_discounts_set'] is False
     )
     G(StylistWeekdayDiscount, stylist=stylist_data)
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_weekday_discounts_set'] is True
     )
Ejemplo n.º 4
0
 def test_services_set(self, stylist_data: Stylist):
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_services_set'] is False
     )
     G(StylistService, stylist=stylist_data, duration=datetime.timedelta(0))
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_services_set'] is True
     )
Ejemplo n.º 5
0
 def test_profile_picture(self, stylist_data: Stylist):
     user = stylist_data.user
     user.photo = None
     user.save()
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_picture_set'] is False
     )
     user.photo = 'http://example.com/1.jpg'
     user.save()
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_picture_set'] is True
     )
Ejemplo n.º 6
0
 def test_business_hours_set(self, stylist_data: Stylist):
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_business_hours_set'] is False
     )
     G(StylistAvailableWeekDay, weekday=1, stylist=stylist_data, is_available=False)
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_business_hours_set'] is False
     )
     G(StylistAvailableWeekDay, weekday=2, stylist=stylist_data, is_available=True,
       work_start_at=datetime.time(8, 0), work_end_at=datetime.time(15, 0))
     assert (
         StylistProfileStatusSerializer(
             instance=stylist_data).data['has_business_hours_set'] is True
     )
Ejemplo n.º 7
0
 def get_profile_status(self, data):
     user = self.context['user']
     if user.is_stylist():
         return StylistProfileStatusSerializer(
             getattr(user, 'stylist', None)).data
     return []
Ejemplo n.º 8
0
 def get_profile_status(self, data):
     user = self.context['user']
     if user.role == UserRole.STYLIST:
         return StylistProfileStatusSerializer(
             getattr(user, 'stylist', None)).data
     return []