コード例 #1
0
 def save(self):
     user = User.objects.get(email=self.cleaned_data['email'])
     key = generate_hash_key(user.username)
     reset = PasswordReset(key=key, user=user)
     reset.save()
     template_name = 'accounts/password_reset_mail.html'
     subject = 'Criar nova senha no Simple MOOC'
     context = {'reset': reset}
     send_email_template(subject, template_name, context, ['user.email'])
コード例 #2
0
 def send_mail(self, course):
     subject = '[%s] Contato' % course
     context = {
         'name': self.cleaned_data['name'],
         'email': self.cleaned_data['email'],
         'message': self.cleaned_data['message'],
     }
     template_name = 'courses/contact_email.html'
     send_email_template(subject, template_name, context, [settings.CONTACT_EMAIL])
コード例 #3
0
    def send_mail(self, course):
        subject = '[%s] Contato' % course
        context = {
            'name': self.cleaned_data['name'],
            'email': self.cleaned_data['email'],
            'message': self.cleaned_data['message'],
        }

        template_nome = 'courses/contact_email.html'
        send_email_template(subject, template_nome, context,
                            [settings.CONTACT_EMAIL])
コード例 #4
0
def post_save_announcement(instance, created, **kwargs):
    if created:
        subject = instance.title
        context = {'announcement': instance}
        template_name = 'courses/announcement_mail.html'
        enrollments = Enrollment.objects.filter(course=instance.course,
                                                status=1)
        for enrollment in enrollments:
            recipient_list = [enrollment.user.email]
            send_email_template(subject, template_name, context,
                                recipient_list)
コード例 #5
0
 def send_email(self, course):
     subject = '[%s] Contato' % course.name
     #message = 'Nome: %(name)s;E-mail:%(email)s;%(message)s'
     context = {
         'name':self.cleaned_data['name'],
         'email':self.cleaned_data['email'],
         'message':self.cleaned_data['message']
     }
     #message = message % context
     #send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [settings.CONTACT_EMAIL])
     template_email = 'courses/contact_email.html'
     send_email_template(subject, template_email, context, [settings.CONTACT_EMAIL])
コード例 #6
0
ファイル: forms.py プロジェクト: danielgomesmateus/simplemooc
    def SendEmail(self, course):

        subject = '[%s] - Contato' % course
        #message = 'Nome: %(name)s; Email: %(email)s; Título: %(title)s; %(message)s'

        context = {
            'name': self.cleaned_data['name'],
            'email': self.cleaned_data['email'],
            'title': self.cleaned_data['title'],
            'message': self.cleaned_data['message']
        }

        template_name = 'courses/contact_email.html'

        send_email_template(subject, template_name, context,
                            [settings.CONTACT_EMAIL])
コード例 #7
0
def post_save_announcement(instance, created, **kwargs):
    # Esse kwargs é porque os signals do django passam vários atributos
    # só iremos usar os dois primeiros
    if created:
        subject = instance.title
        context = {
            'announcement': instance
        }
        template_name = 'courses/announcement_mail.html'
        enrollments = Enrollment.objects.filter(
            course=instance.course,
            status=Status_Course.INS
        )
        #envia um por vez pra evitar bloqueio por spam
        for enrollment in enrollments:
            recipient_list = [enrollment.user.email]
            send_email_template(subject, template_name, context, recipient_list)
コード例 #8
0
    def save(self):
        user = User.objects.get(email=self.cleaned_data['email'])
        import time
        key = TokenGenerator._make_token_with_timestamp(user, int(time.time()))
        reset = PasswordReset(key=key, user=user)
        reset.save()
        template_name = 'accounts/password_reset_mail.html'
        subject = '[Simple MOOC] Redefinição de senha'
        context = {'reset': reset}
        send_email_template(subject, template_name, context, [user.email])


#usado para forçar email unico, mas depreciado pois nosso custom user ja tem isso
# def clean_email(self):
#     #django, por padrão, além de verificar o tipo
#     # procura um clean_nomedocampo e usa se houver
#     email = self.cleaned_data['email']
#     if User.objects.filter(email=email).exists():
#         raise forms.ValidationError('Email já cadastrado no sistema')
#     return email