fix api comments (fixes #512)
This commit is contained in:
parent
50b6e06f62
commit
a8013f1089
1 changed files with 9 additions and 20 deletions
|
@ -302,7 +302,7 @@ class Comment(Base):
|
||||||
@lazy
|
@lazy
|
||||||
def json_core(self):
|
def json_core(self):
|
||||||
if self.is_banned:
|
if self.is_banned:
|
||||||
data= {'is_banned': True,
|
data = {'is_banned': True,
|
||||||
'ban_reason': self.ban_reason,
|
'ban_reason': self.ban_reason,
|
||||||
'id': self.id,
|
'id': self.id,
|
||||||
'post': self.post.id if self.post else 0,
|
'post': self.post.id if self.post else 0,
|
||||||
|
@ -310,38 +310,27 @@ class Comment(Base):
|
||||||
'parent': self.parent_fullname
|
'parent': self.parent_fullname
|
||||||
}
|
}
|
||||||
elif self.deleted_utc:
|
elif self.deleted_utc:
|
||||||
data= {'deleted_utc': self.deleted_utc,
|
data = {'deleted_utc': self.deleted_utc,
|
||||||
'id': self.id,
|
'id': self.id,
|
||||||
'post': self.post.id if self.post else 0,
|
'post': self.post.id if self.post else 0,
|
||||||
'level': self.level,
|
'level': self.level,
|
||||||
'parent': self.parent_fullname
|
'parent': self.parent_fullname
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
|
data = self.json_raw
|
||||||
|
if self.level >= 2: data['parent_comment_id']= self.parent_comment_id
|
||||||
|
|
||||||
data=self.json_raw
|
data['replies'] = [x.json_core for x in self.replies(None)]
|
||||||
|
|
||||||
if self.level>=2: data['parent_comment_id']= self.parent_comment_id
|
|
||||||
|
|
||||||
data['replies']=[x.json_core for x in self.replies(None)]
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def json(self):
|
def json(self):
|
||||||
|
data = self.json_core
|
||||||
data=self.json_core
|
if self.deleted_utc or self.is_banned: return data
|
||||||
|
data["author"] = '👻' if self.ghost else self.author.json_core
|
||||||
if self.deleted_utc or self.is_banned:
|
data["post"] = self.post.json_core if self.post else ''
|
||||||
return data
|
|
||||||
|
|
||||||
data["author"]='👻' if self.ghost else self.author.json_core
|
|
||||||
data["post"]=self.post.json_core if self.post else ''
|
|
||||||
|
|
||||||
if self.level >= 2:
|
|
||||||
data["parent"]=self.parent.json_core
|
|
||||||
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def realbody(self, v):
|
def realbody(self, v):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue