Archived
More manic unicode fixes. Logs renewals to din_user_update.
This commit is contained in:
1 parent
ef9acf3321
commit
e042b1b9e9
1 file changed
+16
-5
+16
-5
@@ -142,16 +142,17 @@ def send_sms(gsm=None, message=None, response_to=None, billing=False, billing_pr
|
|||||||
# The strings in this file are in utf-8, encode to latin-1 before sending
|
# The strings in this file are in utf-8, encode to latin-1 before sending
|
||||||
try:
|
try:
|
||||||
assert type(message) == unicode
|
assert type(message) == unicode
|
||||||
message = message.encode('latin-1', 'ignore')
|
message_latin = message.encode('latin-1', 'ignore')
|
||||||
except:
|
except:
|
||||||
|
message_latin = message
|
||||||
app.logger.warning("Unicode woes: %s", sys.exc_info())
|
app.logger.warning("Unicode woes: %s", sys.exc_info())
|
||||||
# Oh, never mind, let's try to send it anyway.
|
# Oh, never mind, let's try to send it anyway.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Truncate message if too long
|
# Truncate message if too long
|
||||||
if len(message) > 160:
|
if len(message_latin) > 160:
|
||||||
app.logger.warning("Truncated the following message to 160 chars: %s", message)
|
app.logger.warning("Truncated the following message to 160 chars: %s", message_latin)
|
||||||
message = message[:160]
|
message_latin = message_latin[:160]
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'bruker': app.config['EB_USER'],
|
'bruker': app.config['EB_USER'],
|
||||||
@@ -159,7 +160,7 @@ def send_sms(gsm=None, message=None, response_to=None, billing=False, billing_pr
|
|||||||
'avsender': app.config['EB_SENDER_BULK'],
|
'avsender': app.config['EB_SENDER_BULK'],
|
||||||
'land': 47,
|
'land': 47,
|
||||||
'til': gsm,
|
'til': gsm,
|
||||||
'melding': message,
|
'melding': message_latin,
|
||||||
}
|
}
|
||||||
|
|
||||||
if billing:
|
if billing:
|
||||||
@@ -270,6 +271,16 @@ def renew_membership(response_to=None, gsm=None, user=None, operator=None):
|
|||||||
'id': user['id']
|
'id': user['id']
|
||||||
})
|
})
|
||||||
|
|
||||||
|
query_db("""
|
||||||
|
INSERT INTO din_userupdate (date, user_id_updated, comment, user_id_updated_by)
|
||||||
|
VALUES (%(date)s, %(user_id_updated)s, %(comment)s, %(user_id_updated_by)s)
|
||||||
|
""", {
|
||||||
|
'date': str(datetime.datetime.now()),
|
||||||
|
'user_id_updated': user['id'],
|
||||||
|
'comment': "Medlemskap fornyet med SMS.",
|
||||||
|
'user_id_updated_by': user['id'],
|
||||||
|
})
|
||||||
|
|
||||||
message = u"Hei %(name)s! Ditt medlemskap er nå gyldig ut %(new_expire)s. Spørsmål? medlem@studentersamfundet.no" % ({
|
message = u"Hei %(name)s! Ditt medlemskap er nå gyldig ut %(new_expire)s. Spørsmål? medlem@studentersamfundet.no" % ({
|
||||||
'name': get_full_name(user),
|
'name': get_full_name(user),
|
||||||
'new_expire': str(new_expire),
|
'new_expire': str(new_expire),
|
||||||
|
|||||||
Reference in new issue
Block a user