Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix additional emoji MobilePay ingest bugs #280

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion stregsystem/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,14 @@ def test_exact_guess(self):
self.assertEqual(Member.objects.get(username__exact="marx"), mobile_payment_exact_match_member("marx"))

def test_emoji_strip(self):
self.assertEqual(strip_emoji("Tilmeld Lichi 😎"), "Tilmeld Lichi ")
self.assertEqual(strip_emoji("Tilmeld Lichi 😎"), "Tilmeld Lichi")

def test_emoji_strip_electric_boogaloo(self):
# Laurits bør få næse for at fremprovokoere dette case
self.assertEqual(strip_emoji("♂️Laurits♂️"), "Laurits")

def test_emoji_retain_nordic(self):
self.assertEqual(strip_emoji("æøåäëö"), "æøåäëö")

def test_emoji_retain(self):
self.assertEqual(strip_emoji("Tilmeld Lichi"), "Tilmeld Lichi")
Expand Down
22 changes: 18 additions & 4 deletions stregsystem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,30 @@ def mobile_payment_exact_match_member(comment):

def strip_emoji(text):
# yoinked from https://stackoverflow.com/questions/33404752/removing-emojis-from-a-string-in-python
regrex_pattern = re.compile(
pattern="["
emoj = re.compile(
"["
u"\U0001F600-\U0001F64F" # emoticons
u"\U0001F300-\U0001F5FF" # symbols & pictographs
u"\U0001F680-\U0001F6FF" # transport & map symbols
u"\U0001F1E0-\U0001F1FF" # flags (iOS)
u"\U00002500-\U00002BEF" # chinese char
u"\U00002702-\U000027B0"
u"\U00002702-\U000027B0"
u"\U000024C2-\U0001F251"
u"\U0001f926-\U0001f937"
u"\U00010000-\U0010ffff"
u"\u2640-\u2642"
u"\u2600-\u2B55"
u"\u200d"
u"\u23cf"
u"\u23e9"
u"\u231a"
u"\ufe0f" # dingbats
u"\u3030"
"]+",
flags=re.UNICODE,
re.UNICODE,
)
return regrex_pattern.sub(r'', text)
return re.sub(emoj, '', text).strip()


def qr_code(data):
Expand Down