def show_section(pif, manf, sect, start=None, end=None, year=None): print '<hr><center><h3 id="%s">%s</h3></center>' % (sect['label'], sect['title']) if sect['comment']: print '\n'.join(sect['comment']) + '<br>' shown = 0 cols = 4 this_year = None for i in range(len(sect['models']) - 1, -1, -1): sect['models'][i]['last_year'] = this_year this_year = None if sect['models'][i]['subid'].isdigit() and int(sect['models'][i]['subid']) == 1 \ else sect['models'][i]['first_year'] for slist in sect['models']: if slist['subid'] == 'X': continue if start and end: modno = 0 for c in slist['id']: if c.isdigit(): modno = 10 * modno + int(c) pif.render.comment(start, end, modno) if modno < start or modno > end: continue if year and slist['last_year'] and (year < int(slist['first_year']) or year > int(slist['last_year'])): continue slist['link'] = "/cgi-bin/upload.cgi?d=./pic/tomica&r" slist['linkid'] = 's_' + slist['id'].lower() slist['descs'] = slist.get('desc', '').split(';') if shown == 0: print "<center><table><tr align=top>" shown += 1 print " <td valign=top width=%d>" % 200 print models.add_model_table_pic_link(pif, slist) print " </td>" if (shown == cols): print "</tr></table></center>\n" shown = 0 if shown: print "</tr></table></center>\n"
def create_lineup(pif, mods): flago = mflags.FlagList() llineup = {'columns': 4} lsec = pif.dbh.fetch_sections({'page_id': pif.page_id})[0] lran = {'entry': []} for mod in mods: mod = pif.dbh.modify_man_item(mod) lran['entry'].append( {'text': models.add_model_table_pic_link(pif, mod, flago=flago)}) lsec['range'] = [lran] lsec['columns'] = 4 llineup['section'] = [lsec] return llineup
def show_make_selection(pif, make_id, makedict): casting_make = make_id lsec = dict() # pif.dbh.fetch_sections({'page_id': pif.page_id})[0] make = makedict.get(make_id, {}) lsec['anchor'] = make_id lsec['range'] = [] lsec['note'] = '' lsec['id'] = '' lsec['columns'] = 4 lsec['name'] = pif.render.fmt_img( make_id, prefix='t', pdir=config.IMG_DIR_MAKE) + '<br>' + make.get( 'company_name', make_id) lran = {'id': '', 'name': '', 'anchor': '', 'note': '', 'entry': []} where = '' if pif.is_allowed('a') else "section.page_id='manno'" if make_id == 'unk': casting_make = '' castings = pif.dbh.fetch_casting_list_by_make(casting_make, where=where) aliases = [ ] # pif.dbh.fetch_aliases(where="casting.make='%s'" % casting_make) mlist = [] for mdict in castings: mlist.append(pif.dbh.modify_man_item(mdict)) for mdict in aliases: mdict = pif.dbh.modify_man_item(mdict) if mdict.get('alias.ref_id'): mdict['picture_id'] = mdict['id'] mdict['id'] = mdict['alias.id'] # mdict['descs'] = mdict['descs'] # mdict['descs'].append('same as ' + mdict['ref_id']) mlist.append(mdict) mlist.sort(key=lambda x: x['name']) for mdict in mlist: # input mdict: id, (picture_id), made, country, link, linkid, name, descs, made, unlicensed, scale, (type) lran['entry'].append({ 'text': models.add_model_table_pic_link(pif, mdict, flago=models.flago) }) lsec['range'].append(lran) return lsec
def show_make_selection(pif, make_id, makedict): casting_make = make_id lsec = dict() #pif.dbh.fetch_sections({'page_id': pif.page_id})[0] make = makedict.get(make_id, {}) lsec['anchor'] = make_id lsec['range'] = [] lsec['note'] = '' lsec['id'] = '' lsec['columns'] = 4 lsec['name'] = pif.render.fmt_img(make_id, prefix='t', pdir=config.IMG_DIR_MAKE) + '<br>' + make.get('company_name', make_id) lran = {'id': '', 'name': '', 'anchor': '', 'note': '', 'entry': []} where = '' if pif.is_allowed('a') else "section.page_id='manno'" if make_id == 'unk': casting_make = '' castings = pif.dbh.fetch_casting_list_by_make(casting_make, where=where) aliases = [] #pif.dbh.fetch_aliases(where="casting.make='%s'" % casting_make) mlist = [] for mdict in castings: mlist.append(pif.dbh.modify_man_item(mdict)) for mdict in aliases: mdict = pif.dbh.modify_man_item(mdict) if mdict.get('alias.ref_id'): mdict['picture_id'] = mdict['id'] mdict['id'] = mdict['alias.id'] #mdict['descs'] = mdict['descs'] #mdict['descs'].append('same as ' + mdict['ref_id']) mlist.append(mdict) mlist.sort(key=lambda x: x['name']) for mdict in mlist: # input mdict: id, (picture_id), made, country, link, linkid, name, descs, made, unlicensed, scale, (type) lran['entry'].append({'text': models.add_model_table_pic_link(pif, mdict, flago=models.flago)}) lsec['range'].append(lran) return lsec