def order_plan_queryset(plans, field, asc=False):
    """
    Annotate the TestPlan queryset
    by calling order_by on it.
    """
    orderable_fields = ('id', 'name', 'author__username', 'create_date',
        'product__name', 'type')
    if field in orderable_fields:
        order_by = field
        if not asc:
            order_by = '-%s' % order_by
        plans = plans.order_by(order_by)
    return plans
