def render(self, name, value, attrs=None, choices=()): dm = None if value: try: dm = DeviceModel.objects.get(id=value) except DeviceModel.DoesNotExist: pass if dm is None: output = [ '<input type="hidden" name="%s" value="">' % (escape(name),), '<div class="input uneditable-input">', '<i class="fugue-icon %s"></i> %s</a>' % ( presentation.get_device_model_icon(None), 'None'), '</div>', ] else: output = [ '<input type="hidden" name="%s" value="%s">' % (escape(name), escape(value)), '<div class="input uneditable-input">', '<a href="/admin/discovery/devicemodel/%s">' '<i class="fugue-icon %s"></i> %s</a>' % (dm.id, presentation.get_device_model_icon(dm), escape(dm.name)), '</div>', ] return mark_safe('\n'.join(output))
def render(self, name, value, attrs=None, choices=()): dm = None if value: try: dm = DeviceModel.objects.get(id=value) except DeviceModel.DoesNotExist: pass if dm is None: output = [ '<input type="hidden" name="%s" value="">' % (escape(name), ), '<div class="input uneditable-input">', '<i class="fugue-icon %s"></i> %s</a>' % (presentation.get_device_model_icon(None), 'None'), '</div>', ] else: output = [ '<input type="hidden" name="%s" value="%s">' % (escape(name), escape(value)), '<div class="input uneditable-input">', '<a href="/admin/discovery/devicemodel/%s">' '<i class="fugue-icon %s"></i> %s</a>' % (dm.id, presentation.get_device_model_icon(dm), escape( dm.name)), '</div>', ] return mark_safe('\n'.join(output))
def _get_details(dev, purchase_only=False, with_price=False): for detail in pricing.details_all(dev, purchase_only): if 'icon' not in detail: if detail['group'] == 'dev': detail['icon'] = presentation.get_device_model_icon( detail.get('model')) else: detail['icon'] = presentation.get_component_model_icon( detail.get('model')) if 'price' not in detail: if detail.get('model'): detail['price'] = detail['model'].get_price() else: detail['price'] = None if with_price and not detail['price']: continue if detail['group'] != 'dev' and 'size' not in detail and detail.get( 'model'): detail['size'] = detail['model'].size if detail.get('model'): if detail['model'].group: detail['modelgroup'] = detail['model'].group detail['model'] = detail['model'].group.name else: detail['model'] = detail['model'].name else: detail['model'] = detail.get('model_name', '') yield detail
def _get_details(dev, purchase_only=False, with_price=False): for detail in pricing.details_all(dev, purchase_only): if 'icon' not in detail: if detail['group'] == 'dev': detail['icon'] = presentation.get_device_model_icon(detail.get('model')) else: detail['icon'] = presentation.get_component_model_icon(detail.get('model')) if 'price' not in detail: if detail.get('model'): detail['price'] = detail['model'].get_price() else: detail['price'] = None if with_price and not detail['price']: continue if detail['group'] != 'dev' and 'size' not in detail and detail.get('model'): detail['size'] = detail['model'].size if detail.get('model'): if detail['model'].group: detail['modelgroup'] = detail['model'].group detail['model'] = detail['model'].group.name else: detail['model'] = detail['model'].name else: detail['model'] = detail.get('model_name', '') yield detail
def _get_details(dev, purchase_only=False, with_price=False, ignore_deprecation=False, exclude=[]): for detail in pricing.details_all( dev, purchase_only, ignore_deprecation=ignore_deprecation, exclude=exclude, ): if 'icon' not in detail: if detail['group'] == 'dev': detail['icon'] = presentation.get_device_model_icon( detail.get('model'), ) else: detail['icon'] = presentation.get_component_model_icon( detail.get('model'), ) if 'price' not in detail: if detail.get('model'): detail['price'] = detail['model'].get_price() else: detail['price'] = None if with_price and not detail['price']: continue if ( detail['group'] != 'dev' and 'size' not in detail and detail.get('model') ): detail['size'] = detail['model'].size if not detail.get('model'): detail['model'] = detail.get('model_name', '') yield detail