def send(self): sender_phone_number = self.user.full_number recepient_contact = self.recepient recepient_user = recepient_contact.contact_user recepient_phone_number = recepient_contact.phone_number if recepient_user: # recepient is registered in TeextMe sender_contact = Contact.objects.filter(contact_user=self.user) sender_contact = sender_contact[0] if sender_contact else None other_message = Message( user=self.recepient.contact_user, sender=sender_contact, message=self.message, date_sent=self.date_sent, other_message=self ) other_message.save() self.other_message = other_message else: send_sms(sender_phone_number, recepient_phone_number, self.message)
def create_activation(self, user): # generate random code code = str(random.randint(10000, 99999)) activation = self.create(user=user, code=code) phone = user.full_number try: send_sms(settings.SITE_NAME, phone, settings.ACTIVATION_MESSAGE % code) except Exception, e: logger.error( 'Activation code %s could not be sent to %s: ', code, phone, exc_info=True) raise e