def test_icon_url_contains_mtime(self): with self.mocked_path_func: from adhocracy.lib import helpers as h from adhocracy.tests.testtools import tt_get_instance test_instance = tt_get_instance() url = h.logo_url(test_instance, 48) self.assertEqual( url, 'http://test.test.lan/instance/test_48.png?t=1234')
def test_icon_url_with_y(self): with self.mocked_path_func: from adhocracy.lib import helpers as h from adhocracy.tests.testtools import tt_get_instance test_instance = tt_get_instance() url = h.logo_url(test_instance, 48) self.assertEqual( url, 'http://test.test.lan/instance/test_48.png?t=1234')
def render_logo(entity, y, x=None, fallback=None): (x, y) = logo.validate_xy(x, y) try: (path, mtime, io) = logo.load(entity, size=(x, y), fallback=fallback) except logo.NoSuchSizeError: abort(404, _(u"The image is not avaliable in that size")) # always add ?t=... to URI for browser cache request_mtime = int(request.params.get('t', 0)) if request_mtime != mtime: redirect(logo_url(entity, y, x=x)) return render_png(io, mtime, cache_forever=True)