Browse Source

add tag list tab + manage visible @tags and @@invisible_tags

damien 11 years ago
parent
commit
1ac78de19c
2 changed files with 21 additions and 8 deletions
  1. 14 4
      pboard/pboard/model/data.py
  2. 7 4
      pboard/pboard/templates/dashboard.mak

+ 14 - 4
pboard/pboard/model/data.py View File

@@ -2,6 +2,7 @@
2 2
 """
3 3
 """
4 4
 import os
5
+import re
5 6
 from datetime import datetime
6 7
 from hashlib import sha256
7 8
 __all__ = ['User', 'Group', 'Permission']
@@ -195,14 +196,23 @@ class PBNode(object):
195 196
       lsTruncatedLabel = self.data_label
196 197
     return lsTruncatedLabel
197 198
 
199
+  def getTagList(self):
200
+    loPattern = re.compile('(^|\s|@)@(\w+)')
201
+    loResults = re.findall(loPattern, self.data_content)
202
+    lsResultList = []
203
+    for loResult in loResults:
204
+      lsResultList.append(loResult[1].replace('@', '').replace('_', ' '))
205
+    return lsResultList
206
+
198 207
   @classmethod
199 208
   def addTagReplacement(cls, matchobj):
200
-    if matchobj.group(0) == '-': return ' '
201
-    else: return "<span class='badge'>%s</span>" %(matchobj.group(0))
209
+    return " <span class='badge'>%s</span> " %(matchobj.group(0).replace('@', '').replace('_', ' '))
202 210
 
203 211
   def getContentWithTags(self):
204
-    import re
205
-    return re.sub('@(\w+)', PBNode.addTagReplacement, self.data_content)
212
+    lsTemporaryResult = re.sub('(^|\s)@@(\w+)', '', self.data_content) # tags with @@ are explicitly removed from the body
213
+    return re.sub('(^|\s)@(\w+)', PBNode.addTagReplacement, lsTemporaryResult) # then, 'normal tags are transformed as labels'
214
+    # FIXME - D.A. - 2013-09-12
215
+    # Does not match @@ at end of content.
206 216
 
207 217
 
208 218
 

+ 7 - 4
pboard/pboard/templates/dashboard.mak View File

@@ -136,11 +136,8 @@ POD :: ${current_node.getTruncatedLabel(40)} [${current_node.getStatus().label}]
136 136
             ${POD.SaveButton('current-document-title-save-cancel-button')}
137 137
           </div>
138 138
         </form>
139
-
140
-
141
-</div>
139
+      </div>
142 140
       <div class="span5">
143
-      
144 141
       <p>
145 142
         <div id='current-document-content' class="">
146 143
           ${current_node.getContentWithTags()|n}
@@ -158,6 +155,7 @@ POD :: ${current_node.getTruncatedLabel(40)} [${current_node.getStatus().label}]
158 155
     <div class="span4">
159 156
       <div class="tabbable">
160 157
         <ul class="nav nav-tabs">
158
+            <li class=""><a href="#tags" data-toggle="tab" title="${_('Tags')}"><i class='icon-g-tags'></i></a></li>
161 159
             <li class="active">
162 160
               <a href="#events" data-toggle="tab" title="History"><i class="icon-g-history"></i></a>
163 161
             </li>
@@ -167,6 +165,11 @@ POD :: ${current_node.getTruncatedLabel(40)} [${current_node.getStatus().label}]
167 165
             <li><a href="#contacts" data-toggle="tab" title="Users"><i class="icon-g-user""></i> </a></li>
168 166
         </ul>
169 167
         <div class="tab-content">
168
+            <div class="tab-pane" id="tags">
169
+              % for tag in current_node.getTagList():
170
+                ${POD.Badge(tag)}
171
+              % endfor
172
+            </div>
170 173
             <div class="tab-pane active" id="events">
171 174
 
172 175
 ${POD.AddButton('current-document-add-event-button', True, _(' Add event'))}