From f673ad41c053e7c7458c9429ea771e3355a304c3 Mon Sep 17 00:00:00 2001 From: Subhodip Biswas Date: Mon, 22 Oct 2012 14:41:18 +0530 Subject: [PATCH 1/3] field for mobile number added --- chaloBEST/settings.py | 22 ++++++++- chaloBEST/urls.py | 9 ++-- chaloBEST/users/forms.py | 48 ++++++++++--------- chaloBEST/users/models.py | 3 ++ .../templates/profiles/profile_detail.html | 1 + chaloBEST/users/views.py | 43 +++++++++++++++++ 6 files changed, 100 insertions(+), 26 deletions(-) diff --git a/chaloBEST/settings.py b/chaloBEST/settings.py index 9fc15ca..b0a104a 100644 --- a/chaloBEST/settings.py +++ b/chaloBEST/settings.py @@ -63,6 +63,22 @@ MEDIA_URL = '/media/' STATIC_URL = '/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 # trailing slash. @@ -101,6 +117,8 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'userena.middleware.UserenaLocaleMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware' ) @@ -180,9 +198,11 @@ LOGIN_REDIRECT_URL ='/accounts/%(username)s/' LOGIN_URL = '/accounts/signin/' LOGOUT_URL = '/accounts/signout/' #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_GRAVATAR=True +USERENA_USE_MESSAGES = True USERENA_MUGSHOT_DEFAULT='monsterid' ANONYMOUS_USER_ID = -1 diff --git a/chaloBEST/urls.py b/chaloBEST/urls.py index a19027c..dd653ec 100644 --- a/chaloBEST/urls.py +++ b/chaloBEST/urls.py @@ -7,6 +7,7 @@ admin.autodiscover() from feeds import RouteFeed #import ox.django.api.urls #import mumbai +from users.forms import SignupFormExtra urlpatterns = patterns('', @@ -43,10 +44,12 @@ urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), (r'^matchstops/$', 'mumbai.views.fuzzystops'), (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')), - #(r'^accounts/signup/$', 'userena.views.signup', - #{'signup_form': SignupFormExtra}), - + url(r'^messages/',include('userena.contrib.umessages.urls')), diff --git a/chaloBEST/users/forms.py b/chaloBEST/users/forms.py index 6a867ac..68ca1bf 100644 --- a/chaloBEST/users/forms.py +++ b/chaloBEST/users/forms.py @@ -2,28 +2,32 @@ from django import forms from django.utils.translation import ugettext_lazy as _ from userena.forms import SignupForm +from users.models import UserProfile class SignupFormExtra(SignupForm): - first_name = forms.CharField(label = _(u'First name'), - max_length =30, - required=False) - last_name = forms.CharField(label = _(u'Last name'), - max_length = 30, - required=False) - mobile_number = forms.IntegerField(label = _(u'Mobile number'), - max_value =9999999999, - required=False) - def __init__(self, *args, **kw): - super(SignupFormExtra, self).__init__(*args, **kw) - new_order = self.fields.keyOrder[:-3] - new_order.insert(0, 'first_name') - new_order.insert(1, 'last_name') - new_order.insert(2, 'mobile_number') - self.fields.KeyOrder = new_order + #first_name = forms.CharField(label = _(u'First name'), + # max_length =30, + # required=False) + #last_name = forms.CharField(label = _(u'Last name'), + # max_length = 30, + # required=False) + mobile_number = forms.CharField(label = _(u'mobile number'), + max_length =10, + required=True) +# def __init__(self, *args, **kw): +# super(SignupFormExtra, self).__init__(*args, **kw) +# new_order = self.fields.keyOrder[:-3] +# new_order.insert(0, 'first_name') +# new_order.insert(1, 'last_name') +# new_order.insert(2, 'mobile_number') +# self.fields.KeyOrder = new_order def save(self): - new_user = super(SignupFormExtra, self).save() - new_user.first_name = self.cleaned_data['first_name'] - new_user.last_name = self.cleaned_data['last_name'] - new_user.mobile_number = self.cleaned_data['mobile_number'] - new_user.save() - return new_user() + new_user= super(SignupFormExtra, self).save() + user_profile = new_user.get_profile() + #user_profile.first_name = self.cleaned_data['first_name'] + #user_profile.last_name = self.cleaned_data['last_name'] + user_profile.mobile_number = self.cleaned_data['mobile_number'] + #user_profile.mobile_number = UserProfile.objects.get_or_create(name=user_profile.mobile_number) + + user_profile.save() + return new_user diff --git a/chaloBEST/users/models.py b/chaloBEST/users/models.py index 6535d9c..ecaa409 100644 --- a/chaloBEST/users/models.py +++ b/chaloBEST/users/models.py @@ -30,7 +30,10 @@ class UserProfile(UserenaLanguageBaseProfile): website = models.URLField(_('website'), blank=True, verify_exists=True) location = models.CharField(_('location'), max_length=255, blank=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) + @property def age(self): if not self.birth_date: return False diff --git a/chaloBEST/users/templates/profiles/profile_detail.html b/chaloBEST/users/templates/profiles/profile_detail.html index 6fb660c..cd9ed56 100644 --- a/chaloBEST/users/templates/profiles/profile_detail.html +++ b/chaloBEST/users/templates/profiles/profile_detail.html @@ -85,6 +85,7 @@

Fax:
{{ profile.fax }}

+

Hello!!

{% endif %} {% endblock content %} diff --git a/chaloBEST/users/views.py b/chaloBEST/users/views.py index 60f00ef..e0494a8 100644 --- a/chaloBEST/users/views.py +++ b/chaloBEST/users/views.py @@ -1 +1,44 @@ # 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 + + From c8f7d84d2aa102b290f085b365c0e80ddd991017 Mon Sep 17 00:00:00 2001 From: Subhodip Biswas Date: Sun, 4 Nov 2012 20:10:14 +0530 Subject: [PATCH 2/3] Profile has mobile number now --- chaloBEST/users/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chaloBEST/users/forms.py b/chaloBEST/users/forms.py index 68ca1bf..ae549d5 100644 --- a/chaloBEST/users/forms.py +++ b/chaloBEST/users/forms.py @@ -11,7 +11,7 @@ class SignupFormExtra(SignupForm): #last_name = forms.CharField(label = _(u'Last name'), # max_length = 30, # required=False) - mobile_number = forms.CharField(label = _(u'mobile number'), + mobile_number = forms.CharField(label = _(u'Mobile number'), max_length =10, required=True) # def __init__(self, *args, **kw): From e4a38f006d046f17d2a8896bf72198144301c60b Mon Sep 17 00:00:00 2001 From: Carolien Klep Date: Mon, 5 Nov 2012 17:25:33 +0530 Subject: [PATCH 3/3] fixed the header links in css and changed tiny bit in SMS page --- chaloBEST/mumbai/static/css/content.css | 3 ++- chaloBEST/mumbai/static/css/style.css | 12 ++++++------ chaloBEST/templates/innov/SMS.html | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/chaloBEST/mumbai/static/css/content.css b/chaloBEST/mumbai/static/css/content.css index f669568..3cb670d 100644 --- a/chaloBEST/mumbai/static/css/content.css +++ b/chaloBEST/mumbai/static/css/content.css @@ -11,7 +11,7 @@ .foot .right img{display:inline; float:right; padding:5px 2px 5px 5px; width:15px; height:15px;} /* primary navigation */ -.banner {background:url('img/header_bg.png') repeat-x; background-size:contain;} /* background image for the global nav + text logo bar */ +.banner {background:url('../images/header_bg.png') repeat-x; background-size:contain;} /* background image for the global nav + text logo bar */ .navlink a {color:#fff;} .sms { float:right; background-color:green; border:2px solid green;} .trip {float:left; background-color:#BEDB74; border:2px solid #BEDB74;} @@ -228,6 +228,7 @@ span.half {display:inline; float:left; margin:0; padding:0; width:50%;} .highlight2 ul{font-size:1em; padding-left:6%; list-style-type: none;} .highlight2 li {padding-bottom:12px;} +.highlight2 li span.small {font-size:0.8em; font-style:normal !important;} .highlight p span,.highlight ul span, .highlight2 p span,.highlight2 ul span{font-style:italic;} .actionbutton {color:red; padding:2px 10px ; background-color:#FBDD09 !important; border:2px solid yellow; border-radius:15px; text-align:center !important;} diff --git a/chaloBEST/mumbai/static/css/style.css b/chaloBEST/mumbai/static/css/style.css index 83e9538..b3ed59c 100644 --- a/chaloBEST/mumbai/static/css/style.css +++ b/chaloBEST/mumbai/static/css/style.css @@ -178,7 +178,7 @@ Change widths as necessary .nav {height:85px; margin:0;} .foot {height:50px;} - .logoimg {display:block; float:left; height: 60px; width:32%; background:URL('img/chalobestlogoS.png') #deeebf no-repeat; background-position: 4px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} + .logoimg {display:block; float:left; height: 60px; width:32%; background:URL('../images/chalobestlogoS.png') #deeebf no-repeat; background-position: 4px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} .global{display:block; float:right; width:65.95%; height:30px; padding-right:0.99%; color:#FBDD09;} .logotext {display:block; float:left; width:100%; height:30px; margin:0; padding:0;} .logotext img {height:100%;} @@ -267,7 +267,7 @@ Change widths as necessary .nav {height:55px; margin:0;} .foot {height:50px;} - .logoimg {display:block; float:left; height: 55px; width:28%; background:URL('img/chalobestlogoS.png') #deeebf no-repeat; background-position: 12px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} + .logoimg {display:block; float:left; height: 55px; width:28%; background:URL('../images/chalobestlogoS.png') #deeebf no-repeat; background-position: 12px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} .global{display:block; float:left; width:69.95%; height:30px; padding-right:0.99%;} .logotext {display:block; float:left; width:51.01%; height:25px; margin:3px 0 0 0;} .globallinks{display:block; float:right; width:48%; height:30px; padding:10px 0.99% 0 0; background-color:inherit; vertical-align:bottom;} @@ -351,7 +351,7 @@ Change widths as necessary .nav {height:60px; margin:0;} .foot {height:50px;} - .logoimg {display:block; float:left; height: 60px; width:18%; background:URL('img/chalobestlogoS.png') #deeebf no-repeat; background-position: 12px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} + .logoimg {display:block; float:left; height: 60px; width:18%; background:URL('../images/chalobestlogoS.png') #deeebf no-repeat; background-position: 12px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} .global{display:block; float:left; width:79.95%; height:30px; padding-right:0.99%;} .logotext {display:block; float:left; height:30px; margin:0; padding:0;} .globallinks{display:block; float:right; width:30%; height:30px; padding:10px 0.99% 0 0; background-color:inherit; vertical-align:bottom;} @@ -434,7 +434,7 @@ Change widths as necessary .nav {height:60px; margin:0;} .foot {height:50px;} - .logoimg {display:block; float:left; height: 60px; width:15%; background:URL('img/chalobestlogoS.png') #deeebf no-repeat; background-position: 12px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} + .logoimg {display:block; float:left; height: 60px; width:15%; background:URL('../images/chalobestlogoS.png') #deeebf no-repeat; background-position: 12px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} .global{display:block; float:left; width:82.95%; height:30px; padding-right:0.99%;} .logotext {display:block; float:left; width:23.01%; height:30px; margin:0; padding:0;} .globallinks{display:block; float:right; width:30%; height:30px; padding:10px 0.99% 0 0; background-color:inherit; vertical-align:bottom;} @@ -523,7 +523,7 @@ Change widths as necessary .nav {height:70px; margin:0;} .foot {height:50px;} - .logoimg {display:block; float:left; height: 80px; width:12.33%; background:URL('img/chalobestlogoM.png') #deeebf no-repeat; background-position: 12px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} + .logoimg {display:block; float:left; height: 80px; width:12.33%; background:URL('../images/chalobestlogoM.png') #deeebf no-repeat; background-position: 12px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} .global{display:block; float:left; margin:0; width:85.65%; height:40px;} .logotext {display:block; float:left; width:23.01%; height:40px; margin:0; padding:0;} .globallinks{display:block; float:right; width:30%; height:30px; padding:17px 0.99% 0 0; background-color:inherit; vertical-align:bottom;} @@ -609,7 +609,7 @@ Change widths as necessary .nav {height:80px; margin:0;} .foot {height:50px;} - .logoimg {display:block; float:left; height:80px; width:10.33%; background:URL('img/chalobestlogo.png') #deeebf no-repeat; background-position: 12px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} + .logoimg {display:block; float:left; height:80px; width:10.33%; background:URL('../images/chalobestlogo.png') #deeebf no-repeat; background-position: 12px top; overflow:hidden; margin:0; padding:0 0 0 1.03%;} .global{display:block; float:left; width:87.65%; height:50px; margin:0;} .logotext {display:block; float:left; width:23.01%; height:50px;} .globallinks{display:block; float:right; width:30%; height:30px; padding:25px 0.99% 0 0; background-color:inherit; vertical-align:bottom;} diff --git a/chaloBEST/templates/innov/SMS.html b/chaloBEST/templates/innov/SMS.html index 8fecf34..6ffbacf 100644 --- a/chaloBEST/templates/innov/SMS.html +++ b/chaloBEST/templates/innov/SMS.html @@ -149,9 +149,9 @@

ChaloBEST SMS

    -
  • Directions:
    "[stop name] to [stop name]"
  • -
  • Buses at your stop:
    "[stop name]"
  • -
  • Bus stop list & frequency:
    "[number]"
  • +
  • Directions:
    [stop name]   to   [stop name]
  • +
  • Buses at your stop:
    [stop name]
  • +
  • Bus stop list & frequency:
    [bus number]
  • SMS 9619524420