diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2012-10-02 06:27:56 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2012-10-02 06:27:56 (GMT) |
commit | 96940bbd7bff34eca9087421ea504d12958a3f7b (patch) | |
tree | 91ebba59fb1ce8fdb135a4dd6c2cf2b4ef8c7bc1 | |
parent | e1a3dc1b128f09ff04e2e64b91242338635f70eb (diff) |
Return stub images for missed "preview" in Context
-rw-r--r-- | sugar_network/resources/context.py | 42 | ||||
-rwxr-xr-x | tests/units/remote_mount.py | 2 |
2 files changed, 24 insertions, 20 deletions
diff --git a/sugar_network/resources/context.py b/sugar_network/resources/context.py index 60018a1..3c3827d 100644 --- a/sugar_network/resources/context.py +++ b/sugar_network/resources/context.py @@ -58,32 +58,36 @@ class Context(Resource): @ad.active_property(ad.BlobProperty, mime_type='image/png') def icon(self, value): - if not value: - if 'package' in self['type']: - return ad.PropertyMeta( - url='/static/images/package.png', - path=join(static.PATH, 'images', 'package.png'), - mime_type='image/png') - else: - return ad.PropertyMeta( - url='/static/images/missing.png', - path=join(static.PATH, 'images', 'missing.png'), - mime_type='image/png') - else: + if value: return value + if 'package' in self['type']: + return ad.PropertyMeta( + url='/static/images/package.png', + path=join(static.PATH, 'images', 'package.png'), + mime_type='image/png') + else: + return ad.PropertyMeta( + url='/static/images/missing.png', + path=join(static.PATH, 'images', 'missing.png'), + mime_type='image/png') @ad.active_property(ad.BlobProperty, mime_type='image/svg+xml') def artifact_icon(self, value): - if not value: - return ad.PropertyMeta( - url='/static/images/missing.svg', - path=join(static.PATH, 'images', 'missing.svg'), - mime_type='image/svg+xml') - return value + if value: + return value + return ad.PropertyMeta( + url='/static/images/missing.svg', + path=join(static.PATH, 'images', 'missing.svg'), + mime_type='image/svg+xml') @ad.active_property(ad.BlobProperty, mime_type='image/png') def preview(self, value): - return value + if value: + return value + return ad.PropertyMeta( + url='/static/images/missing.png', + path=join(static.PATH, 'images', 'missing.png'), + mime_type='image/png') @ad.active_property(prefix='K', typecast=bool, default=False) def keep(self, value): diff --git a/tests/units/remote_mount.py b/tests/units/remote_mount.py index 8ccc2c4..2544491 100755 --- a/tests/units/remote_mount.py +++ b/tests/units/remote_mount.py @@ -187,7 +187,7 @@ class RemoteMountTest(tests.Test): job.kill() self.assertEqual([ - {'document': 'context', 'event': 'update', 'guid': guid, 'seqno': 4}, + {'document': 'context', 'event': 'update', 'guid': guid, 'seqno': 5}, ], events) |