field for mobile number added

This commit is contained in:
Subhodip Biswas 2012-10-22 14:41:18 +05:30
parent 3bc70a9cf8
commit f673ad41c0
6 changed files with 100 additions and 26 deletions

View File

@ -63,6 +63,22 @@ MEDIA_URL = '/media/'
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATIC_ROOT = join(PROJECT_ROOT, 'static') STATIC_ROOT = join(PROJECT_ROOT, 'static')
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_ROOT, 'mumbai/static'),
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash. # trailing slash.
@ -101,6 +117,8 @@ MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'userena.middleware.UserenaLocaleMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware' 'debug_toolbar.middleware.DebugToolbarMiddleware'
) )
@ -180,9 +198,11 @@ LOGIN_REDIRECT_URL ='/accounts/%(username)s/'
LOGIN_URL = '/accounts/signin/' LOGIN_URL = '/accounts/signin/'
LOGOUT_URL = '/accounts/signout/' LOGOUT_URL = '/accounts/signout/'
#LOGIN_REDIRECT_URL = '/profiles/profile/' #LOGIN_REDIRECT_URL = '/profiles/profile/'
USERENA_DISABLE_PROFILE_LIST = False #USERENA_DISABLE_PROFILE_LIST = False
USERENA_DISABLE_PROFILE_LIST = True
USERENA_MUGSHOT_SIZE = 140 USERENA_MUGSHOT_SIZE = 140
USERENA_MUGSHOT_GRAVATAR=True USERENA_MUGSHOT_GRAVATAR=True
USERENA_USE_MESSAGES = True
USERENA_MUGSHOT_DEFAULT='monsterid' USERENA_MUGSHOT_DEFAULT='monsterid'
ANONYMOUS_USER_ID = -1 ANONYMOUS_USER_ID = -1

View File

@ -7,6 +7,7 @@ admin.autodiscover()
from feeds import RouteFeed from feeds import RouteFeed
#import ox.django.api.urls #import ox.django.api.urls
#import mumbai #import mumbai
from users.forms import SignupFormExtra
urlpatterns = patterns('', urlpatterns = patterns('',
@ -43,9 +44,11 @@ urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)), (r'^admin/', include(admin.site.urls)),
(r'^matchstops/$', 'mumbai.views.fuzzystops'), (r'^matchstops/$', 'mumbai.views.fuzzystops'),
(r'^fuzzystops_edit/$', 'mumbai.views.fuzzystops_edit'), (r'^fuzzystops_edit/$', 'mumbai.views.fuzzystops_edit'),
# url(r'^accounts/', include('userena.urls')),
url(r'^accounts/signup/$',
'userena.views.signup',
{'signup_form': SignupFormExtra}),
url(r'^accounts/', include('userena.urls')), url(r'^accounts/', include('userena.urls')),
#(r'^accounts/signup/$', 'userena.views.signup',
#{'signup_form': SignupFormExtra}),
url(r'^messages/',include('userena.contrib.umessages.urls')), url(r'^messages/',include('userena.contrib.umessages.urls')),

View File

@ -2,28 +2,32 @@ from django import forms
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from userena.forms import SignupForm from userena.forms import SignupForm
from users.models import UserProfile
class SignupFormExtra(SignupForm): class SignupFormExtra(SignupForm):
first_name = forms.CharField(label = _(u'First name'), #first_name = forms.CharField(label = _(u'First name'),
max_length =30, # max_length =30,
required=False) # required=False)
last_name = forms.CharField(label = _(u'Last name'), #last_name = forms.CharField(label = _(u'Last name'),
max_length = 30, # max_length = 30,
required=False) # required=False)
mobile_number = forms.IntegerField(label = _(u'Mobile number'), mobile_number = forms.CharField(label = _(u'mobile number'),
max_value =9999999999, max_length =10,
required=False) required=True)
def __init__(self, *args, **kw): # def __init__(self, *args, **kw):
super(SignupFormExtra, self).__init__(*args, **kw) # super(SignupFormExtra, self).__init__(*args, **kw)
new_order = self.fields.keyOrder[:-3] # new_order = self.fields.keyOrder[:-3]
new_order.insert(0, 'first_name') # new_order.insert(0, 'first_name')
new_order.insert(1, 'last_name') # new_order.insert(1, 'last_name')
new_order.insert(2, 'mobile_number') # new_order.insert(2, 'mobile_number')
self.fields.KeyOrder = new_order # self.fields.KeyOrder = new_order
def save(self): def save(self):
new_user = super(SignupFormExtra, self).save() new_user= super(SignupFormExtra, self).save()
new_user.first_name = self.cleaned_data['first_name'] user_profile = new_user.get_profile()
new_user.last_name = self.cleaned_data['last_name'] #user_profile.first_name = self.cleaned_data['first_name']
new_user.mobile_number = self.cleaned_data['mobile_number'] #user_profile.last_name = self.cleaned_data['last_name']
new_user.save() user_profile.mobile_number = self.cleaned_data['mobile_number']
return new_user() #user_profile.mobile_number = UserProfile.objects.get_or_create(name=user_profile.mobile_number)
user_profile.save()
return new_user

View File

@ -30,7 +30,10 @@ class UserProfile(UserenaLanguageBaseProfile):
website = models.URLField(_('website'), blank=True, verify_exists=True) website = models.URLField(_('website'), blank=True, verify_exists=True)
location = models.CharField(_('location'), max_length=255, blank=True) location = models.CharField(_('location'), max_length=255, blank=True)
birth_date = models.DateField(_('birth date'), blank=True, null=True) birth_date = models.DateField(_('birth date'), blank=True, null=True)
# about_me = models.TextField(_('about me'), blank = True)
mobile_number = models.CharField(_('mobile number'), blank = True, max_length=10)
about_me = models.TextField(_('about me'), blank = True) about_me = models.TextField(_('about me'), blank = True)
@property @property
def age(self): def age(self):
if not self.birth_date: return False if not self.birth_date: return False

View File

@ -85,6 +85,7 @@
<p><strong>Fax:</strong><br> <p><strong>Fax:</strong><br>
{{ profile.fax }} {{ profile.fax }}
</p> </p>
<p><strong>Hello!!</strong></p>
{% endif %} {% endif %}
{% endblock content %} {% endblock content %}

View File

@ -1 +1,44 @@
# Create your views here. # Create your views here.
from django.core.management import setup_environ
import settings
setup_environ(settings)
from users.models import UserProfile
from django.shortcuts import redirect
from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404
from django.http import HttpResponse
from django.template import RequestContext
import django.utils.simplejson as json
import os
import urllib2
#from users.models import *
from StringIO import StringIO
#from django.http import HttpResponse
from django.contrib.auth.models import User
def getsmsfeed(request):
current_user = request.user
print current_user
users = user.objects.all()
apireq = urllib2.Request('http://sms.chalobest.in/messages_json/?phone_no='+mobilenumber)
apires = urllib2.urlopen(apireq)
try:
#jsonres = json.dumps(apires,sort_keys=True)
##print jsonres.__class__
#print apires
jstr = json.load(apires)
l = (json.dumps(jstr,sort_keys=True)).split("}")
#print l
sjstr = sorted(l, key=lambda l:l[0])
#print sjstr[0]['datetime']
#k = [i for i, j, k in jstr[1]]
print sjstr[-5:]
#print jstr.get('text')
#print l.__class__
except ValueError,e:
print e