def password_forgotten(self, request, email): """ Generate a new password for the given user and send the new password by email. """ try: user = User.objects.get(email=email.lower().strip()) password_plaintext = get_pronounceable_password() user.set_password(password_plaintext) user.save() from cubane.cms.views import get_cms cms = get_cms() cubane_send_shop_mail( request, email, '%s | New Password Request' % cms.settings.name, { 'password_reset': True, 'customer': user, 'password_plaintext': password_plaintext, 'login_url': get_absolute_url('shop.account.login', https=True) }) return True except User.DoesNotExist: return False
def send_client_mail(request, email, subject, context, attachments=None): from cubane.cms.views import get_cms cms = get_cms() cubane_send_shop_mail(request, email, subject, context, attachments=attachments)
def test_should_render_cms_page_and_dispatch_email(self): page = Page() page.title = 'Test Page' page.slug = 'test' page.template = 'testapp/mail/enquiry_visitor.html' page.set_slot_content('content', '<h1>Test</h1>') page.save() settings = Settings() settings.shop_email_template = page settings.save() cubane_send_shop_mail(None, '*****@*****.**', 'Test') m = self.get_latest_email() self.assertTrue('*****@*****.**' in m.to, 'to address not found') self.assertEqual(m.subject, 'Test') self.assertTrue('<html><head><title>' in m.message().as_string()) self.assertTrue('<h1>Test</h1>' in m.message().as_string())
def test_requires_ishop_module(self): with self.assertRaisesRegexp( ValueError, 'cubane.ishop required for sending shop page emails.'): cubane_send_shop_mail(None, '*****@*****.**', 'Test')