def common_contexts(request): """Adds arbitrary data common to one or more view""" common_context = { "top_islands": Island.get_top_islands(), "sorts": [Hot.name, New.name], } if request.user.is_authenticated: common_context.update({ "my_islands": Island.get_my_islands(request.user), "list_types": Post.list_types(), }) return common_context