Example #1
0
 def to_json(self):
     return dict(
         title=self.title,
         slug=self.slug,
         content=self.content,
         date_added=format_date(self.date_added),
         id=self.id,
         tags=[x.name for x in self.tags.all()],
         comments=[x.to_json() for x in self.comments.all()],
         author_id=self.author_id,
         author=self.author.username if self.author is not None else '')
Example #2
0
 def to_json(self):
     return dict(
         subject=self.subject,
         post_id=self.post_id,
         content=self.content,
         author=self.author and self.author.username or '',
         author_email=self.author and ((hasattr(self.author,'email') and self.author.email) or hasattr(self.author,'emails') and self.author.emails[0]).address or '',
         id=self.id,
         children=[x.to_json() for x in self.replys],
         parent=self.parent_comment_id,
         date=format_date(self.date_added)
     )
Example #3
0
 def to_json(self):
     return dict(
         title=self.title,
         slug=self.slug,
         content=self.content,
         date_added=format_date(self.date_added),
         id=self.id,
         tags=[x.name for x in self.tags.all()],
         comments=[x.to_json() for x in self.comments.all()],
         author_id=self.author_id,
         author=self.author.username
     )
Example #4
0
 def to_json(self):
     return dict(
         subject=self.subject,
         post_id=self.post_id,
         content=self.content,
         author=self.author and self.author.username or '',
         author_email=self.author and
         ((hasattr(self.author, 'email') and self.author.email) or
          hasattr(self.author, 'emails') and self.author.emails[0]).address
         or '',
         id=self.id,
         children=[x.to_json() for x in self.replys],
         parent=self.parent_comment_id,
         date=format_date(self.date_added))