]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/utils/userlinking.py
Fixes OSQA-663, the user.username property should pass through the smart_unicode...
[osqa.git] / forum / utils / userlinking.py
index da476ee9cc9bf58c07d5f1d34ecb74e1b07aee13..6693883e1e6effb7866b9048ce9f80d68c7efa79 100644 (file)
@@ -1,6 +1,6 @@
 import re
 
 import re
 
-from forum.models import User,  Question,  Answer,  Comment
+from forum.models.user import User
 
 def find_best_match_in_name(content,  uname,  fullname,  start_index):      
     end_index = start_index + len(fullname)    
 
 def find_best_match_in_name(content,  uname,  fullname,  start_index):      
     end_index = start_index + len(fullname)    
@@ -20,20 +20,8 @@ def find_best_match_in_name(content,  uname,  fullname,  start_index):
 APPEAL_PATTERN = re.compile(r'(?<!\w)@\w+')
 
 def auto_user_link(node, content):
 APPEAL_PATTERN = re.compile(r'(?<!\w)@\w+')
 
 def auto_user_link(node, content):
-    
-    # We should find the root of the node tree (question) the current node belongs to.
-    if isinstance(node,  Question):
-        question = node
-    elif isinstance(node,  Answer):
-        question = node.question
-    elif isinstance(node,  Comment):
-        if node.question:
-            question = node.question
-        elif node.answer:
-            question = node.answer.question
-    
-    # Now we've got the root question. Let's get the list of active users.
-    active_users = question.get_active_users()
+
+    active_users = node.absolute_parent.get_active_users()
     
     appeals = APPEAL_PATTERN.finditer(content)
 
     
     appeals = APPEAL_PATTERN.finditer(content)