Revision e7953d63 snf-cyclades-app/synnefo/plankton/views.py

b/snf-cyclades-app/synnefo/plankton/views.py
62 62

  
63 63
DETAIL_FIELDS = ('name', 'disk_format', 'container_format', 'size', 'checksum',
64 64
                 'location', 'created_at', 'updated_at', 'deleted_at',
65
                 'status', 'is_public', 'owner', 'properties', 'id')
65
                 'status', 'is_public', 'owner', 'properties', 'id', "is_snapshot")
66 66

  
67 67
ADD_FIELDS = ('name', 'id', 'store', 'disk_format', 'container_format', 'size',
68 68
              'checksum', 'is_public', 'owner', 'properties', 'location')
......
76 76

  
77 77
def _create_image_response(image):
78 78
    response = HttpResponse()
79
    def normalize(s):
80
        return ''.join('_' if c in punctuation else c.lower() for c in s)\
81
                .replace("\n", "_")
79 82

  
80 83
    for key in DETAIL_FIELDS:
81 84
        if key == 'properties':
82 85
            for k, v in image.get('properties', {}).items():
83 86
                name = 'x-image-meta-property-' + k.replace('_', '-')
84
                response[name] = v
87
                response[name] = normalize(str(v))
85 88
        else:
86 89
            name = 'x-image-meta-' + key.replace('_', '-')
87
            response[name] = image.get(key, '')
90
            response[name] = normalize(str(image.get(key, '')))
88 91

  
89 92
    return response
90 93

  

Also available in: Unified diff