diff options
author | Nishanth Amuluru | 2011-01-08 11:20:57 +0530 |
---|---|---|
committer | Nishanth Amuluru | 2011-01-08 11:20:57 +0530 |
commit | 65411d01d448ff0cd4abd14eee14cf60b5f8fc20 (patch) | |
tree | b4c404363c4c63a61d6e2f8bd26c5b057c1fb09d /profile | |
parent | 2e35094d43b4cc6974172e1febf76abb50f086ec (diff) | |
download | pytask-65411d01d448ff0cd4abd14eee14cf60b5f8fc20.tar.gz pytask-65411d01d448ff0cd4abd14eee14cf60b5f8fc20.tar.bz2 pytask-65411d01d448ff0cd4abd14eee14cf60b5f8fc20.zip |
Added buildout stuff and made changes accordingly
--HG--
rename : profile/management/__init__.py => eggs/djangorecipe-0.20-py2.6.egg/EGG-INFO/dependency_links.txt
rename : profile/management/__init__.py => eggs/djangorecipe-0.20-py2.6.egg/EGG-INFO/not-zip-safe
rename : profile/management/__init__.py => eggs/infrae.subversion-1.4.5-py2.6.egg/EGG-INFO/dependency_links.txt
rename : profile/management/__init__.py => eggs/infrae.subversion-1.4.5-py2.6.egg/EGG-INFO/not-zip-safe
rename : profile/management/__init__.py => eggs/mercurial-1.7.3-py2.6-linux-x86_64.egg/EGG-INFO/dependency_links.txt
rename : profile/management/__init__.py => eggs/mercurial-1.7.3-py2.6-linux-x86_64.egg/EGG-INFO/not-zip-safe
rename : profile/management/__init__.py => eggs/py-1.4.0-py2.6.egg/EGG-INFO/dependency_links.txt
rename : profile/management/__init__.py => eggs/py-1.4.0-py2.6.egg/EGG-INFO/not-zip-safe
rename : profile/management/__init__.py => eggs/zc.buildout-1.5.2-py2.6.egg/EGG-INFO/dependency_links.txt
rename : profile/management/__init__.py => eggs/zc.buildout-1.5.2-py2.6.egg/EGG-INFO/not-zip-safe
rename : profile/management/__init__.py => eggs/zc.recipe.egg-1.3.2-py2.6.egg/EGG-INFO/dependency_links.txt
rename : profile/management/__init__.py => eggs/zc.recipe.egg-1.3.2-py2.6.egg/EGG-INFO/not-zip-safe
rename : profile/management/__init__.py => parts/django/Django.egg-info/dependency_links.txt
rename : taskapp/models.py => parts/django/django/conf/app_template/models.py
rename : taskapp/tests.py => parts/django/django/conf/app_template/tests.py
rename : taskapp/views.py => parts/django/django/conf/app_template/views.py
rename : taskapp/views.py => parts/django/django/contrib/gis/tests/geo3d/views.py
rename : profile/management/__init__.py => parts/django/tests/modeltests/delete/__init__.py
rename : profile/management/__init__.py => parts/django/tests/modeltests/files/__init__.py
rename : profile/management/__init__.py => parts/django/tests/modeltests/invalid_models/__init__.py
rename : profile/management/__init__.py => parts/django/tests/modeltests/m2m_signals/__init__.py
rename : profile/management/__init__.py => parts/django/tests/modeltests/model_package/__init__.py
rename : profile/management/__init__.py => parts/django/tests/regressiontests/bash_completion/__init__.py
rename : profile/management/__init__.py => parts/django/tests/regressiontests/bash_completion/management/__init__.py
rename : profile/management/__init__.py => parts/django/tests/regressiontests/bash_completion/management/commands/__init__.py
rename : profile/management/__init__.py => parts/django/tests/regressiontests/bash_completion/models.py
rename : profile/management/__init__.py => parts/django/tests/regressiontests/delete_regress/__init__.py
rename : profile/management/__init__.py => parts/django/tests/regressiontests/file_storage/__init__.py
rename : profile/management/__init__.py => parts/django/tests/regressiontests/max_lengths/__init__.py
rename : profile/forms.py => pytask/profile/forms.py
rename : profile/management/__init__.py => pytask/profile/management/__init__.py
rename : profile/management/commands/seed_db.py => pytask/profile/management/commands/seed_db.py
rename : profile/models.py => pytask/profile/models.py
rename : profile/templatetags/user_tags.py => pytask/profile/templatetags/user_tags.py
rename : taskapp/tests.py => pytask/profile/tests.py
rename : profile/urls.py => pytask/profile/urls.py
rename : profile/utils.py => pytask/profile/utils.py
rename : profile/views.py => pytask/profile/views.py
rename : static/css/base.css => pytask/static/css/base.css
rename : taskapp/tests.py => pytask/taskapp/tests.py
rename : taskapp/views.py => pytask/taskapp/views.py
rename : templates/base.html => pytask/templates/base.html
rename : templates/profile/browse_notifications.html => pytask/templates/profile/browse_notifications.html
rename : templates/profile/edit.html => pytask/templates/profile/edit.html
rename : templates/profile/view.html => pytask/templates/profile/view.html
rename : templates/profile/view_notification.html => pytask/templates/profile/view_notification.html
rename : templates/registration/activate.html => pytask/templates/registration/activate.html
rename : templates/registration/activation_email.txt => pytask/templates/registration/activation_email.txt
rename : templates/registration/activation_email_subject.txt => pytask/templates/registration/activation_email_subject.txt
rename : templates/registration/logged_out.html => pytask/templates/registration/logged_out.html
rename : templates/registration/login.html => pytask/templates/registration/login.html
rename : templates/registration/logout.html => pytask/templates/registration/logout.html
rename : templates/registration/password_change_done.html => pytask/templates/registration/password_change_done.html
rename : templates/registration/password_change_form.html => pytask/templates/registration/password_change_form.html
rename : templates/registration/password_reset_complete.html => pytask/templates/registration/password_reset_complete.html
rename : templates/registration/password_reset_confirm.html => pytask/templates/registration/password_reset_confirm.html
rename : templates/registration/password_reset_done.html => pytask/templates/registration/password_reset_done.html
rename : templates/registration/password_reset_email.html => pytask/templates/registration/password_reset_email.html
rename : templates/registration/password_reset_form.html => pytask/templates/registration/password_reset_form.html
rename : templates/registration/registration_complete.html => pytask/templates/registration/registration_complete.html
rename : templates/registration/registration_form.html => pytask/templates/registration/registration_form.html
rename : utils.py => pytask/utils.py
Diffstat (limited to 'profile')
-rwxr-xr-x | profile/__init__.py | 0 | ||||
-rw-r--r-- | profile/__init__.pyc | bin | 146 -> 0 bytes | |||
-rw-r--r-- | profile/events.py | 0 | ||||
-rw-r--r-- | profile/forms.py | 93 | ||||
-rw-r--r-- | profile/forms.pyc | bin | 3845 -> 0 bytes | |||
-rw-r--r-- | profile/management/__init__.py | 1 | ||||
-rw-r--r-- | profile/management/commands/__init__.py | 0 | ||||
-rw-r--r-- | profile/management/commands/seed_db.py | 61 | ||||
-rwxr-xr-x | profile/models.py | 78 | ||||
-rw-r--r-- | profile/templatetags/__init__.py | 0 | ||||
-rw-r--r-- | profile/templatetags/user_tags.py | 12 | ||||
-rwxr-xr-x | profile/tests.py | 23 | ||||
-rw-r--r-- | profile/urls.py | 16 | ||||
-rw-r--r-- | profile/utils.py | 32 | ||||
-rwxr-xr-x | profile/views.py | 149 |
15 files changed, 0 insertions, 465 deletions
diff --git a/profile/__init__.py b/profile/__init__.py deleted file mode 100755 index e69de29..0000000 --- a/profile/__init__.py +++ /dev/null diff --git a/profile/__init__.pyc b/profile/__init__.pyc Binary files differdeleted file mode 100644 index 888cd78..0000000 --- a/profile/__init__.pyc +++ /dev/null diff --git a/profile/events.py b/profile/events.py deleted file mode 100644 index e69de29..0000000 --- a/profile/events.py +++ /dev/null diff --git a/profile/forms.py b/profile/forms.py deleted file mode 100644 index 649be82..0000000 --- a/profile/forms.py +++ /dev/null @@ -1,93 +0,0 @@ -import os -import PIL - -from django import forms - -from registration.forms import RegistrationFormUniqueEmail -from registration.models import RegistrationProfile - -from pytask.utils import make_key -from pytask.profile.models import GENDER_CHOICES, Profile - -class CustomRegistrationForm(RegistrationFormUniqueEmail): - """Used instead of RegistrationForm used by default django-registration - backend, this adds aboutme, dob, gender, address, phonenum to the default - django-registration RegistrationForm""" - - full_name = forms.CharField(required=True, max_length=50, - label="Name as on your bank account", - help_text="Any DD/Cheque will be issued on \ - this name") - - aboutme = forms.CharField(required=True, max_length=1000, label=u"About Me", - help_text="A write up about yourself to aid the\ - reviewer in judging your eligibility for a task.\ - It can have your educational background, CGPA,\ - field of interests etc.," - ) - - - dob = forms.DateField(help_text = "YYYY-MM-DD", required=True, label=u'date of birth') - gender = forms.ChoiceField(choices = GENDER_CHOICES, required=True, label=u'gender') - - address = forms.CharField(required=True, max_length=200, help_text="This \ - information will be used while sending DD/Cheque") - phonenum = forms.CharField(required=True, max_length=10, - label="Phone Number") - - def clean_aboutme(self): - """ Empty not allowed """ - - data = self.cleaned_data['aboutme'] - if not data.strip(): - raise forms.ValidationError("Please write something about\ - yourself") - - return data - - def clean_address(self): - """ Empty not allowed """ - - data = self.cleaned_data['address'] - if not data.strip(): - raise forms.ValidationError("Please enter an address") - - return data - - def clean_phonenum(self): - """ should be of 10 digits """ - - data = self.cleaned_data['phonenum'] - - if (not data.strip()) or \ - (data.strip("1234567890")) or \ - (len(data)!= 10): - raise forms.ValidationError("This is not a valid phone number") - - return data - - - def save(self,profile_callback=None): - - new_user = RegistrationProfile.objects.create_inactive_user( - username=self.cleaned_data['username'], - password=self.cleaned_data['password1'], - email=self.cleaned_data['email']) - - new_profile = Profile(user=new_user, - aboutme=self.cleaned_data['aboutme'], - dob=self.cleaned_data['dob'], - gender=self.cleaned_data['gender'], - address=self.cleaned_data['address'], - phonenum=self.cleaned_data['phonenum'], - uniq_key=make_key(Profile), - ) - new_profile.save() - - return new_user - -class EditProfileForm(forms.ModelForm): - - class Meta: - model = Profile - fields = ['full_name', 'aboutme', 'gender', 'dob', 'address', 'phonenum'] diff --git a/profile/forms.pyc b/profile/forms.pyc Binary files differdeleted file mode 100644 index a9a5609..0000000 --- a/profile/forms.pyc +++ /dev/null diff --git a/profile/management/__init__.py b/profile/management/__init__.py deleted file mode 100644 index 8b13789..0000000 --- a/profile/management/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/profile/management/commands/__init__.py b/profile/management/commands/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/profile/management/commands/__init__.py +++ /dev/null diff --git a/profile/management/commands/seed_db.py b/profile/management/commands/seed_db.py deleted file mode 100644 index e011ee8..0000000 --- a/profile/management/commands/seed_db.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys -from datetime import datetime -from django.core.management.base import NoArgsCommand - -from django.contrib.auth.models import User - -from pytask.profile.models import Profile, Notification -from pytask.utils import make_key - -def seed_db(): - """ a method to seed the database with random data """ - - - for i in range(21,1,-1): - - username = 'user'+str(i) - email = username+'@example.com' - password = '123456' - full_name = "User "+str(i) - dob = datetime.now() - gender = "M" - aboutme = "I am User"+str(i) - address = "I live in street"+str(i) - phonenum = "1234567890" - - new_user = User.objects.create_user(username=username, - email=email, - password=password) - - new_profile = Profile() - new_profile.user = new_user - new_profile.full_name = full_name - new_profile.dob = dob - new_profile.aboutme = aboutme - new_profile.gender = gender - new_profile.address = address - new_profile.phonenum = phonenum - if i%2 == 0: - new_profile.rights = "CT" - elif i%3 == 0: - new_profile.rights = "CR" - new_profile.save() - - new_user.is_superuser = True - new_user.is_staff = True - new_user.save() - - for i in range(10): - Notification(sent_to=new_user, sent_date=datetime.now(), - subject="A subject here for"+str(i), - message="A message with mess"+str(i)+" html inside.\ - <br /><b>a bold text</b>", - uniq_key=make_key(Notification), - ).save() - -class Command(NoArgsCommand): - - def handle_noargs(self, **options): - """ Just copied the code from seed_db.py """ - - seed_db() diff --git a/profile/models.py b/profile/models.py deleted file mode 100755 index 48e8dc5..0000000 --- a/profile/models.py +++ /dev/null @@ -1,78 +0,0 @@ -from django.db import models - -from django.contrib.auth.models import User - -GENDER_CHOICES = (( 'M', 'Male'), ('F', 'Female')) - -RIGHTS_CHOICES = ( - ("DC", "Director"), - ("MG", "Manager"), - ("CR", "Co-ordinator"), - ("CT", "Contributor"),) - -ROLE_CHOICES = ( - ("DC", "Request sent by Director \ - to a user at lower level, asking him to act as a director"), - ("MG", "Request sent by Manager \ - to a user at lower level, asking him to act as a manager"),) - -class Profile(models.Model): - - uniq_key = models.CharField(max_length=20) - - full_name = models.CharField(max_length=50, verbose_name="Name as on bank\ - account", help_text="Any DD/Cheque will be\ - issued on this name") - user = models.ForeignKey(User, unique = True) - rights = models.CharField(max_length = 2, choices = RIGHTS_CHOICES, default = u"CT") - pynts = models.PositiveSmallIntegerField(default = 0) - - aboutme = models.TextField(blank = True, help_text="This information will\ - be used to judge the eligibility for any task") - - dob = models.DateField(verbose_name = u"Date of Birth", help_text = "YYYY-MM-DD") - gender = models.CharField(max_length = 1, choices = GENDER_CHOICES) - - address = models.TextField(blank = False, help_text="This information will\ - be used to send any DDs/Cheques") - phonenum = models.CharField(max_length = 15, blank = True, verbose_name = u"Phone Number") - - def __unicode__(self): - return unicode(self.user.username) - -class Notification(models.Model): - """ A model to hold notifications. - All these are sent by the site to users. - Hence there is no sent_from option. - """ - - uniq_key = models.CharField(max_length=20) - - sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False) - - subject = models.CharField(max_length=100, blank=True) - message = models.TextField() - - sent_date = models.DateTimeField() - is_read = models.BooleanField(default = False) - is_deleted = models.BooleanField(default = False) - -class RoleRequest(models.Model): - """ A request sent by one user to the other. - Typically requesting to raise one's status. - """ - - uniq_key = models.CharField(max_length=20) - role = models.CharField(max_length=2, choices=ROLE_CHOICES) - is_accepted = models.BooleanField(default=False) - - message = models.TextField() - response = models.TextField() - - sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False) - sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", null = True, blank = True) - - sent_date = models.DateTimeField() - is_read = models.BooleanField(default = False) - is_deleted = models.BooleanField(default = False) - diff --git a/profile/templatetags/__init__.py b/profile/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/profile/templatetags/__init__.py +++ /dev/null diff --git a/profile/templatetags/user_tags.py b/profile/templatetags/user_tags.py deleted file mode 100644 index e03aa09..0000000 --- a/profile/templatetags/user_tags.py +++ /dev/null @@ -1,12 +0,0 @@ -from django import template - -register = template.Library() - -@register.filter -def notf_dsp(user): - - notf_cnt = user.notification_sent_to.filter(is_deleted=False, - is_read=False).count() - - return u'notifications(%s)'%notf_cnt if notf_cnt else u'notifications' - diff --git a/profile/tests.py b/profile/tests.py deleted file mode 100755 index 2247054..0000000 --- a/profile/tests.py +++ /dev/null @@ -1,23 +0,0 @@ -""" -This file demonstrates two different styles of tests (one doctest and one -unittest). These will both pass when you run "manage.py test". - -Replace these with more appropriate tests for your application. -""" - -from django.test import TestCase - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.failUnlessEqual(1 + 1, 2) - -__test__ = {"doctest": """ -Another way to test that 1 + 1 is equal to 2. - ->>> 1 + 1 == 2 -True -"""} - diff --git a/profile/urls.py b/profile/urls.py deleted file mode 100644 index 0949c66..0000000 --- a/profile/urls.py +++ /dev/null @@ -1,16 +0,0 @@ -from django.conf.urls.defaults import * - -from pytask.profile.views import view_profile, edit_profile,\ - browse_notifications, view_notification,\ - delete_notification, unread_notification - -urlpatterns = patterns('', - - (r'^view/$', view_profile), - (r'^edit/$', edit_profile), - (r'^notf/browse/$', browse_notifications), - (r'^notf/view/nid=(\w+)$', view_notification), - (r'^notf/del/nid=(\w+)$', delete_notification), - (r'^notf/unr/nid=(\w+)$', unread_notification), -) - diff --git a/profile/utils.py b/profile/utils.py deleted file mode 100644 index 84b5e00..0000000 --- a/profile/utils.py +++ /dev/null @@ -1,32 +0,0 @@ -from pytask.profile.models import Notification - -def get_notification(nid, user): - """ if notification exists, and belongs to the current user, return it. - else return None. - """ - - user_notifications = user.notification_sent_to.filter(is_deleted=False).order_by('sent_date') - current_notifications = user_notifications.filter(uniq_key=nid) - if user_notifications: - current_notification = current_notifications[0] - - try: - newer_notification = current_notification.get_next_by_sent_date(sent_to=user, is_deleted=False) - newest_notification = user_notifications.reverse()[0] - if newest_notification == newer_notification: - newest_notification = None - except Notification.DoesNotExist: - newest_notification, newer_notification = None, None - - try: - older_notification = current_notification.get_previous_by_sent_date(sent_to=user, is_deleted=False) - oldest_notification = user_notifications[0] - if oldest_notification == older_notification: - oldest_notification = None - except: - oldest_notification, older_notification = None, None - - return newest_notification, newer_notification, current_notification, older_notification, oldest_notification - - else: - return None, None, None, None, None diff --git a/profile/views.py b/profile/views.py deleted file mode 100755 index a8e48f4..0000000 --- a/profile/views.py +++ /dev/null @@ -1,149 +0,0 @@ -from django.shortcuts import render_to_response, redirect -from django.http import Http404 - -from django.contrib.auth.decorators import login_required -from django.core.context_processors import csrf -from django.views.decorators.csrf import csrf_protect - -from pytask.profile.forms import EditProfileForm -from pytask.profile.utils import get_notification - -@login_required -def view_profile(request): - """ Display the profile information. - """ - - user = request.user - profile = user.get_profile() - - context = {"user": user, - "profile": profile, - } - return render_to_response("profile/view.html", context) - -@login_required -def edit_profile(request): - """ Make only a few fields editable. - """ - - user = request.user - profile = user.get_profile() - - context = {"user": user, - "profile": profile, - } - - context.update(csrf(request)) - - if request.method == "POST": - form = EditProfileForm(request.POST, instance=profile) - - if form.is_valid(): - form.save() - return redirect("/profile/view") - else: - context.update({"form":form}) - return render_to_response("profile/edit.html", context) - else: - form = EditProfileForm(instance=profile) - context.update({"form":form}) - return render_to_response("profile/edit.html", context) - -@login_required -def browse_notifications(request): - """ get the list of notifications that are not deleted and display in - datetime order.""" - - user = request.user - - active_notifications = user.notification_sent_to.filter(is_deleted=False).order_by('sent_date').reverse() - - context = {'user':user, - 'notifications':active_notifications, - } - - return render_to_response('profile/browse_notifications.html', context) - -@login_required -def view_notification(request, nid): - """ get the notification depending on nid. - Display it. - """ - - user = request.user - newest, newer, notification, older, oldest = get_notification(nid, user) - - if not notification: - raise Http404 - - notification.is_read = True - notification.save() - - context = {'user':user, - 'notification':notification, - 'newest':newest, - 'newer':newer, - 'older':older, - 'oldest':oldest, - } - - return render_to_response('profile/view_notification.html', context) - -@login_required -def delete_notification(request, nid): - """ check if the user owns the notification and delete it. - """ - - user = request.user - newest, newer, notification, older, oldest = get_notification(nid, user) - - if not notification: - raise Http404 - - notification.is_deleted = True - notification.save() - - context = {'user':user, - 'notification':notification, - 'newest':newest, - 'newer':newer, - 'older':older, - 'oldest':oldest, - } - - if older: - redirect_url = "/profile/notf/view/nid=%s"%older.uniq_key - else: - redirect_url = "/profile/notf/browse" - - return redirect(redirect_url) - -@login_required -def unread_notification(request, nid): - - """ check if the user owns the notification and delete it. - """ - - user = request.user - newest, newer, notification, older, oldest = get_notification(nid, user) - - if not notification: - raise Http404 - - notification.is_read = False - notification.save() - - context = {'user':user, - 'notification':notification, - 'newest':newest, - 'newer':newer, - 'older':older, - 'oldest':oldest, - } - - if older: - redirect_url = "/profile/notf/view/nid=%s"%older.uniq_key - else: - redirect_url = "/profile/notf/browse" - - return redirect(redirect_url) |