##// END OF EJS Templates
Merged in xdevelnet/neboard-1/xdevelnet/modify-readmemarkdown-according-to-recen-1462861521600 (pull request #19)...
Merged in xdevelnet/neboard-1/xdevelnet/modify-readmemarkdown-according-to-recen-1462861521600 (pull request #19) modify readme.markdown according to recent branch updates

File last commit:

r542:8b7899f5 1.7-dev
r1555:54fb2b93 merge default
Show More
posting_mixin.py
25 lines | 634 B | text/x-python | PythonLexer
import re
import string
from boards.models import Post
from boards.models.post import REGEX_REPLY
REFLINK_PREFIX = '>>'
class PostMixin:
@staticmethod
def _remove_invalid_links(text):
"""
Replace invalid links in posts so that they won't be parsed.
Invalid links are links to non-existent posts
"""
for reply_number in re.finditer(REGEX_REPLY, text):
post_id = reply_number.group(1)
post = Post.objects.filter(id=post_id)
if not post.exists():
text = string.replace(text, REFLINK_PREFIX + post_id, post_id)
return text