From 18d5bf1a0a718be3ba0c33fcbc259e6836ab6d1f Mon Sep 17 00:00:00 2001 From: anoop Date: Wed, 17 Feb 2010 18:55:01 +0530 Subject: started using django-registration default backend, removed browse users functionality. --- settings.py | 3 +++ taskapp/views/user.py | 11 ++++++----- templates/index.html | 1 - templates/registration/activation_email.txt | 9 +++++++++ templates/registration/activation_email_subject.txt | 1 + templates/registration/login.html | 7 +++++++ templates/registration/logout.html | 4 ++++ templates/registration/registration_complete.html | 4 ++++ templates/registration/registration_form.html | 7 +++++++ urls.py | 4 +++- 10 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 templates/registration/activation_email.txt create mode 100644 templates/registration/activation_email_subject.txt create mode 100644 templates/registration/login.html create mode 100644 templates/registration/logout.html create mode 100644 templates/registration/registration_complete.html create mode 100644 templates/registration/registration_form.html diff --git a/settings.py b/settings.py index 4f70f7a..f215f97 100644 --- a/settings.py +++ b/settings.py @@ -72,6 +72,8 @@ TEMPLATE_DIRS = ( './templates', ) +ACCOUNT_ACTIVATION_DAYS = 5 + INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', @@ -79,6 +81,7 @@ INSTALLED_APPS = ( 'django.contrib.sites', 'django.contrib.admin', 'pytask.taskapp', + 'registration', ) AUTH_PROFILE_MODULE = 'taskapp.Profile' diff --git a/taskapp/views/user.py b/taskapp/views/user.py index 7f028d1..20562e7 100644 --- a/taskapp/views/user.py +++ b/taskapp/views/user.py @@ -1,4 +1,4 @@ -from django.http import HttpResponse +from django.http import HttpResponse, Http404 from django.shortcuts import redirect, render_to_response from pytask.taskapp.models import Task from pytask.taskapp.forms.user import UserProfileEditForm @@ -48,8 +48,12 @@ def homepage(request): return render_to_response('index.html', context) @login_required -def view_my_profile(request,uid): +def view_my_profile(request,uid=None): """ allows the user to view the profiles of users """ + if uid == None: + edit_profile = True + profile = Profile.objects.get(user = request.user) + return render_to_response('user/my_profile.html', {'edit_profile':edit_profile,'profile':profile}) edit_profile = True if request.user == User.objects.get(pk=uid) else False try: profile = Profile.objects.get(user = User.objects.get(pk=uid)) @@ -78,6 +82,3 @@ def edit_my_profile(request): edit_profile_form = UserProfileEditForm(instance = profile) return render_to_response('user/edit_profile.html',{'edit_profile_form' : edit_profile_form}) -def browse_users(request): - userlist = User.objects.order_by('username') - return render_to_response('user/browse.html',{'userlist':userlist}) diff --git a/templates/index.html b/templates/index.html index 3154221..96846fd 100644 --- a/templates/index.html +++ b/templates/index.html @@ -13,7 +13,6 @@ logout

Tasks
- Users
My Profile
{% endif %} {% if can_create_task %} diff --git a/templates/registration/activation_email.txt b/templates/registration/activation_email.txt new file mode 100644 index 0000000..2d9e253 --- /dev/null +++ b/templates/registration/activation_email.txt @@ -0,0 +1,9 @@ +Welcome to PyTasks: + +Click on the following link +http://www.pytasks.in/accounts/activate/{{activation_key}} +and activate your account. +Note that the account has to activated within {{expiration_days}} days + +Regards, +PyTasks Team diff --git a/templates/registration/activation_email_subject.txt b/templates/registration/activation_email_subject.txt new file mode 100644 index 0000000..c73db7e --- /dev/null +++ b/templates/registration/activation_email_subject.txt @@ -0,0 +1 @@ +Welcome to PyTasks! diff --git a/templates/registration/login.html b/templates/registration/login.html new file mode 100644 index 0000000..f762af1 --- /dev/null +++ b/templates/registration/login.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} +{% block content %} +
+{{ form.as_p }} + +
+{% endblock %} diff --git a/templates/registration/logout.html b/templates/registration/logout.html new file mode 100644 index 0000000..b2f9910 --- /dev/null +++ b/templates/registration/logout.html @@ -0,0 +1,4 @@ +{% extends 'base.html' %} +{% block content %} +You have successfully logged out of PyTasks. +{% endblock %} diff --git a/templates/registration/registration_complete.html b/templates/registration/registration_complete.html new file mode 100644 index 0000000..53e85bc --- /dev/null +++ b/templates/registration/registration_complete.html @@ -0,0 +1,4 @@ +{% extends 'base.html' %} +{% block content %} +Please check your email for instructions on activating your account. +{% endblock %} diff --git a/templates/registration/registration_form.html b/templates/registration/registration_form.html new file mode 100644 index 0000000..ed116d3 --- /dev/null +++ b/templates/registration/registration_form.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} +{% block content %} +
+{{ form.as_p }} + +
+{% endblock %} diff --git a/urls.py b/urls.py index ba83abc..bf51a06 100644 --- a/urls.py +++ b/urls.py @@ -29,8 +29,10 @@ urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), + (r'^accounts/', include('registration.urls')), + (r'^accounts/profile/$', userViews.view_my_profile), + (r'^user/view/uid=(\d+)$', userViews.view_my_profile), (r'^user/edit/?$', userViews.edit_my_profile), - (r'^user/browse/?$', userViews.browse_users), ) -- cgit