diff options
author | hardythe1 | 2015-01-30 13:18:53 +0530 |
---|---|---|
committer | hardythe1 | 2015-01-30 13:18:53 +0530 |
commit | 1925e9b20777a03ede9ee59ae5d759a3524a0093 (patch) | |
tree | ff5b9b075520a652c24080c31630899e5237ef73 /tbc | |
parent | 58d2c6cac74f200f2e410ee47a71f1f19971cdd2 (diff) | |
download | Python-TBC-Interface-1925e9b20777a03ede9ee59ae5d759a3524a0093.tar.gz Python-TBC-Interface-1925e9b20777a03ede9ee59ae5d759a3524a0093.tar.bz2 Python-TBC-Interface-1925e9b20777a03ede9ee59ae5d759a3524a0093.zip |
check for duplicate email while registration
Diffstat (limited to 'tbc')
-rw-r--r-- | tbc/templates/tbc/register.html | 10 | ||||
-rwxr-xr-x | tbc/views.py | 14 |
2 files changed, 20 insertions, 4 deletions
diff --git a/tbc/templates/tbc/register.html b/tbc/templates/tbc/register.html index 68323fb..97bf423 100644 --- a/tbc/templates/tbc/register.html +++ b/tbc/templates/tbc/register.html @@ -1,5 +1,15 @@ {% extends 'base.html' %} {% block content %} + +{% if DuplicateEmail %} + <center> + <div class="alert" style="width:360px;height:23px;"> + <a class="close" data-dismiss="alert" href="#">×</a> + <p>Sorry ! User with same email address already exists.</p> + </div> + </center> +{% endif %} + <div id="content-wrap" style="max-width:600px;"> <h3>Registration</h3> <hr> diff --git a/tbc/views.py b/tbc/views.py index 5fde428..7d7bc7c 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -192,12 +192,19 @@ def UserLogin(request): def UserRegister(request): context = {} + context.update(csrf(request)) if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): - user = form.save() - add_log(user, user, CHANGE, 'Registered') - return HttpResponseRedirect('/login/?signup=done') + email = request.POST['email'] + if User.objects.get(email=email): + context['form'] = form + context['DuplicateEmail'] = True + return render_to_response('tbc/register.html', context) + else: + user = form.save() + add_log(user, user, CHANGE, 'Registered') + return HttpResponseRedirect('/login/?signup=done') else: context = {} context.update(csrf(request)) @@ -205,7 +212,6 @@ def UserRegister(request): return render_to_response('tbc/register.html', context) else: form = UserRegisterForm() - context.update(csrf(request)) context['form'] = form return render_to_response('tbc/register.html', context) |