Permalink
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (20 sloc) 949 Bytes
from django.contrib import messages
from django.utils.translation import ugettext
from two_factor.middleware.threadlocals import get_current_request
from two_factor.templatetags.two_factor import mask_phone_number
class Messages(object):
@classmethod
def make_call(cls, device, token):
cls._add_message(ugettext('Fake call to %(number)s: '
'"Your token is: %(token)s"'),
device, token)
@classmethod
def send_sms(cls, device, token):
cls._add_message(ugettext('Fake SMS to %(number)s: '
'"Your token is: %(token)s"'),
device, token)
@classmethod
def _add_message(cls, message, device, token):
message = message % {'number': mask_phone_number(device.number),
'token': token}
messages.add_message(get_current_request(), messages.INFO, message)