Пример #1
0
 def save(self, **kwargs):
     """Override entire method. Due to the layout of the original method we
     cannot do a super() call."""
     domain_override = kwargs.get('domain_override', None)
     email_template_name = kwargs.get('email_template_name', 'registration/password_reset_email.html')
     use_https = kwargs.get('use_https', False)
     token_generator = kwargs.get('token_generator', default_token_generator)
     from_email = kwargs.get('from_email', None)
     request = kwargs.get('request', None)
     subject_template_name = kwargs.get('subject_template_name', 'registration/password_reset_subject.txt')
     from django.core.mail import send_mail
     for user in self.users_cache:
         if not domain_override:
             current_site = get_current_site(request)
             site_name = current_site.name
             domain = current_site.domain
         else:
             site_name = domain = domain_override
         t = loader.get_template(email_template_name)
         c = {
             'email': user.email,
             'domain': domain,
             'site_name': site_name,
             'uid': int_to_base36(user.id),
             'user': user,
             'token': token_generator.make_token(user),
             'protocol': use_https and 'https' or 'http',
         }
         content = t.render(Context(c))
         if self.fields.has_key('email'):
             send_mail(
                 _("Password reset on %s") % site_name, 
                 content, from_email, [user.email]
             )
         else:
             sms = AmbientSMS(
                 settings.FOUNDRY['sms_gateway_api_key'], 
                 settings.FOUNDRY['sms_gateway_password']
             )
             try:
                 sms.sendmsg(content, [self.cleaned_data['mobile_number']])
             except AmbientSMSError:
                 pass
Пример #2
0
    def save(self, *args, **kwargs):

        invite = super(OffsiteInviteForm, self).save(*args, **kwargs)

        sms = AmbientSMS(settings.FOUNDRY['sms_gateway_api_key'],
                         settings.FOUNDRY['sms_gateway_password'])

        url = 'http://%s/token/%s/' % (Site.objects.get_current(),
                                       invite.url_token.token)

        content = u'%s, %s invites you to join %s.  ' \
                   'Click here to become a member: %s' % (invite.to_friend_name,
                                                          invite.from_member,
                                                          Site.objects.get_current(),
                                                          url)
        try:
            sms.sendmsg(content, [self.cleaned_data['to_mobile_number']])
        except AmbientSMSError:
            pass

        return invite
Пример #3
0
 def save(self, *args, **kwargs):
     
     invite = super(OffsiteInviteForm, self).save(*args, **kwargs)
     
     sms = AmbientSMS(
         settings.FOUNDRY['sms_gateway_api_key'], 
         settings.FOUNDRY['sms_gateway_password']
     )
     
     url = 'http://%s/token/%s/' % (Site.objects.get_current(), invite.url_token.token)
     
     content = u'%s, %s invites you to join %s.  ' \
                'Click here to become a member: %s' % (invite.to_friend_name,
                                                       invite.from_member,
                                                       Site.objects.get_current(),
                                                       url)
     try:
         sms.sendmsg(content, [self.cleaned_data['to_mobile_number']])
     except AmbientSMSError:
         pass
     
     return invite