Browse Source

add replacement of #id_of_task by a link to that task in template processing

damien 11 years ago
parent
commit
82acba6eda
1 changed files with 6 additions and 0 deletions
  1. 6 0
      pboard/pboard/model/data.py

+ 6 - 0
pboard/pboard/model/data.py View File

@@ -11,6 +11,7 @@ from sqlalchemy import Table, ForeignKey, Column, Sequence
11 11
 from sqlalchemy.types import Unicode, Integer, DateTime, Text
12 12
 from sqlalchemy.orm import relation, synonym
13 13
 
14
+import tg
14 15
 from pboard.model import DeclarativeBase, metadata, DBSession
15 16
 
16 17
 # This is the association table for the many-to-many relationship between
@@ -199,8 +200,13 @@ class PBNode(object):
199 200
   def addTagReplacement(cls, matchobj):
200 201
     return " <span class='badge'>%s</span> " %(matchobj.group(0).replace('@', '').replace('_', ' '))
201 202
 
203
+  @classmethod
204
+  def addDocLinkReplacement(cls, matchobj):
205
+    return " <a href='%s'>%s</a> " %(tg.url('/dashboard?node=%s')%(matchobj.group(1)), matchobj.group(0))
206
+
202 207
   def getContentWithTags(self):
203 208
     lsTemporaryResult = re.sub('(^|\s)@@(\w+)', '', self.data_content) # tags with @@ are explicitly removed from the body
209
+    lsTemporaryResult = re.sub('#([0-9]*)', PBNode.addDocLinkReplacement, lsTemporaryResult) # tags with @@ are explicitly removed from the body
204 210
     return re.sub('(^|\s)@(\w+)', PBNode.addTagReplacement, lsTemporaryResult) # then, 'normal tags are transformed as labels'
205 211
     # FIXME - D.A. - 2013-09-12
206 212
     # Does not match @@ at end of content.