Commits

Anonymous committed e939f86

send email when new user is registered

Comments (0)

Files changed (7)

django_authopenid/templates/authopenid/registration_email.txt

+Thank you to join {{ site }}.

django_authopenid/templates/authopenid/registration_email_subject.txt

+Welcome to {{ site }}

django_authopenid/templates/authopenid/signin.html

 		
         <div class="submit-row"><input type="submit" name="blogin" value="{% trans "Sign in" %}"> </div>
 	</fieldset>	
+	<p><a href="{% url registration_register %}}">{% trans "Create a new account" %}</a></p>
 </form>
 
 <br />

django_authopenid/templates/registration/registration_form.html

+{% extends "base.html" %}
+{% load i18n %}
+
+{% block head %}
+
+
+{% endblock %}
+
+
+{% block content %}
+
+<form action="" method="post">
+	<table>
+		{{ form.as_table }}
+	</table>
+	 <div class="submit-row"><input type="submit" name="bsignup" value="{% trans "Sign up" %}"> </div>
+{% endblock %}

django_authopenid/urls.py

 # -*- coding: utf-8 -*-
 from django.conf.urls.defaults import patterns, url
-from django.utils.translation import ugettext as _
+from django.views.generic.simple import direct_to_template
 
+# views
 from django.contrib.auth import views as auth_views
 from django_authopenid import views as oid_views
+from registration import views as reg_views
+
 
 urlpatterns = patterns('',
-    # yadis rdf
-    url(r'^yadis.xrdf$', oid_views.xrdf, name='oid_views.yadis_xrdf'),
+    # django registration activate
+    url(r'^activate/(?P<activation_key>\w+)/$', reg_views.activate, name='registration_activate'),
     
     # user profile
     url(r'^password/$',oid_views.password_change, name='auth_password_change'),
     url(r'^signin/$', oid_views.signin, name='user_signin'),
     url(r'^signout/$', oid_views.signout, name='user_signout'),
     url(r'^signin/complete/$', oid_views.complete_signin, name='user_complete_signin'),
-  
+    url(r'^signup/$', reg_views.register, name='registration_register'),
+    url(r'^signup/complete/$',direct_to_template, 
+        {'template': 'registration/registration_complete.html'},
+        name='registration_complete'),
+    
+    # yadis uri
+    url(r'^yadis.xrdf$', oid_views.xrdf, name='oid_views.yadis_xrdf'),
 )

django_authopenid/views.py

 from django.contrib.auth.models import User
 from django.contrib.auth import login, logout
 from django.contrib.auth.decorators import login_required
+from django.contrib.sites.models import Site
 
 from django.http import HttpResponseRedirect
 from django.shortcuts import render_to_response as render
 @not_authenticated
 def register(request, template_name='authopenid/complete.html', 
             redirect_field_name=REDIRECT_FIELD_NAME, register_form=OpenidRegisterForm, 
-            auth_form=AuthenticationForm, register_account=register_account):
+            auth_form=AuthenticationForm, register_account=register_account, send_email=True):
     """
     register an openid.
 
             )
             uassoc.save()
             login(request, user_)
+            
+            if send_email:
+                from django.core.mail import send_mail
+                current_site = Site.objects.get_current()
+                subject = render_to_string('authopenid/registration_email_subject.txt',
+                                           { 'site': current_site,
+                                             'user': user})
+                message = render_to_string('authopenid/registration_email.txt',
+                                           { 'site': current_site,
+                                             'user': user
+                                            })
+
+                send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [new_user.email])
             return HttpResponseRedirect(redirect_to) 
     
     return render(template_name, {
     return render(template_name, {
         'form': form,
         'set_password': set_password
-    }, context_instance=RequestContext(request))
-    
-    
+    }, context_instance=RequestContext(request))
     ],
 
     install_requires = [
-        'python-openid'
+        'python-openid',
+        'django-registration'
     ],