Return the field name and direction for an order specification. For example, '-foo' is returned as ('foo', 'DESC'). The 'default' param is used to indicate which way no prefix (or a '+' prefix) should sort. The '-' prefix always sorts the opposite way.
(field, default="ASC")
| 2792 | |
| 2793 | |
| 2794 | def get_order_dir(field, default="ASC"): |
| 2795 | """ |
| 2796 | Return the field name and direction for an order specification. For |
| 2797 | example, '-foo' is returned as ('foo', 'DESC'). |
| 2798 | |
| 2799 | The 'default' param is used to indicate which way no prefix (or a '+' |
| 2800 | prefix) should sort. The '-' prefix always sorts the opposite way. |
| 2801 | """ |
| 2802 | dirn = ORDER_DIR[default] |
| 2803 | if field[0] == "-": |
| 2804 | return field[1:], dirn[1] |
| 2805 | return field, dirn[0] |
| 2806 | |
| 2807 | |
| 2808 | class JoinPromoter: |
no outgoing calls
no test coverage detected