-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #43: Format ports as ranges in edit forms
- Loading branch information
1 parent
d9e4366
commit 55b692b
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from utilities.data import array_to_string | ||
from utilities.forms.fields import NumericArrayField as NumericArrayField_ | ||
|
||
|
||
__all__ = ("NumericArrayField",) | ||
|
||
|
||
class NumericArrayField(NumericArrayField_): | ||
"""Format ranges in a human-friendly way before displaying the field.""" | ||
|
||
def prepare_value(self, value): | ||
if not value: | ||
return "" | ||
|
||
if isinstance(value, str): | ||
return value | ||
|
||
return array_to_string(value) |