def form(req): out = {} feedback_form = FeddbackAuthForm if req.user.is_authenticated( ) else FeddbackForm if req.POST: out['form'] = form = feedback_form(req.POST) if form.is_valid(): if req.user.is_authenticated(): form.instance.author = req.user form.save() #send E-Mail emails = User.objects.filter( models.Q(is_superuser=True) | models.Q(is_staff=True)).values_list('email') out['feedback'] = form.instance send_mail(ugettext('New feedback'), render_to_string('feedback/email.html', out, context_instance=RequestContext(req)), SEND_FROM_EMAIL, emails, fail_silently=False, content_subtype='html') req.flash.notice = ugettext(u'Ваше сообщение успешно отправлено') return HttpResponseRedirect(reverse("feedback_form")) else: out['form'] = feedback_form() return out
def form(req): out={} feedback_form = FeddbackAuthForm if req.user.is_authenticated() else FeddbackForm if req.POST: out['form'] = form = feedback_form(req.POST) if form.is_valid(): if req.user.is_authenticated(): form.instance.author=req.user form.save() #send E-Mail emails = User.objects.filter(models.Q(is_superuser=True) | models.Q(is_staff = True) ).values_list('email') out['feedback'] = form.instance send_mail(ugettext('New feedback'), render_to_string('feedback/email.html',out, context_instance = RequestContext(req)), SEND_FROM_EMAIL, emails, fail_silently=False, content_subtype='html' ) req.flash.notice = ugettext(u'Ваше сообщение успешно отправлено') return HttpResponseRedirect(reverse("feedback_form")) else: out['form'] = feedback_form() return out
def send_restore_password_code(self): email_body = render_to_string('emails/recovery_password.txt', { 'user': self, 'SITE_DOMAIN': settings.SITE_DOMAIN }) if settings.SEND_EMAILS: send_mail(_('Password Reset Request'), email_body, settings.SERVER_EMAIL, [self.email], fail_silently=True)
def send_activation_code(self): #@todo: send email in a separate process (queue worker or smth like it) #@todo: check email sending results email_body = render_to_string('emails/confirm_registration.txt', { 'user': self, 'SITE_DOMAIN': settings.SITE_DOMAIN }) #if settings.DEBUG: # print email_body if settings.SEND_EMAILS: send_mail(_('Confirm registration'), email_body, settings.SERVER_EMAIL, [self.email], fail_silently=True)
def send(self): email_body = render_to_string('emails/invite.txt', dict( invite=self, SITE_DOMAIN=settings.SITE_DOMAIN, )) #if settings.DEBUG: # print email_body if settings.SEND_EMAILS: send_mail(_('Site invite'), email_body, settings.SERVER_EMAIL, (self.recipient_email,), fail_silently=True)
def send(self): email_body = render_to_string( 'emails/invite.txt', dict( invite=self, SITE_DOMAIN=settings.SITE_DOMAIN, )) #if settings.DEBUG: # print email_body if settings.SEND_EMAILS: send_mail(_('Site invite'), email_body, settings.SERVER_EMAIL, (self.recipient_email, ), fail_silently=True)