def html_list_grouped(self, include='thing_item_set.inc', header='thing_group_heading.inc', selected=(), prefix=DELETE_PREFIX):
        """ Alan - 08/01/08 - Used for lists that require grouping on assets by stage. 
        (e.g. avatars, props and backdrops edit selection lists) """

        table = []
        inc = get_template(include)
        things = self.get_formatted_list(inc, selected, prefix)
        end_stage_group = "</table>"
        thing_column_headers = ['', '', 'Name:', 'Stages:', 'Uploader:', 'DateTime:']
        avatar_column_headers = ['', '', 'Name:', 'Voice:', 'Stages:', 'Uploader:', 'DateTime:']
        audio_column_headers = ['', '', 'Name:', 'Type:', 'Stages:', 'Uploader', 'DateTime']
            
        # Check to see if the current media type contains any uploaded assets.
        if things:
            #sort alphabetically (note: things is schwartzian). Only sort if things contains items.
            things.sort()
            collections = self._get_stage_collections()
            group_heading = get_template(header)
            
            # Adds the appropiate column headings for the group
            column_headers = thing_column_headers
            #Shaun Narayan (01/27/10 - Added try except block) - If no stages exist, this throws an exception
            try:
                if collections[0][0].typename == 'avatar': column_headers = avatar_column_headers
                elif collections[0][0].typename == 'audio': column_headers = audio_column_headers 
            except:
                table.extend('<th>No Stages Found</th>')
            
            for c, s in collections:
                if c.things.values(): 
                    table.extend(group_heading % {'stage_name': s.ID })
                    
                    for h in column_headers: table.extend('<th>%s</th>' %h)
                    
                    for n, d in things:                        
                        for i in c.things.values():
                            if d['name'] == i.name and d['media'] in c.media: table.extend(inc % d)
                                    
                    table.extend(end_stage_group)
            
            """ Unassigned media asset group """
            unassigned_assets = [ n for n in things if not len(n[1]['stages']) ]
            
            if unassigned_assets: 
                table.extend(group_heading % { 'stage_name': 'unassigned' })
                for h in column_headers: table.extend('<th>%s</th>' %h)
                for x in unassigned_assets: table.extend(inc % x[1])
                table.extend(end_stage_group)
                
        return ''.join(table)
Example #2
0
    def html_list_grouped(self, include='thing_item_set.inc', header='thing_group_heading.inc', selected=(), prefix=DELETE_PREFIX):
        """ Alan - 08/01/08 - Used for lists that require grouping on assets by stage. 
        (e.g. avatars, props and backdrops edit selection lists) """

        table = []
        inc = get_template(include)
        things = self.get_formatted_list(inc, selected, prefix)
        end_stage_group = "</table>"
        thing_column_headers = ['', '', 'Name:', 'Stages:', 'Uploader:', 'DateTime:']
        avatar_column_headers = ['', '', 'Name:', 'Voice:', 'Stages:', 'Uploader:', 'DateTime:']
        audio_column_headers = ['', '', 'Name:', 'Type:', 'Stages:', 'Uploader', 'DateTime']
            
        # Check to see if the current media type contains any uploaded assets.
        if things:
            #sort alphabetically (note: things is schwartzian). Only sort if things contains items.
            things.sort()
            collections = self._get_stage_collections()
            group_heading = get_template(header)
            
            # Adds the appropiate column headings for the group
            column_headers = thing_column_headers
            #Shaun Narayan (01/27/10 - Added try except block) - If no stages exist, this throws an exception
            try:
                if collections[0][0].typename == 'avatar': column_headers = avatar_column_headers
                elif collections[0][0].typename == 'audio': column_headers = audio_column_headers 
            except:
                table.extend('<th>No Stages Found</th>')
            
            for c, s in collections:
                if c.things.values(): 
                    table.extend(group_heading % {'stage_name': s.ID })
                    
                    for h in column_headers: table.extend('<th>%s</th>' %h)
                    
                    for n, d in things:                        
                        for i in c.things.values():
                            if d['name'] == i.name and d['key'] in c.media: table.extend(inc % d)
                                    
                    table.extend(end_stage_group)
            
            """ Unassigned media asset group """
            unassigned_assets = [ n for n in things if not len(n[1]['stages']) ]
            
            if unassigned_assets: 
                table.extend(group_heading % { 'stage_name': 'unassigned' })
                for h in column_headers: table.extend('<th>%s</th>' %h)
                for x in unassigned_assets: table.extend(inc % x[1])
                table.extend(end_stage_group)
                
        return ''.join(table)
Example #3
0
 def html_list(self, playerName='', include='stage_item_set.inc'):
     """make a list of stages as a set of table rows"""
     things = [(ID.lower(), {'name': stage.name,
                             'ID': ID
                             })
               for ID, stage in self.items()]
     things.sort() # alphabetical (note: things is schwartzian)
     tmpl = get_template(include)
     
     if '%(pcount)s' in tmpl and '%(acount)s' and '%(access)s' in tmpl:
         for n, d in things:
             d['pcount'] = len(self[d['ID']].player_sockets) or ''
             d['acount'] = (len(self[d['ID']].sockets) - len(self[d['ID']].player_sockets)) or ''
             d['access'] = self[d['ID']].get_player_access(playerName)
         
     table = [ tmpl % x[1] for x in things ]
     return ''.join(table)