Esempio n. 1
0
    def _set_generic_entity(self, entity):
        db = self.app.db
        # edata = db.get(entityid)
        # main = edata['main']
        # extras = edata['extras']
        # tags = edata['tags']

        # set name and main action links
        name = TableHeader(str(entity.name), colspan=2, align="center")
        name_row = TableRow(name)
        self.set(name_row)
        edit_anchor = Anchor("(edit)", href=myurl.make("edit", "entity", str(entity.entityid)))
        delete_anchor = Anchor("(delete)", href=myurl.make("delete", "entity", str(entity.entityid)))
        cell = TableCell(edit_anchor)
        self.append(TableRow(cell))
        cell = TableCell(delete_anchor)
        self.append(TableRow(cell))

        # set type
        cell = TableCell("type:  %s" % str(entity.type), colspan=2)
        self.append(TableRow(cell))

        # extra fields
        if entity.extfields:
            self.append(TableRow(TableCell(Bold("Extra Fields"))))
            for field in entity.extfields:
                label = str("%s:  %s" % (field, str(entity.extfields[field].value)))
                cell = TableCell(label)
                self.append(TableRow(cell))

        # back to main data
        if entity.url:
            urlanchor = Anchor("url", href=str(entity.url))
            self.append(TableRow(TableCell(urlanchor, colspan=2)))
        if entity.desc:
            self.append(TableRow(TableCell(Bold("Description"), colspan=2)))
            desc = Paragraph(str(entity.desc))
            cell = TableCell(desc)
            self.append(TableRow(cell, colspan=2))

        # handle tags
        tagrow = TableRow()
        tagrow.append(TableCell(Bold("Tags"), colspan=2))
        span = Span(style="font-size: xx-small")
        add_anchor = Anchor("(add)", href=myurl.make("addtag", "entity", str(entity.entityid)))
        del_anchor = Anchor("(remove)", href=myurl.make("deltag", "entity", str(entity.entityid)))
        span.set(add_anchor)
        span.append(del_anchor)
        cell = TableCell(span, colspan=2)
        tagrow.append(cell)
        self.append(tagrow)
        for tag in entity.tags:
            row = TableRow()
            cell = TableCell(str(tag.tagname))
            row.set(cell)
            self.append(row)
Esempio n. 2
0
    def set_info(self, guestid):
        guests_db = self.app.guests
        data = guests_db.get_guest_data(guestid)
        name = '%s %s' % (data['firstname'], data['lastname'])
        fullname = TableHeader(name, colspan=0, align='center')
        fullname_row = TableRow(fullname)
        edit_anchor = Anchor('edit',
                             href='guest||edit||%d' % guestid)
        cell = TableCell(edit_anchor)
        fullname_row.append(cell)
        self.set(fullname_row)
        title = data['title']
        if title:
            title = TableCell(title, colspan=2)
            title_row = TableRow(title)
            self.append(title_row)
        desc = data['description']
        if desc:
            desc = self.app.guests.unescape_text(desc)
            span = Span(desc)
            cell = TableCell(span, colspan=2)
            if len(desc) > 150:
                span['style'] = 'font-size: x-small'
            desc_row = TableRow(cell)
            self.append(desc_row)

        #################
        # works section #
        #################
        workheader = TableHeader('Works', colspan=0, align='center')
        new_work_anchor = Anchor('add',
                                 href='work||new||%d' % guestid)
        cell = TableCell(new_work_anchor)
        workheader_row = TableRow(workheader)
        workheader_row.append(cell)
        self.append(workheader_row)
        # add works
        works = guests_db.get_guest_works(guestid)
        if works:
            worktable = GuestWorksTable(width='100%')
            worktable.set_info(works)
            cell = TableCell(worktable, colspan=2)
            trow = TableRow(cell)
            self.append(trow)
        else:
            workheader.set('No Works')

        #######################
        # appearances section #
        #######################
        appearance_header = TableHeader('Appearances',
                                        colspan=0, align='center')
        new_appearance_anchor = Anchor('add',
                                       href='appearance||new||%d' % guestid)

        cell = TableCell(new_appearance_anchor)
        appearance_header_row = TableRow(appearance_header)
        appearance_header_row.append(cell)
        self.append(appearance_header_row)
        appearances = guests_db.get_appearances(guestid)
        if appearances:
            for row in appearances:
                #print row
                url = row['url']
                sdate = parse_appearance_m3u_url(url)
                app_anchor = Anchor(sdate, href=url)
                cell = TableCell(app_anchor)
                h1, h2 = make_mp3_links(url)
                h1_anchor = Anchor('(hr1)', href=h1)
                h2_anchor = Anchor('(hr2)', href=h2)
                span = Span(style='font-size: xx-small')
                span.append(h1_anchor)
                span.append(h2_anchor)
                cell.append(span)
                trow = TableRow(cell)
                cell = TableCell()
                edit_anchor = Anchor('edit',
                                     href='appearance||edit||%s' % url)
                play_anchor = Anchor('(play)',
                                     href='appearance||play||%s' % url)
                cell.append(edit_anchor)
                cell.append(play_anchor)
                trow.append(cell)
                self.append(trow)
        else:
            appearance_header.set('No Appearances')
        
        #######################
        # pictures section    #
        #######################
        pix_header = TableHeader('Pictures',
                                 colspan=0, align='center')
        newpix_anchor = Anchor('add',
                               href='picture||new||%d' % guestid)
        cell = TableCell(newpix_anchor)
        pix_header_row = TableRow(pix_header)
        pix_header_row.append(cell)
        self.append(pix_header_row)
        pictures = guests_db.get_guest_pictures(guestid)
        if pictures:
            datadir = self.app.datadir
            for row in pictures:
                filename = row['all_pictures.filename']
                fullpath = os.path.join(datadir, filename)
                image = Image(src=fullpath, width='100', height='100')
                cell = TableCell(image)
                trow = TableRow(cell)
                span = Span(style='font-size: xx-small')
                span.append(filename)
                cell = TableCell(span)
                trow.append(cell)
                self.append(trow)
        else:
            pix_header.set('No Pictures')