Changeset 1409 for HelpIM3

Show
Ignore:
Timestamp:
02/17/11 14:45:43 (15 months ago)
Author:
zeank
Message:

free editable textblock above subscription page
refs #278

Location:
HelpIM3/branches/chatgroups/HelpIM/chatgroup/pages
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • HelpIM3/branches/chatgroups/HelpIM/chatgroup/pages/Subscription.py

    r1407 r1409  
    11from HelpIM.web.pageBase import EditPanel 
     2from HelpIM.intranet.db.databaseMetadata import HIM_Text 
    23 
    34class Handler(EditPanel): 
     
    89        self.panelName = 'Chatgroup Subscription' 
    910        self.function = 'subscribe' 
     11        path = kwargs['him_request'].environment['PATH_INFO'] 
     12        if path[:1] == '/': 
     13            path = path[1:] 
     14        self.newsType = path 
     15        self.editFunction = 'Edit'+path 
    1016 
    1117    def getPanelDef(self, *args, **kwargs): 
    1218        group_id = self.checkNotEmpty('group_id') 
     19        if self.site.userIsAuthorized( 
     20            user=self.him_request.session.session_user, 
     21            script=self.editFunction): 
     22            editLink = {'action': [{'name':self.editFunction, 'text':'Bewerk deze pagina'}, 
     23                                   [{'actionParm': [{'name': 'newsType', 'value':self.newsType }]}] 
     24                                   ]} 
     25        else: 
     26            editLink = {} 
     27 
     28        intro = {'web_panel': [ 
     29            [editLink, 
     30             {'htmlCode': [{'id':'htmlCode'}]}] 
     31            ]} 
    1332        table = {'table_panel': [ 
    1433            {'panelName': 'Beschikbare Chat Groepen', 
     
    6180                ] 
    6281            ]} 
    63         return [table, form] 
     82        return [intro, table, form] 
    6483 
    6584    def getPanelData(self, *args, **kwargs): 
     85        him_text = self.site.getHIMTextByTextId(self.site, self.newsType) 
     86        htmlCode = '' 
     87        if him_text is None: 
     88            him_text = HIM_Text() 
     89        if him_text.himTxt_text is None: 
     90            him_text.himTxt_text = '' 
     91             
     92        him_text.himTxt_text = him_text.himTxt_text.encode('utf-8') 
     93        self.log.debug('.getPanelData() found HIM_Text.himTxt_textId(%s) himTxt_text(%s)' % (him_text.himTxt_textId, him_text.himTxt_text)) 
     94 
     95        htmlCode = {  'htmlCode': [ him_text.himTxt_text.replace(' ', ' ') ] } 
     96 
    6697        if self.checkNotEmpty('group_id'): 
    6798            groups = [self.site.getChatgroupById(self.site, self.getParam('group_id'))] 
     
    88119 
    89120        self.log.debug(groupsData) 
    90  
    91121         
    92122        fieldErrors =  {'fieldErrors' : [self.errors]} 
    93123        panelMessage = {'panelMessage': self.panelMessage} 
    94124         
    95         panel_data =   {'panel_data'  : [[ groupsData ]]} 
     125        panel_data =   {'panel_data'  : [[ htmlCode, groupsData ]]} 
    96126 
    97127        return [panel_data, fieldErrors, panelMessage]