def to_dict_json(self):
     return {
         'id': self.id,
         'creationDate': str(self.creationDate),
         'when': as_time_string(self.creationDate),
         'action': self.action,
         'entity': self.entity,
         # 'creationDate': self.id,
         'user_image': self.user.gravatar_url_medium(),
         'username': self.user.username,
         'user_link': self.user.get_view_link(),
         'user_id': self.user.id,
         'project_id': self.project.id if self.project else None,
         'project': self.project.to_dict_json() if self.project else None,
         'issue_id': self.issue.id if self.issue else None,
         'issue': self.issue.to_dict_json() if self.issue else None,
         'offer_id': self.offer.id if self.offer else None,
         'offer': self.offer.to_dict_json() if self.offer else None,
         'payment_id': self.payment.id if self.payment else None,
         'payment': self.payment.to_dict_json() if self.payment else None,
         'solution_id': self.solution.id if self.solution else None,
         'issue_comment_id': self.issue_comment.id if self.issue_comment else None,
         'issue_comment_content': self.issue_comment.content if self.issue_comment else None,
         'old_json': self.old_json,
         'new_json': self.new_json,
     }
Exemplo n.º 2
0
 def to_dict_json(self):
     return {
         'id':
         self.id,
         'creationDate':
         str(self.creationDate),
         'when':
         as_time_string(self.creationDate),
         'action':
         self.action,
         'entity':
         self.entity,
         # 'creationDate': self.id,
         'user_image':
         self.user.gravatar_url_medium(),
         'username':
         self.user.username,
         'user_link':
         self.user.get_view_link(),
         'user_id':
         self.user.id,
         'project_id':
         self.project.id if self.project else None,
         'project':
         self.project.to_dict_json() if self.project else None,
         'issue_id':
         self.issue.id if self.issue else None,
         'issue':
         self.issue.to_dict_json() if self.issue else None,
         'offer_id':
         self.offer.id if self.offer else None,
         'offer':
         self.offer.to_dict_json() if self.offer else None,
         'payment_id':
         self.payment.id if self.payment else None,
         'payment':
         self.payment.to_dict_json() if self.payment else None,
         'solution_id':
         self.solution.id if self.solution else None,
         'issue_comment_id':
         self.issue_comment.id if self.issue_comment else None,
         'issue_comment_content':
         self.issue_comment.content if self.issue_comment else None,
         'old_json':
         self.old_json,
         'new_json':
         self.new_json,
     }
 def test_as_time_string(self):
     date_input_1 = timezone.now() - timedelta(seconds=4)
     date_input_2 = timezone.now() - timedelta(seconds=50)
     date_input_3 = timezone.now() - timedelta(seconds=3500)
     date_input_4 = timezone.now() - timedelta(hours=20)
     date_input_5 = timezone.now() - timedelta(days=20)
     date_input_6 = timezone.make_aware(datetime(2012, 12, 12), timezone.get_default_timezone())
     self.assertEqual(as_time_string(date_input_1), 'just now')
     self.assertEqual(as_time_string(date_input_2), '50 seconds ago')
     self.assertEqual(as_time_string(date_input_3), '58 minutes ago')
     self.assertEqual(as_time_string(date_input_4), '20 hours ago')
     self.assertEqual(as_time_string(date_input_5), '20 days ago')
     self.assertEqual(as_time_string(date_input_6), 'on 2012/12/12')
 def test_as_time_string(self):
     date_input_1 = timezone.now() - timedelta(seconds=4)
     date_input_2 = timezone.now() - timedelta(seconds=50)
     date_input_3 = timezone.now() - timedelta(seconds=3500)
     date_input_4 = timezone.now() - timedelta(hours=20)
     date_input_5 = timezone.now() - timedelta(days=20)
     date_input_6 = timezone.make_aware(datetime(2012, 12, 12),
                                        timezone.get_default_timezone())
     self.assertEqual(as_time_string(date_input_1), 'just now')
     self.assertEqual(as_time_string(date_input_2), '50 seconds ago')
     self.assertEqual(as_time_string(date_input_3), '58 minutes ago')
     self.assertEqual(as_time_string(date_input_4), '20 hours ago')
     self.assertEqual(as_time_string(date_input_5), '20 days ago')
     self.assertEqual(as_time_string(date_input_6), 'on 2012/12/12')