Changeset 1372

Show
Ignore:
Timestamp:
01/04/11 15:59:45 (17 months ago)
Author:
zeank
Message:

show list of facilitators and participants

refs #247

Location:
HelpIM3/branches/chatgroups/HelpIM/chatgroup
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • HelpIM3/branches/chatgroups/HelpIM/chatgroup/db/databaseMetadata.py

    r1367 r1372  
    9090        Column('created_at', 
    9191               DateTime, 
    92                default=func.now() 
    93                ), 
     92               default=func.now()), 
    9493 
    9594        UniqueConstraint('group_id', 'email'), 
     
    147146               ForeignKey('conv_Participants.conv_participant_id'), 
    148147               primary_key=True), 
    149         Column( 
    150             'meeting_id', 
    151             Integer, 
    152             ForeignKey('chatgroup_meeting.id') 
    153             ), 
    154         Column( 
    155             'member_id', 
    156             Integer, 
    157             ForeignKey('chatgroup_member.id') 
    158             ) 
     148        Column('meeting_id', 
     149               Integer, 
     150               ForeignKey('chatgroup_meeting.id')), 
     151        Column('member_id', 
     152               Integer, 
     153               ForeignKey('chatgroup_member.id')), 
     154        Column('is_admin', 
     155               Boolean, 
     156               nullable=False, 
     157               default=False), 
     158        Column('joined_at', 
     159               DateTime, 
     160               default=func.now()), 
     161        Column('left_at', 
     162               DateTime, 
     163               nullable=True), 
    159164        ) 
    160165 
  • HelpIM3/branches/chatgroups/HelpIM/chatgroup/db/services.py

    r1367 r1372  
    166166                raise 
    167167 
    168     """ iterates through meetings for members groups. if there's a 
    169     meeting today checks whether now is within window """ 
     168    """ ChatgroupMeetingParticipant """ 
     169 
     170    def getChatgroupMeetingParticipantsByMeetingId(self, site, meeting_id, is_admin=None): 
     171        session = site.database.getSession() 
     172        query = session.query(ChatgroupMeetingParticipant).filter_by(meeting_id=meeting_id) 
     173        if (is_admin is not None): 
     174            query = query.filter_by(is_admin=is_admin) 
     175        try: 
     176            meeting = query.all() 
     177            return meeting 
     178        except NoResultFound: 
     179            if raiseError: 
     180                raise 
     181         
     182 
    170183    def getChatgroupMeetingByMember(self, site, member): 
     184        """ iterates through meetings for members groups. if there's a 
     185        meeting today checks whether now is within window """ 
    171186        from HelpIM.utils import today 
    172187        from datetime import timedelta, datetime 
     
    192207                    participant.conv_participant_conv_id = meeting.id 
    193208                    participant.conv_participant_name = member.nickname 
     209                    participant.is_admin = member.is_admin 
    194210                    meeting.participants.append(participant) 
    195211                    session.flush() 
  • HelpIM3/branches/chatgroups/HelpIM/chatgroup/pages/ChatLog.py

    r1371 r1372  
    8080            } 
    8181 
    82          
    83         chatLogTable = self.getChatLogTableDef() 
    84         panelDef = [ chat_conv_detail_panel, 
    85                      chatLogTable ] 
    86         return panelDef 
     82        return [ chat_conv_detail_panel, 
     83                 self.getParticipantsDef('Facilitators', 'ChatgroupFacilitators'), 
     84                 self.getParticipantsDef('Participants', 'ChatgroupParticipants'), 
     85                 self.getChatLogTableDef() ] 
     86 
     87    def getParticipantsDef(self, panelName, dataTable): 
     88        return { 
     89            'table_panel': [ 
     90                {'panelName': panelName, 
     91                 'dataTable': dataTable, 
     92                 'dataRecord': 'ChatgroupMeetingParticipant'}, 
     93                [{'table_column': [ 
     94                    {'heading': 'Naam', 
     95                     'valueAttr': 'conv_participant_name'} 
     96                    ]}, 
     97                 {'table_column': [ 
     98                     {'heading': 'joined', 
     99                      'valueAttr': 'joined_at'} 
     100                     ]}, 
     101                 {'table_column': [ 
     102                     {'heading': 'left', 
     103                      'valueAttr': 'left_at'} 
     104                     ]}, 
     105                 {'table_column': [ 
     106                     {'heading': 'lines', 
     107                      'valueAttr': 'conv_participant_nbr_lines'} 
     108                     ]}, 
     109                 {'table_column': [ 
     110                     {'heading': 'words', 
     111                      'valueAttr': 'conv_participant_nbr_words'} 
     112                     ]} 
     113                    ] 
     114                ] 
     115            } 
    87116 
    88117    def getChatLogTableDef(self): 
     
    125154        chatData = self.site.pythonObjectAsTuple( 
    126155            chat, 
    127             self.chatConv_DataElements, 
    128             escape=['conv_Question_answerText']) 
     156            self.chatConv_DataElements) 
    129157 
    130158        chatData['ChatgroupMeeting'][0]['chat_lines_total'] = len(chat.conv_messages) 
     
    136164        self.dbg(chatData) 
    137165 
    138         panel_data = {  'panel_data': [  [chatData]  ] } 
    139         fieldErrors = { 'fieldErrors': [ self.errors ] } 
    140         panelMessage = { 'panelMessage': self.panelMessage} 
     166        participantDataElements = ['conv_participant_name', 'joined_at', 'left_at', 'conv_participant_nbr_lines', 'conv_participant_nbr_words'] 
     167 
     168        facilitators = self.site.listOfPythonObjectsAsTuple( 
     169            'ChatgroupFacilitators', 
     170            self.site.getChatgroupMeetingParticipantsByMeetingId( 
     171                self.site, 
     172                self.getParam('conv_id'), 
     173                True), 
     174             participantDataElements 
     175            ) 
     176             
     177        self.dbg(facilitators) 
     178         
     179        participants = self.site.listOfPythonObjectsAsTuple( 
     180            'ChatgroupParticipants', 
     181            self.site.getChatgroupMeetingParticipantsByMeetingId( 
     182                self.site, 
     183                self.getParam('conv_id'), 
     184                False), 
     185             participantDataElements 
     186            ) 
     187             
     188        self.dbg(participants) 
     189 
     190        panel_data   = {'panel_data'  : [[chatData, facilitators, participants]]} 
     191        fieldErrors  = {'fieldErrors' : [self.errors]} 
     192        panelMessage = {'panelMessage': self.panelMessage} 
    141193         
    142194        return [panel_data, fieldErrors, panelMessage]