##// END OF EJS Templates
Fixed connecting replies to posts
neko259 -
r935:114b6f2e decentral
parent child Browse files
Show More
@@ -170,9 +170,8 b' class PostManager(models.Manager):'
170 Connects replies to a post to show them as a reflink map
170 Connects replies to a post to show them as a reflink map
171 """
171 """
172
172
173 for reply_number in re.finditer(REGEX_REPLY, post.get_raw_text()):
173 for reply_number in post.get_replied_ids():
174 post_id = reply_number.group(1)
174 ref_post = self.filter(id=reply_number)
175 ref_post = self.filter(id=post_id)
176 if ref_post.count() > 0:
175 if ref_post.count() > 0:
177 referenced_post = ref_post[0]
176 referenced_post = ref_post[0]
178 referenced_post.referenced_posts.add(post)
177 referenced_post.referenced_posts.add(post)
@@ -234,7 +233,7 b' class PostManager(models.Manager):'
234
233
235 text = et.SubElement(content_tag, TAG_TEXT)
234 text = et.SubElement(content_tag, TAG_TEXT)
236 # TODO Replace local links by global ones in the text
235 # TODO Replace local links by global ones in the text
237 text.text = post.text.raw
236 text.text = post.get_raw_text()
238
237
239 if not post.is_opening():
238 if not post.is_opening():
240 thread = et.SubElement(content_tag, TAG_THREAD)
239 thread = et.SubElement(content_tag, TAG_THREAD)
@@ -523,17 +522,16 b' class Post(models.Model, Viewable):'
523 def get_pub_time_epoch(self):
522 def get_pub_time_epoch(self):
524 return utils.datetime_to_epoch(self.pub_time)
523 return utils.datetime_to_epoch(self.pub_time)
525
524
526 # TODO Use this to connect replies
527 def get_replied_ids(self):
525 def get_replied_ids(self):
528 """
526 """
529 Gets ID list of the posts that this post replies.
527 Gets ID list of the posts that this post replies.
530 """
528 """
531
529
532 local_replied = REGEX_REPLY.findall(self.text.raw)
530 raw_text = self.get_raw_text()
531
532 local_replied = REGEX_REPLY.findall(raw_text)
533 global_replied = []
533 global_replied = []
534 # TODO Similar code is used in mdx_neboard, maybe it can be extracted
534 for match in REGEX_GLOBAL_REPLY.findall(raw_text):
535 # into a method?
536 for match in REGEX_GLOBAL_REPLY.findall(self.text.raw):
537 key_type = match[0]
535 key_type = match[0]
538 key = match[1]
536 key = match[1]
539 local_id = match[2]
537 local_id = match[2]
@@ -42,7 +42,7 b' class SyncTest(TestCase):'
42 post.id,
42 post.id,
43 post.global_id.key_type,
43 post.global_id.key_type,
44 post.title,
44 post.title,
45 post.text.raw,
45 post.get_raw_text(),
46 post.get_pub_time_epoch(),
46 post.get_pub_time_epoch(),
47 ) in respond_get(request).content.decode(),
47 ) in respond_get(request).content.decode(),
48 'Wrong response generated for the GET request.') No newline at end of file
48 'Wrong response generated for the GET request.')
General Comments 0
You need to be logged in to leave comments. Login now