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
 from sqlalchemy.types import Unicode, Integer, DateTime, Text
11
 from sqlalchemy.types import Unicode, Integer, DateTime, Text
12
 from sqlalchemy.orm import relation, synonym
12
 from sqlalchemy.orm import relation, synonym
13
 
13
 
14
+import tg
14
 from pboard.model import DeclarativeBase, metadata, DBSession
15
 from pboard.model import DeclarativeBase, metadata, DBSession
15
 
16
 
16
 # This is the association table for the many-to-many relationship between
17
 # This is the association table for the many-to-many relationship between
199
   def addTagReplacement(cls, matchobj):
200
   def addTagReplacement(cls, matchobj):
200
     return " <span class='badge'>%s</span> " %(matchobj.group(0).replace('@', '').replace('_', ' '))
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
   def getContentWithTags(self):
207
   def getContentWithTags(self):
203
     lsTemporaryResult = re.sub('(^|\s)@@(\w+)', '', self.data_content) # tags with @@ are explicitly removed from the body
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
     return re.sub('(^|\s)@(\w+)', PBNode.addTagReplacement, lsTemporaryResult) # then, 'normal tags are transformed as labels'
210
     return re.sub('(^|\s)@(\w+)', PBNode.addTagReplacement, lsTemporaryResult) # then, 'normal tags are transformed as labels'
205
     # FIXME - D.A. - 2013-09-12
211
     # FIXME - D.A. - 2013-09-12
206
     # Does not match @@ at end of content.
212
     # Does not match @@ at end of content.