|
27 | 27 |
|
28 | 28 | """
|
29 | 29 |
|
| 30 | +DATA_ATTRS_HELP_TEXT = ( |
| 31 | + _( |
| 32 | + """**DEPRECATED: Use 'data_attr' instead**. |
| 33 | +Only include objects that have attributes with certain values. |
| 34 | +Data filtering expressions are comma-separated and are structured as follows: |
| 35 | +
|
| 36 | +%(value_part_help_text)s |
| 37 | +
|
| 38 | +Example: in order to display only objects with `height` equal to 100, query `data_attrs=height__exact__100` |
| 39 | +should be used. If `height` is nested inside `dimensions` attribute, query should look like |
| 40 | +`data_attrs=dimensions__height__exact__100` |
| 41 | +
|
| 42 | +`value` may not contain comma, since commas are used as separator between filtering expressions. |
| 43 | +If you want to use commas in `value` you can use `data_attr` query parameter. |
| 44 | +""" |
| 45 | + ) |
| 46 | + % {"value_part_help_text": DATA_ATTR_VALUE_HELP_TEXT} |
| 47 | +) |
| 48 | + |
| 49 | +DATA_ATTR_HELP_TEXT = ( |
| 50 | + _( |
| 51 | + """Only include objects that have attributes with certain values. |
| 52 | +
|
| 53 | +%(value_part_help_text)s |
| 54 | +
|
| 55 | +Example: in order to display only objects with `height` equal to 100, query `data_attr=height__exact__100` |
| 56 | +should be used. If `height` is nested inside `dimensions` attribute, query should look like |
| 57 | +`data_attr=dimensions__height__exact__100` |
| 58 | +
|
| 59 | +This filter is very similar to the old `data_attrs` filter, but it has two differences: |
| 60 | +
|
| 61 | +* `value` may contain commas |
| 62 | +* only one filtering expression is allowed |
| 63 | +
|
| 64 | +If you want to use several filtering expressions, just use this `data_attr` several times in the query string. |
| 65 | +Example: `data_attr=height__exact__100&data_attr=naam__icontains__boom` |
| 66 | +""" |
| 67 | + ) |
| 68 | + % {"value_part_help_text": DATA_ATTR_VALUE_HELP_TEXT} |
| 69 | +) |
| 70 | + |
30 | 71 |
|
31 | 72 | def filter_data_attr_value_part(value_part: str, queryset: QuerySet) -> QuerySet:
|
32 | 73 | """
|
@@ -98,49 +139,17 @@ class ObjectRecordFilterSet(FilterSet):
|
98 | 139 | "date would be between `registrationAt` attributes of different records"
|
99 | 140 | ),
|
100 | 141 | )
|
| 142 | + |
101 | 143 | data_attrs = filters.CharFilter(
|
102 | 144 | method="filter_data_attrs",
|
103 | 145 | validators=[validate_data_attrs],
|
104 |
| - help_text=_( |
105 |
| - """**DEPRECATED: Use 'data_attr' instead**. |
106 |
| -Only include objects that have attributes with certain values. |
107 |
| -Data filtering expressions are comma-separated and are structured as follows: |
108 |
| -
|
109 |
| -%(value_part_help_text)s |
110 |
| -
|
111 |
| -Example: in order to display only objects with `height` equal to 100, query `data_attrs=height__exact__100` |
112 |
| -should be used. If `height` is nested inside `dimensions` attribute, query should look like |
113 |
| -`data_attrs=dimensions__height__exact__100` |
114 |
| -
|
115 |
| -`value` may not contain comma, since commas are used as separator between filtering expressions. |
116 |
| -If you want to use commas in `value` you can use `data_attr` query parameter. |
117 |
| -""" |
118 |
| - ) |
119 |
| - % {"value_part_help_text": DATA_ATTR_VALUE_HELP_TEXT}, |
| 146 | + help_text=DATA_ATTRS_HELP_TEXT, |
120 | 147 | )
|
121 | 148 |
|
122 | 149 | data_attr = ManyCharFilter(
|
123 | 150 | method="filter_data_attr",
|
124 | 151 | validators=[validate_data_attr],
|
125 |
| - help_text=_( |
126 |
| - """Only include objects that have attributes with certain values. |
127 |
| -
|
128 |
| -%(value_part_help_text)s |
129 |
| -
|
130 |
| -Example: in order to display only objects with `height` equal to 100, query `data_attr=height__exact__100` |
131 |
| -should be used. If `height` is nested inside `dimensions` attribute, query should look like |
132 |
| -`data_attr=dimensions__height__exact__100` |
133 |
| -
|
134 |
| -This filter is very similar to the old `data_attrs` filter, but it has two differences: |
135 |
| -
|
136 |
| -* `value` may contain commas |
137 |
| -* only one filtering expression is allowed |
138 |
| -
|
139 |
| -If you want to use several filtering expressions, just use this `data_attr` several times in the query string. |
140 |
| -Example: `data_attr=height__exact__100&data_attr=naam__icontains__boom` |
141 |
| -""" |
142 |
| - ) |
143 |
| - % {"value_part_help_text": DATA_ATTR_VALUE_HELP_TEXT}, |
| 152 | + help_text=DATA_ATTR_HELP_TEXT, |
144 | 153 | )
|
145 | 154 |
|
146 | 155 | data_icontains = filters.CharFilter(
|
|
0 commit comments