2017-10-25 13 views

답변

1

편집 시스템에서 편집기 시스템이 올바르게 처리됩니까? 여기에 직접 언급 사용자 @[username]에 제공 django-markdown-editor입니다 = 다른 사용자들에 의해 언급 한 사용자, 유래와 같은 뭔가를 알림 시스템을 구현해야하는 경우

@username 기능 markdown_find_mentions, 유용에 대한 참조>.

def markdown_find_mentions(markdown_text): 
    """ 
    To find the users that mentioned 
    on markdown content using `BeautifulShoup`. 

    input : `markdown_text` or markdown content. 
    return : `list` of usernames. 
    """ 
    mark = markdownify(markdown_text) 
    soup = BeautifulSoup(mark, 'html.parser') 
    return list(set(
     username.text[1::] for username in 
     soup.findAll('a', {'class': 'direct-mention-link'}) 
    )) 

그리고 이것은 간단한 흐름 프로세스입니다.

  1. 댓글/게시물/등을 만들 때 언급 된 모든 사용자를 찾아 알림을 만듭니다.
  2. commemnt/post/etc를 편집 할 때 언급 된 새로운 사용자를 모두 찾아 알림을 만듭니다.

발신자에게 발신자와 수신자가 있음을 의미합니다.

class Notification(TimeStampedModel): 
    sender = models.ForeignKey(User, related_name='sender_n') 
    receiver = models.ForeignKey(User, related_name='receiver_n') 
    content_type = models.ForeignKey(ContentType, related_name='n', on_delete=models.CASCADE) 
    object_id = models.PositiveIntegerField() 
    content_object = GenericForeignKey('content_type', 'object_id') 
    read = models.BooleanField(default=False) 

    ....