-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Prepop branch with changes from main (#1119)
- Loading branch information
Showing
10 changed files
with
123 additions
and
58 deletions.
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
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,33 @@ | ||
import re | ||
from decimal import Decimal | ||
|
||
import flask_babel | ||
from babel import numbers | ||
|
||
from app.jinja_filters import format_number, get_formatted_currency | ||
from app.utilities import safe_content | ||
|
||
|
||
def sanitise_number(number: str) -> str: | ||
return ( | ||
number.replace(numbers.get_group_symbol(flask_babel.get_locale()), "") | ||
.replace("_", "") | ||
.replace(" ", "") | ||
) | ||
|
||
|
||
def sanitise_mobile_number(data: str) -> str: | ||
data = re.sub(r"[\s.,\t\-{}\[\]()/]", "", data) | ||
return re.sub(r"^(0{1,2}44|\+44|0)", "", data) | ||
|
||
|
||
def format_playback_value(value: float | Decimal, currency: str | None = None) -> str: | ||
if currency: | ||
return get_formatted_currency(value, currency) | ||
|
||
formatted_number: str = format_number(value) | ||
return formatted_number | ||
|
||
|
||
def format_message_with_title(error_message: str, question_title: str) -> str: | ||
return error_message % {"question_title": safe_content(question_title)} |
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
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
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