예제 #1
0
파일: widgets.py 프로젝트: damjanek/ralph
 def render(self, name, value, attrs=None, choices=()):
     dev = None
     if value:
         try:
             dev = Device.objects.get(sn=(value or '').lower())
         except Device.DoesNotExist:
             pass
     if dev is None:
         output = [
             '<input type="hidden" name="%s" value="">' % (escape(name),),
             '<div class="input uneditable-input">',
             '<i class="fugue-icon %s"></i>&nbsp;%s</a>' % (
                 presentation.get_device_icon(None), 'None'),
             '</div>',
         ]
     else:
         output = [
             '<input type="hidden" name="%s" value="%s">' % (escape(name),
                                                             escape(value)),
             '<div class="input uneditable-input">',
             '<a href="/ui/racks/%s/info/">'
             '<i class="fugue-icon %s"></i>&nbsp;%s</a>' % (slugify(dev.sn),
                 presentation.get_device_icon(dev), escape(dev.name)),
             '</div>',
         ]
     return mark_safe('\n'.join(output))
예제 #2
0
파일: widgets.py 프로젝트: iwwwwwwi/ralph
 def render(self, name, value, attrs=None, choices=()):
     dev = None
     if value:
         try:
             dev = Device.objects.get(id=value)
         except Device.DoesNotExist:
             pass
     if dev is None:
         output = [
             '<input type="hidden" name="%s" value="">' % (escape(name), ),
             '<div class="input uneditable-input">',
             '<i class="fugue-icon %s"></i>&nbsp;%s</a>' %
             (presentation.get_device_icon(None), 'None'),
             '</div>',
         ]
     else:
         output = [
             '<input type="hidden" name="%s" value="%s">' %
             (escape(name), escape(value)),
             '<div class="input uneditable-input">',
             '<a href="%s">'
             '<i class="fugue-icon %s"></i>&nbsp;%s</a>' %
             (dev.id, presentation.get_device_icon(dev), escape(dev.name)),
             '</div>',
         ]
     return mark_safe('\n'.join(output))
예제 #3
0
파일: forms.py 프로젝트: tosuch/ralph
 def render(self, name, value, attrs=None, choices=()):
     dev = None
     if value:
         try:
             dev = Device.objects.get(id=value)
         except Device.DoesNotExist:
             pass
     if dev is None:
         output = [
             '<input type="hidden" name="%s" value="">' % (name,),
             '<div class="input uneditable-input">',
             '<i class="fugue-icon %s"></i>&nbsp;%s</a>' % (
                 presentation.get_device_icon(None), 'None'),
             '</div>',
         ]
     else:
         output = [
             '<input type="hidden" name="%s" value="%s">' % (name, value),
             '<div class="input uneditable-input">',
             '<a href="%s">'
             '<i class="fugue-icon %s"></i>&nbsp;%s</a>' % (dev.id,
                 presentation.get_device_icon(dev), dev.name),
             '</div>',
         ]
     return mark_safe('\n'.join(output))
예제 #4
0
파일: views.py 프로젝트: iwwwwwwi/ralph
def get_icon_for(ci):
    if not ci or not ci.content_object:
        return
    if ci.content_type.name == 'venture':
        return get_venture_icon(ci.content_object)
    elif ci.content_type.name == 'device':
        return get_device_icon(ci.content_object)
    elif ci.content_type.name == 'network':
        return get_network_icon(ci.content_object)
예제 #5
0
파일: views.py 프로젝트: tosuch/ralph
def get_icon_for(ci):
    if not ci or not ci.content_object:
        return
    if ci.content_type.name == "venture":
        return get_venture_icon(ci.content_object)
    elif ci.content_type.name == "device":
        return get_device_icon(ci.content_object)
    elif ci.content_type.name == "network":
        return get_network_icon(ci.content_object)
예제 #6
0
파일: views.py 프로젝트: iwwwwwwi/ralph
def get_icon_for(ci):
    if not ci or not ci.content_object:
        return
    if ci.content_type.name == 'venture':
        return get_venture_icon(ci.content_object)
    elif ci.content_type.name == 'device':
        return get_device_icon(ci.content_object)
    elif ci.content_type.name == 'network':
        return get_network_icon(ci.content_object)
예제 #7
0
def _prices_per_venture_device_details(device, exclude=[]):
    components, stock = [], []
    total = 0
    for detail in _get_details(
            device,
            ignore_deprecation=True,
            exclude=exclude,
    ):
        model = detail.get('model')
        price = detail.get('price') or 0
        if not model:
            components.append({
                'model': 'n/a',
                'icon': 'n/a',
                'count': 'n/a',
                'price': 'n/a',
                'serial': 'n/a',
            })
        if model not in stock:
            components.append({
                'model':
                model.name if hasattr(model, 'name') else model,
                'icon':
                detail.get('icon'),
                'count':
                1,
                'price':
                price,
                'serial':
                detail.get('serial'),
            })
        else:
            for component in components:
                if component['model'] == model:
                    component['count'] = component['count'] + 1
        total += price
        stock.append(model)
    venture = 'N/a'
    if device.venture and device.venture.symbol:
        venture = device.venture.symbol
    return {
        'device': {
            'id': device.id,
            'name': device.name,
            'sn': device.sn,
            'barcode': device.barcode,
            'deprecation_date': device.deprecation_date,
            'cached_price': device.cached_price,
            'icon': get_device_icon(device),
            'venture': venture,
            'role': device.role or 'N/a',
        },
        'components': components,
        'total': total,
        'deprecated': device.is_deprecated(),
    }
예제 #8
0
def _prices_per_venture_device_details(device, exclude=[]):
    components, stock = [], []
    total = 0
    for detail in _get_details(
        device,
        ignore_deprecation=True,
        exclude=exclude,
    ):
        model = detail.get('model')
        price = detail.get('price') or 0
        if not model:
            components.append({
                'model': 'n/a',
                'icon': 'n/a',
                'count': 'n/a',
                'price': 'n/a',
                'serial': 'n/a',
            })
        if model not in stock:
            components.append({
                'model': model.name if hasattr(model, 'name') else model,
                'icon': detail.get('icon'),
                'count': 1,
                'price': price,
                'serial': detail.get('serial'),
            })
        else:
            for component in components:
                if component['model'] == model:
                    component['count'] = component['count'] + 1
        total += price
        stock.append(model)
    venture = 'N/a'
    if device.venture and device.venture.symbol:
        venture = device.venture.symbol
    return {
        'device': {
            'id': device.id,
            'name': device.name,
            'sn': device.sn,
            'barcode': device.barcode,
            'deprecation_date': device.deprecation_date,
            'cached_price': device.cached_price,
            'icon': get_device_icon(device),
            'venture': venture,
            'role': device.role or 'N/a',
        },
        'components': components,
        'total': total,
        'deprecated': device.is_deprecated(),
    }
예제 #9
0
 def format_item_display(self, obj):
     return '<i class="fugue-icon %s"></i>&nbsp;%s <div><small>%s</small></div>' % (
         presentation.get_device_icon(obj),
         escape(obj.name),
         escape(obj.venture) + '/' + escape(obj.venture_role),
     )
예제 #10
0
def device_icon(device):
    return icon_filter(presentation.get_device_icon(device))
예제 #11
0
def device_icon(device):
    return icon_filter(presentation.get_device_icon(device))
예제 #12
0
파일: channels.py 프로젝트: ReJeCtAll/ralph
 def format_item_display(self, obj):
     return '<i class="fugue-icon %s"></i>&nbsp;%s <div><small>%s</small></div>' % (
         presentation.get_device_icon(obj),
         escape(obj.name),
         escape(obj.venture) + '/' + escape(obj.venture_role),
     )