Пример #1
0
    def test_user_with_friends_sees_friendship_events_in_feed(self):
        # John is a logged-in user.
        self.create_pre_authenticated_session(
            first_name='John',
            last_name='Carney',
            email='*****@*****.**',
            password='******'
        )

        # He has sent a friend request to Regina, who has accepted the request.
        john = User.objects.get(username='******')
        regina = User.objects.create_user(
            first_name='Regina',
            last_name='Mcdonalid',
            email='*****@*****.**',
            username='******',
            password='******'
        )

        friendship = Friendship.user_add_friend(john, friend=regina)
        friendship.accept()

        # He visits the homepage.
        self.browser.get(self.live_server_url + '/users/feed/')

        # He sees a list of events.
        event_list = self.browser.find_element_by_class_name('media-list')
        events = event_list.find_elements_by_class_name('media')

        # John sees a container describing the event of his friendship request to Regina.
        # The container has a label that reads "John added Regina as a friend" and there
        # is also a description with the date the friendship was created.
        event_1st = events[0]
        event_body = event_1st.find_element_by_class_name('media-body')

        self.assertIn('John added Regina as a friend', event_body.text)
        self.assertIn(date(friendship.created, getattr(settings, 'SHORT_DATE_FORMAT')), event_body.text)

        # He also sees a container describing the event of Regina accepting his friendship request.
        # The container has a label that reads "Regina accepted John's friendship" and there
        # is also a description with the date the friendship was updated.
        event_2nd = events[1]
        event_body = event_2nd.find_element_by_class_name('media-body')

        self.assertIn('Regina accepted John\'s friendship', event_body.text)
        self.assertIn(date(friendship.updated, getattr(settings, 'SHORT_DATE_FORMAT')), event_body.text)
Пример #2
0
    def get_rows(self):
        total = 0
        qs = self.get_queryset()
        for outcome_data in qs:
            total += 1
            local_dt = timezone.localtime(outcome_data[1])
            yield [
                outcome_data[0], date(local_dt, "d/m/o H:i"),
                outcome_data[2], outcome_data[3]
            ]

        yield []
        yield ['Total: %d' % total]
Пример #3
0
    def get_rows(self):
        total = 0
        qs = self.get_queryset()
        for outcome_data in qs:
            total += 1
            local_dt = timezone.localtime(outcome_data[1])
            yield [
                outcome_data[0],
                date(local_dt, "d/m/o H:i"), outcome_data[2], outcome_data[3]
            ]

        yield []
        yield ['Total: %d' % total]
Пример #4
0
def now(format_string):
	tzinfo = timezone.get_current_timezone() if settings.USE_TZ else None
	return date(datetime.now(tz=tzinfo), format_string)
Пример #5
0
 def payment_topic(self):
     start_date = date(self.pizza_event.start, "Y-m-d")
     return f"Pizzas {self.pizza_event.event.title_en} [{start_date}]"
Пример #6
0
def now(format_string):
    tzinfo = timezone.get_current_timezone() if settings.USE_TZ else None
    return date(datetime.now(tz=tzinfo), format_string)