changeset 233:e2d2f018a8e2

add character count to staff profile editing page.
author casties
date Thu, 14 Nov 2013 18:09:16 +0100
parents 76ea03db3426
children 774ee7595e0c
files MPIWGStaff.py zpt/staff/edit_profile.zpt
diffstat 2 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MPIWGStaff.py	Thu Nov 14 15:17:05 2013 +0100
+++ b/MPIWGStaff.py	Thu Nov 14 18:09:16 2013 +0100
@@ -21,7 +21,7 @@
 from Products.ZDBInterface.ZDBInterfaceFolder import ZDBInterfaceFolder
 from Products.MPIWGManager.MPIWGIcsManager import MPIWGIcsManager
 
-from SrvTxtUtils import getInt, unicodify, utf8ify, sqlName
+from SrvTxtUtils import getInt, unicodify, utf8ify, sqlName, getPlaintext
 import MPIWGHelper
 
 #
@@ -145,6 +145,8 @@
             query += " ORDER BY lower(last_name)"
         elif sortBy == 'date_from':
             query += " ORDER BY date_from DESC"
+        elif sortBy:
+            query += ' ORDER BY "%s"'%sqlName(sortBy)
             
         if limit > 0:
             query += " LIMIT %s"%int(limit)
@@ -413,6 +415,18 @@
     
     getUrl = MPIWGHelper.getUrl
     
+
+    def getProfile(self, filter=None, length=0):
+        """Return the profile"""
+        logging.debug("getProfile: self.content=%s"%(repr(self.content)))
+        text = self.content.profile
+        if filter == 'plaintext':
+            # filter out any tags, keep only text
+            text = getPlaintext(text, length=length, wordwrap=True, ignoretags=['style'])
+        
+        return text
+            
+        
     def getTalks(self, published=True, sortBy='priority'):
         """Return the list of talks"""
         query = "SELECT oid,* FROM talks WHERE key_main = %s"
@@ -984,17 +998,13 @@
         return self.executeZSQL(query,[self.getKey()])
     
     
-    def getProfile(self,REQUEST):
+    def getProfileHtml(self, REQUEST):
         """get the profile"""
-        self.REQUEST.RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT')
-      
-        
+        REQUEST.RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT')
         html="""<html><body>%s</body></html>"""
         if self.content.profile and self.content.profile != "":
-           
             return html%self.content.profile
         else:
-                        
             return html%""
    
             
--- a/zpt/staff/edit_profile.zpt	Thu Nov 14 15:17:05 2013 +0100
+++ b/zpt/staff/edit_profile.zpt	Thu Nov 14 18:09:16 2013 +0100
@@ -28,6 +28,7 @@
         <span class="kupu-tb-buttongroup">
           <button type="button" id="kupu-save-button" title="save: alt-s" accesskey="s">Publish</button>
         </span>
+        <span>(currently published: <span tal:replace="python:len(here.getProfile(filter='plaintext', length=0))"/> characters)</span>
       </div>
       
       <metal:macros use-macro="here/kupuEditor/kupumacros/macros/xmlconfig">
@@ -50,7 +51,7 @@
         
         <metal:macros fill-slot="editorframe">
           <iframe class="kupu-editor-iframe" id="kupu-editor" frameborder="0" scrolling="auto" src="fulldoc"
-              tal:attributes="src python:root+'/getProfile?time='+here.REQUEST.get('time','0')">
+              tal:attributes="src python:root+'/getProfileHtml?time='+request.get('time','0')">
           </iframe>
         </metal:macros>