Exemplo n.º 1
0
 def send_verification_email(self):
     if not self.verified:
         c = {
             'email': self.email,
             'user': self,
         }
         send_mail('verify_email', [self.email], context=c)
Exemplo n.º 2
0
 def send_mail(self):
     if not self.claimed:
         c = {
             'email': self.email,
             'invitation': self,
         }
         send_mail('team_invitation', [self.email], context=c)
Exemplo n.º 3
0
def invite_friends(request):
    form = InviteFriendsForm(request.POST or None)
    if form.is_valid():
        extra_context = {
            'user': request.user
        }
        emails = form.cleaned_data['emails']
        aux = User.objects.filter(email__in=emails).values_list('email', flat=True)
        emails = list(set(emails) - set(aux))
        send_mail('invite_friends', emails, extra_context)
        return HttpResponse('OK', status=200)
    return TemplateResponse(request, 'identity/welcome/invite_friends_form.html', locals())
Exemplo n.º 4
0
def invite_friends(request):
    form = InviteFriendsForm(request.POST or None)
    if form.is_valid():
        extra_context = {'user': request.user}
        emails = form.cleaned_data['emails']
        aux = User.objects.filter(email__in=emails).values_list('email',
                                                                flat=True)
        emails = list(set(emails) - set(aux))
        send_mail('invite_friends', emails, extra_context)
        return HttpResponse('OK', status=200)
    return TemplateResponse(request,
                            'identity/welcome/invite_friends_form.html',
                            locals())
Exemplo n.º 5
0
def set_username(sender, **kwargs):
    instance = kwargs['instance']
    save = False
    if instance.id and (instance.username.startswith('user_') and
       not instance.username.replace('user_', '').isdigit()):
        instance.username = '******' % instance.id
        save = True
    if kwargs['created']:
        c = {
            'email': instance.email,
            'user': instance,
        }
        send_mail('welcome', [instance.email], context=c)
    if save:
        instance.save()
Exemplo n.º 6
0
 def save(self, domain_override=None,
          subject_template_name='emails/forgot_password_subject.txt',
          email_template_name='emails/forgot_password.html',
          use_https=False, token_generator=default_token_generator,
          from_email=None, request=None, html_email_template_name=None):
     email = self.cleaned_data['email'].strip()
     active_users = User._default_manager.filter(
         email__iexact=email, is_active=True
     )
     for user in active_users:
         if not user.has_usable_password():
             continue
         c = {
             'email': user.email,
             'uid': urlsafe_base64_encode(force_bytes(user.pk)),
             'user': user,
             'token': token_generator.make_token(user),
         }
         send_mail('forgot_password', [user.email], context=c)
Exemplo n.º 7
0
 def save(self,
          domain_override=None,
          subject_template_name='emails/forgot_password_subject.txt',
          email_template_name='emails/forgot_password.html',
          use_https=False,
          token_generator=default_token_generator,
          from_email=None,
          request=None,
          html_email_template_name=None):
     email = self.cleaned_data['email'].strip()
     active_users = User._default_manager.filter(email__iexact=email,
                                                 is_active=True)
     for user in active_users:
         if not user.has_usable_password():
             continue
         c = {
             'email': user.email,
             'uid': urlsafe_base64_encode(force_bytes(user.pk)),
             'user': user,
             'token': token_generator.make_token(user),
         }
         send_mail('forgot_password', [user.email], context=c)