Commits

Anonymous committed 9b2cb64 Draft

"cambios"

Comments (0)

Files changed (1)

registration/models.py

         return False
     
     def create_inactive_user(self, username, email, password,
-                             site, send_email=True):
+                             site, language, code, send_email=True):
         """
         Create a new, inactive ``User``, generate a
         ``RegistrationProfile`` and email its activation key to the
         registration_profile = self.create_profile(new_user)
 
         if send_email:
-            registration_profile.send_activation_email(site)
+            registration_profile.send_activation_email(site, language, code)
 
         return new_user
     create_inactive_user = transaction.commit_on_success(create_inactive_user)
                (self.user.date_joined + expiration_date <= datetime_now())
     activation_key_expired.boolean = True
 
-    def send_activation_email(self, site):
+    def send_activation_email(self, site, language, code):
         """
         Send an activation email to the user associated with this
         ``RegistrationProfile``.
         """
         ctx_dict = {'activation_key': self.activation_key,
                     'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS,
-                    'site': site}
+                    'site': site,
+                    'code': code,
+                    'language': language
+                    }
         subject = render_to_string('registration/activation_email_subject.txt',
                                    ctx_dict)
         # Email subject *must not* contain newlines
         subject = ''.join(subject.splitlines())
         
-        message = render_to_string('registration/activation_email.txt',
-                                   ctx_dict)
+        message_text = render_to_string('registration/activation_email.txt', ctx_dict) 
+
+        from django.core.mail import EmailMultiAlternatives
+        message_html = render_to_string('registration/activation_email.html', ctx_dict) 
+        message = EmailMultiAlternatives(subject, message_text, settings.DEFAULT_FROM_EMAIL, [self.user.email])
+        message.attach_alternative(message_html, "text/html")
+        message.send()
         
-        self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
+        #message = render_to_string('registration/activation_email.txt',ctx_dict)
+        #self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)