def list_viewers(context, obj, next_url=None, separator=", "): viewers = [] for viewer in get_viewers_for_object(obj, user=context["request"].user): viewers.append((viewer, hasattr(viewer, "url_for_obj") and viewer.url_for_obj(obj) or None)) viewers = sorted(viewers, key=lambda v: getattr(v[0], "weight", 0), reverse=True) return {"obj": obj, "viewers": viewers, "next": next_url, "separator": separator}
def list_viewers(context, obj, next_url=None, separator=', '): viewers = get_viewers_for_object(obj, context['request']) viewers = sorted(viewers, key=lambda v: getattr(v, 'weight', 0), reverse=True) return {'obj': obj, 'viewers': viewers, 'next': next_url, 'separator': separator, }
def list_viewers(context, obj, next_url=None, separator=', '): viewers = get_viewers_for_object(obj, context['request']) viewers = sorted(viewers, key=lambda v: getattr(v, 'weight', 0), reverse=True) return { 'obj': obj, 'viewers': viewers, 'next': next_url, 'separator': separator, }