Exemplo n.º 1
0
 def prep_mod(pif, mod, cat):
     mod = pif.dbh.modify_man_item(mod)
     mod['img'] = pif.render.format_link(
         '?mod_id=%s&cat=%s' % (mod['id'], cat),
         txt='%d Variation%s' %
         (mod['count(*)'], 's' if mod['count(*)'] != 1 else ''))
     return models.add_model_thumb_pic_link(pif, mod)
Exemplo n.º 2
0
def plant_models(pif):
    plant_id = pif.form.get_str('id')
    if plant_id == 'unset':
        plant_id = ''
    plant_d = dict([(y, x) for x, y in mbdata.plants])
    pif.render.title = plant_name = plant_d.get(plant_id, 'origin not set')
    pif.render.print_html()
    pif.render.set_button_comment(pif)
    pif.render.hierarchy_append('/', 'Home')
    pif.render.hierarchy_append('/database.php', 'Database')
    pif.render.hierarchy_append('/cgi-bin/plants.cgi', 'By Manufacturing Plant')
    pif.render.hierarchy_append('/cgi-bin/plants.cgi?id=%s' % plant_id, plant_name)

    entries = []
    mmods = pif.dbh.fetch_castings_by_plant(plant_name if plant_id else '')
    for mmod in mmods:
        mod = pif.dbh.make_man_item(mmod)
        mod['count'] = mmod['count']
        mod['img'] = pif.render.format_link(
            '/cgi-bin/vars.cgi?manufacture=%s&mod=%s' % (plant_d.get(plant_id, 'unset'), mod['id']),
            txt='%d Variation%s' % (mod.get('count', -1), 's' if mod.get('count', -1) != 1 else ''))
        entries.append({'text': models.add_model_thumb_pic_link(pif, mod)})

    llineup = {
        'section': [{'range': [{'entry': entries}]}],
        'columns': 3,
    }
    pif.render.format_matrix_for_template(llineup)
    return pif.render.format_template('simplematrix.html', llineup=llineup)
Exemplo n.º 3
0
def plant_models(pif):
    plant_id = pif.form.get_str('id')
    if plant_id == 'unset':
	plant_id = ''
    plant_d = dict([(y, x) for x, y in mbdata.plants])
    pif.render.title = plant_name = plant_d.get(plant_id, 'origin not set')
    pif.render.print_html()
    pif.render.set_button_comment(pif)
    pif.render.hierarchy_append('/', 'Home')
    pif.render.hierarchy_append('/database.php', 'Database')
    pif.render.hierarchy_append('/cgi-bin/plants.cgi', 'By Manufacturing Plant')
    pif.render.hierarchy_append('/cgi-bin/plants.cgi?id=%s' % plant_id, plant_name)

    entries = []
    mmods = pif.dbh.fetch_castings_by_plant(plant_name if plant_id else '')
    for mmod in mmods:
	mod = pif.dbh.make_man_item(mmod)
	mod['count'] = mmod['count']
	mod['img'] = pif.render.format_link('/cgi-bin/vars.cgi?manufacture=%s&mod=%s' % (plant_d.get(plant_id, 'unset'), mod['id']), txt='%d Variation%s' % (mod.get('count', -1), 's' if mod.get('count', -1) != 1 else ''))
	entries.append({'text': models.add_model_thumb_pic_link(pif, mod)})

    llineup = {
	'section': [{'range': [{'entry': entries}]}],
	'columns': 3,
    }
    pif.render.format_matrix_for_template(llineup)
    return pif.render.format_template('simplematrix.html', llineup=llineup)
Exemplo n.º 4
0
def custom_create_section(pif, attribute_type):
    adds = {x[0][0]: x[1] for x in mbdata.model_adds}
    credits = {
        x['photo_credit.name'][2:]: x['photographer.name']
        for x in pif.dbh.fetch_photo_credits(path=config.IMG_DIR_ADD[1:])
        if x['photo_credit.name'].startswith(attribute_type)
    }

    def prep_mod(attr_pic):
        mod_id = attr_pic['attribute_picture.mod_id']
        img_id = mod_id.lower() + (
            '-' + attr_pic['attribute_picture.picture_id']
            if attr_pic['attribute_picture.picture_id'] else '')
        add = adds.get(attr_pic['attribute_picture.attr_type'], 'Picture%s')
        img = pif.render.find_image_path(
            img_id,
            prefix=attr_pic['attribute_picture.attr_type'],
            pdir=config.IMG_DIR_ADD)
        caption = attr_pic['attribute_picture.description']
        img_credit = credits.get(img_id, '')
        ostr = ''
        if img:
            ostr += '<center><h3>%s</h3>\n' % add % {'s': ''}
            ostr += '<table><tr><td>' + pif.render.fmt_img_src(img) + '<br>'
            if img_credit:
                ostr += '<div class="credit">Photo credit: %s</div>' % img_credit
            ostr += '</td></tr></table>'
            if attr_pic['attribute_picture.description']:
                ostr += attr_pic['attribute_picture.description']
            ostr += '<p></center>\n'
        return (
            ''' <a onclick="init_modal('m.%s');" class="modalbutton">%s</a>\n'''
            % (img_id, attr_pic['attribute_picture.description']),
            pif.render.format_modal('m.' + img_id, ostr))

    mods = pif.dbh.fetch_attribute_pictures_by_type(
        attribute_type, 'attribute_picture.mod_id')
    modd = {}
    modals = []
    for mod in mods:
        mod_id = mod['attribute_picture.mod_id']
        if mod_id not in modd:
            modd[mod_id] = pif.dbh.modify_man_item(mod)
            modd[mod_id]['img'] = []
        img, modal = prep_mod(mod)
        modd[mod_id]['img'].append(img)
        modals.append(modal)
    lsec = pif.dbh.fetch_sections({'page_id': pif.page_id})[0]
    lsec['range'] = [{
        'entry': [{
            'text': models.add_model_thumb_pic_link(pif, mod[1])
        } for mod in sorted(modd.items())]
    }]
    lsec['footer'] = '\n'.join(modals)
    return lsec
Exemplo n.º 5
0
def create_section(pif, attribute_type):
    def prep_mod(mod):
	mod = pif.dbh.modify_man_item(mod)
	mod['img'] = '/'.join(pif.render.find_image_file(mod['attribute_picture.mod_id'] + '-' + mod['attribute_picture.picture_id'], prefix=attribute_type, pdir=config.IMG_DIR_ADD))
	mod['img'] = pif.render.format_link('/' + mod['img'], txt=mod['attribute_picture.description'])
	return mod
    mods = pif.dbh.fetch_attribute_pictures_by_type(attribute_type, 'attribute_picture.mod_id')
    lsec = pif.dbh.fetch_sections({'page_id': pif.page_id})[0]
    lsec['range'] = [{'entry':
	[{'text': models.add_model_thumb_pic_link(pif, prep_mod(mod))} for mod in mods]}]
    return lsec
Exemplo n.º 6
0
def create_section(pif, attribute_type):
    def prep_mod(mod):
        mod = pif.dbh.modify_man_item(mod)
        mod['img'] = '/'.join(pif.render.find_image_file(
            mod['attribute_picture.mod_id'] + '-' + mod['attribute_picture.picture_id'],
            prefix=attribute_type, pdir=config.IMG_DIR_ADD))
        mod['img'] = pif.render.format_link('/' + mod['img'], txt=mod['attribute_picture.description'])
        return mod
    mods = pif.dbh.fetch_attribute_pictures_by_type(attribute_type, 'attribute_picture.mod_id')
    lsec = pif.dbh.fetch_sections({'page_id': pif.page_id})[0]
    lsec['range'] = [{'entry': [{'text': models.add_model_thumb_pic_link(pif, prep_mod(mod))} for mod in mods]}]
    return lsec
Exemplo n.º 7
0
def custom_create_section(pif, attribute_type):
    adds = {x[0][0]: x[1] for x in mbdata.model_adds}
    credits = {x['photo_credit.name'][2:]: x['photographer.name'] for x in pif.dbh.fetch_photo_credits(path=config.IMG_DIR_ADD[1:])
		    if x['photo_credit.name'].startswith(attribute_type)}

    def prep_mod(attr_pic):
	mod_id = attr_pic['attribute_picture.mod_id']
	img_id = mod_id.lower() + ('-' + attr_pic['attribute_picture.picture_id'] if attr_pic['attribute_picture.picture_id'] else '')
	add = adds.get(attr_pic['attribute_picture.attr_type'], 'Picture%s')
	img = pif.render.find_image_path(img_id, prefix=attr_pic['attribute_picture.attr_type'], pdir=config.IMG_DIR_ADD)
	caption = attr_pic['attribute_picture.description']
	img_credit = credits.get(img_id, '')
	ostr = ''
	if img:
	    ostr += '<center><h3>%s</h3>\n' % add % {'s': ''}
	    ostr += '<table><tr><td>' + pif.render.fmt_img_src(img) + '<br>'
	    if img_credit:
		ostr += '<div class="credit">Photo credit: %s</div>' % img_credit
	    ostr += '</td></tr></table>'
	    if attr_pic['attribute_picture.description']:
		ostr += attr_pic['attribute_picture.description']
	    ostr += '<p></center>\n'
	return (''' <a onclick="init_modal('m.%s');" class="modalbutton">%s</a>\n''' % (img_id, attr_pic['attribute_picture.description']),
		pif.render.format_modal('m.' + img_id, ostr))

    mods = pif.dbh.fetch_attribute_pictures_by_type(attribute_type, 'attribute_picture.mod_id')
    modd = {}
    modals = []
    for mod in mods:
	mod_id = mod['attribute_picture.mod_id']
	if mod_id not in modd:
	    modd[mod_id] = pif.dbh.modify_man_item(mod)
	    modd[mod_id]['img'] = []
	img, modal = prep_mod(mod)
	modd[mod_id]['img'].append(img)
	modals.append(modal)
    lsec = pif.dbh.fetch_sections({'page_id': pif.page_id})[0]
    lsec['range'] = [{'entry':
	[{'text': models.add_model_thumb_pic_link(pif, mod[1])} for mod in sorted(modd.items())]}]
    lsec['footer'] = '\n'.join(modals)
    return lsec
Exemplo n.º 8
0
    def prep_mod(pif, mod, cat):
	mod = pif.dbh.modify_man_item(mod)
	mod['img'] = pif.render.format_link('?mod_id=%s&cat=%s' % (mod['id'], cat), txt='%d Variation%s' % (mod['count(*)'], 's' if mod['count(*)'] != 1 else ''))
	return models.add_model_thumb_pic_link(pif, mod)