merged ..

This commit is contained in:
Johnson Chetty 2012-08-30 12:41:20 +02:00
commit 6be81cd5eb
16 changed files with 563 additions and 22 deletions

View File

@ -134,30 +134,58 @@ INSTALLED_APPS = (
#'socialregistration.contrib.facebook',
'emailconfirmation',
# 'uni_form',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.openid',
'allauth.socialaccount.providers.facebook',
# 'allauth',
# 'allauth.account',
# 'allauth.socialaccount',
# 'allauth.socialaccount.providers.twitter',
# 'allauth.socialaccount.providers.openid',
# 'allauth.socialaccount.providers.facebook',
#'allauth.socialaccount.providers.google',
'users',
'profiles',
'userena',
'guardian',
'easy_thumbnails',
'south',
'django_extensions',
'userena.contrib.umessages',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'django.contrib.auth.context_processors.auth',
"allauth.context_processors.allauth",
"allauth.account.context_processors.account"
#"allauth.context_processors.allauth",
#"allauth.account.context_processors.account",
"django.contrib.messages.context_processors.messages"
)
AUTHENTICATION_BACKENDS = (
"allauth.account.auth_backends.AuthenticationBackend",
# "allauth.account.auth_backends.AuthenticationBackend",
"userena.backends.UserenaAuthenticationBackend",
"guardian.backends.ObjectPermissionBackend",
"django.contrib.auth.backends.ModelBackend",
)
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST ='smtp.gmail.com'
EMAIL_HOST_USER = 'subhodipbiswas@gmail.com'
EMAIL_HOST_PASSWORD ='doaxhentai'
EMAIL_HOST_USER = 'abc@abc.com'
EMAIL_HOST_PASSWORD ='somepassword'
EMAIL_PORT =587
EMAIL_USE_TLS =True
SERVER_EMAIL = EMAIL_HOST_USER
DEFAULT_FROM_EMAIL=EMAIL_HOST_USER
AUTH_PROFILE_MODULE = "users.UserProfile"
#AUTH_PROFILE_MODULE = 'profiles.Profile'
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_MUGSHOT_SIZE = 140
USERENA_MUGSHOT_GRAVATAR=True
USERENA_MUGSHOT_DEFAULT='monsterid'
ANONYMOUS_USER_ID = -1
try:
from local_settings import *
except:

View File

@ -42,10 +42,10 @@ body,html {
{% block body %}
<ul>
{% if user.is_authenticated %}
<li><a href="{% url account_logout %}">Sign Out</a></li>
<li><a href="{% url userena_signout %}">Sign Out</a></li>
{% else %}
<li><a href="{% url account_login %}">Sign In</a></li>
<li><a href="{% url account_signup %}">Sign Up</a></li>
<li><a href="{% url userena_signin %}">Sign In</a></li>
<li><a href="{% url userena_signup %}">Sign Up</a></li>
{% endif %}
</ul>
{% block content %}

View File

@ -11,10 +11,10 @@
{% block body %}
<ul>
{% if user.is_authenticated %}
<li><a href="{% url account_logout %}">Sign Out</a></li>
<li><a href="{% url userena_signout %}">Sign Out</a></li>
{% else %}
<li><a href="{% url account_login %}">Sign In</a></li>
<li><a href="{% url account_signup %}">Sign Up</a></li>
<li><a href="{% url userena_signin %}">Sign In</a></li>
<li><a href="{% url userena_signup %}">Sign Up</a></li>
{% endif %}
</ul>
{% block content %}

View File

@ -25,7 +25,7 @@ urlpatterns = patterns('',
# (r'^stop/(?P<slug>.*?)/georss/$', StopFeed()),
(r'^buseditor/$', 'mumbai.views.buseditor'),
(r'^editstops/$', 'mumbai.views.editstops'),
(r'^accounts/', include('allauth.urls')),
#(r'^accounts/', include('allauth.urls')),
(r'^1.0/', include('mumbai.apiurls')),
#url(r'^login/', include('socialregistration.urls',namespace='socialregistration')),
# Uncomment the admin/doc line below to enable admin documentation:
@ -35,6 +35,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')),
#(r'^accounts/signup/$', 'userena.views.signup',
#{'signup_form': SignupFormExtra}),
url(r'^messages/',include('userena.contrib.umessages.urls')),
)

View File

29
chaloBEST/users/forms.py Normal file
View File

@ -0,0 +1,29 @@
from django import forms
from django.utils.translation import ugettext_lazy as _
from userena.forms import SignupForm
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
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()

60
chaloBEST/users/models.py Normal file
View File

@ -0,0 +1,60 @@
from django.db import models
from django.contrib.auth.models import User
from userena.models import UserenaBaseProfile
from userena.models import UserenaLanguageBaseProfile
#from django.contrib.auth.models import User
#from django.contrib.auth.models import User
#from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from django.db.models.signals import post_save
import datetime
# Create your models here.
class UserProfile(UserenaLanguageBaseProfile):
GENDER_CHOICES =(
(1, _('Male')),
(2, _('Female')),
)
# user = models.ForeignKey(User, unique=True)
# url - models.URLField("Website", blank=True)
# company = models.CharField(max_length=50, blank=True)
user = models.ForeignKey(User,
unique=True,
verbose_name =('user'),
related_name = 'profile')
gender = models.PositiveSmallIntegerField(_('gender'),
choices=GENDER_CHOICES,
blank = True,
null=True)
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)
@property
def age(self):
if not self.birth_date: return False
else:
today = datetime.date.today()
try:
birthday = self.birth_date.replace(year=today.year)
except ValueError:
day = today.day -1 if today.day != 1 else today.day + 2
birthday = self.birth_date.replace(year=today.year, day = day)
if birthday > today: return today.year - self.birth_date.year - 1
else: return today.year - self.birth_date.year
#def create_user_profile(sender, instance, created, **kwargs):
# if created:
# UserProfile.objects.create(user=instance)
#post_save.connect(create_user_profile, sender=User)
#def create_profile(sender, **kw):
# user = kw["instance"]
# if kw["created"]:
# up = UserProfile(user=user, gender=1,location="test")
# up.save()
#post_save.connect(create_profile, sender=User)
#User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])

View File

@ -0,0 +1,29 @@
{% load thumbnail %}
{% comment %}
If profile has an avatar, show it.
If user is viewing their own list and they don't have an avatar,
show them the Add Photo button. Otherwise show generic avatar.
{% endcomment %}
<div class="avatar">
{% if profile.avatar %}
{% thumbnail profile.avatar "100x100" crop="center" as im %}
<a href="{% url list_view profile.user.username %}"><img src="{{im.url}}" width="{{im.width}}" height="{{im.height}}" alt="{{profile}}'s avatar image" /></a>
{% endthumbnail %}
{% else %}
{% if profile == user.get_profile %}
<a href="{% url profiles_edit_profile %}"><img src="{{ MEDIA_URL }}images/no-photo.png" width="100" height="100" alt="Please add an avatar to your profile."></a>
{% else %}
<a href="{% url list_view profile.user.username %}"><img src="{{ STATIC_URL }}images/user_default_medium.png" width="100" height="100" alt="Generic avatar"></a>
{% endif %}
{% endif %}
</div>

View File

@ -0,0 +1,35 @@
{% extends "main_template.html" %}
{% block content%}
<script>
$(document).ready(function() {
$("#profile").addClass("active");
});
</script>
<div class="description">
<h2>Create Profile:</h2>
</div>
<h2>{{ user|capfirst }}, before we begin, lets set some of your account preferences. These can be changed at any time.</h2>
<form method="POST" action="">
<p>
Default League to bet: <span class="required">*</span> {{ form.pref_sport }}
{% for error in form.pref_sport.errors %}
{{ error|escape }}
{% endfor %}
</p>
<p>
Default Number of games to bet: <span class="required">*</span> {{ form.pref_num_games }}
{% for error in form.pref_num_games.errors %}
{{ error|escape }}
{% endfor %}
</p>
<input type="submit" name="submit" class="submit" value="Create Profile">
</form>
{% endblock %}

View File

@ -0,0 +1,153 @@
{% extends "base.html" %}
{% load thumbnail %}
{% block title %}Edit Profile{% endblock %}
{% block extrahead %}
{# Bring in jquery-ui and its theme #}
<link type="text/css" href="{{STATIC_URL}}js/jquery-ui/css/eggplant/jquery-ui-1.8rc1.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="{{STATIC_URL}}js/jquery-ui/js/jquery-ui-1.8rc1.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
jQuery("#formatting").dialog({
bgiframe: true, autoOpen: false, height: 570, width: 550, modal: false
});
jQuery("#adding_media").dialog({
bgiframe: true, autoOpen: false, height: 500, width: 650, modal: false
});
});
</script>
{# form.media #} {# -- js for tinymce #}
<script type="text/javascript" src="/static/js/tiny_mce/tiny_mce.js"></script>
{% endblock %}
{% block content %}
{# Hidden divs - revealed by jquery dialog #}
<div id="adding_media" title="Adding images and video">
{% include 'media_instr.html' %}
</div>
{% if form.errors %}
<ul id="messagelist">
<p>The following required fields are missing:</p>
{% for error in form.errors %}
<li class="error">{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
{# Reusable avatar code #}
{% if not profile.avatar %}
{% include 'profiles/avatar.html' %}
{% endif %}
<h2>Edit profile for {{ user.first_name }} {{ user.last_name }} ({{user}})</h2>
<div class="clear"></div>
<h1>Tell us about yourself...</h1>
<form enctype="multipart/form-data" method="post" action="" style="margin-top:20px;">
{% csrf_token %}
<div class="fieldWrapper">
{{form.avatar.label_tag}}
{% if profile.avatar %}
{% thumbnail profile.avatar "100x100" crop="center" as im %}
<a href="{% url list_view profile.user.username %}"><img src="{{im.url}}" width="{{im.width}}" height="{{im.height}}" alt="{{profile}}'s avatar image" /></a>
{% endthumbnail %}<br />
{# <img src="{% thumbnail profile.avatar 100x100 quality=70 %}" /> <br /> #}
{% endif %}
{{form.avatar}}<br />
{{form.avatar.help_text|safe}}
</div>
<div class="fieldWrapper">
{{form.about.label_tag}}
{{form.about.help_text|safe}}<br />
<a style="margin-right:30px;" href="#" onclick="jQuery('#adding_media').dialog('open'); return false">&#x238B; You can add images and video to your profile!</a>
{{form.about}}
</div>
<div class="fieldWrapper">
{{form.email.label_tag}}
{{form.email}}<br />
{{form.email.help_text}}
</div>
<div class="fieldWrapper">
{{form.city.label_tag}}
{{form.city}}
</div>
<div class="fieldWrapper">
{{form.state.label_tag}}
{{form.state}}
</div>
<div class="fieldWrapper">
{{form.country.label_tag}}
{{form.country}}
</div>
<div class="fieldWrapper">
{{form.twitter.label_tag}}
{{form.twitter}}<br />
{{form.twitter.help_text|safe}}
</div>
<div class="fieldWrapper">
{{form.facebook.label_tag}}
{{form.facebook}}<br />
{{form.facebook.help_text|safe}}
</div>
<div class="fieldWrapper inline">
{{form.allow_contact}} {{form.allow_contact.label_tag}}
</div>
<div class="fieldWrapper inline">
{{form.email_updates}} {{form.email_updates.label_tag}}
</div>
<div class="fieldWrapper inline">
{{form.email_on_follow}} {{form.email_on_follow.label_tag}}
</div>
<div class="fieldWrapper inline">
{{form.email_site_news}} {{form.email_site_news.label_tag}}
</div>
<p><input class="button blue" type="submit" value="Update profile" /> </p>
<p>
<a href="/accounts/password/change/" class="button small blue">&raquo; Change password &laquo;</a>
<a href="{% url profile_settings %}" class="button small blue">&raquo; Account settings &laquo;</a>
<a href="{% url account_del %}" class="button small blue">&raquo; Delete account &laquo;</a>
</p>
</form>
{% endblock content %}

View File

@ -0,0 +1,72 @@
{% extends "base.html" %}
{% load thumbnail %}
{% block title %}Edit Profile Settings{% endblock %}
{% block content %}
{% if form.errors %}
<ul id="messagelist">
<p>The following required fields are missing:</p>
{% for error in form.errors %}
<li class="error">{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
<h2>Edit settings for {{ user.first_name }} {{ user.last_name }} ({{user}})</h2>
<div class="clear"></div>
<form enctype="multipart/form-data" method="post" action="" style="margin-top:20px;">
{% csrf_token %}
<p>We recommend keeping all of these settings enabled. <br />
Don't worry - none of them will result in a ton of email!</p>
<div class="fieldWrapper inline">
{{form.use_full_name}} {{form.use_full_name.label_tag}}<br />
<span style="margin-left:25px;">{{form.use_full_name.help_text}}</span>
</div>
<div class="fieldWrapper inline">
{{form.email_updates}} {{form.email_updates.label_tag}}
</div>
<div class="fieldWrapper inline">
{{form.email_on_follow}} {{form.email_on_follow.label_tag}}
</div>
<div class="fieldWrapper inline">
{{form.email_on_copy}} {{form.email_on_copy.label_tag}}
</div>
<div class="fieldWrapper inline">
{{form.email_site_news}} {{form.email_site_news.label_tag}}
</div>
<div class="fieldWrapper inline">
{{form.allow_contact}} {{form.allow_contact.label_tag}}
</div>
<div class="fieldWrapper inline">
{{form.enable_comments}} {{form.enable_comments.label_tag}}
</div>
<p style="margin-top:30px;"><input class="button blue" type="submit" value="Update settings" /> </p>
<p>
<a href="/accounts/password/change/" class="button medium green">&raquo; Change my password &laquo;</a>
<a href="{% url profiles_edit_profile %}" class="button medium green">&raquo; Update profile &laquo;</a>
</p>
</form>
{% endblock content %}

View File

@ -0,0 +1,91 @@
{% extends "base.html" %}
{% block extrahead %}
<script type="text/javascript" src="http://scripts.embed.ly/embedly.js" ></script>
<script type="text/javascript">
// set custom embedly defaults
// More customizations at http://api.embed.ly/tools/script
var embedly_maxWidth = 600;
var embedly_maxHeight = 600;
</script>
{% endblock %}
{% block title %} {{ user.first_name }} {{ user.last_name }}{% endblock %}
{% block content %}
{{block.super}}
{% ifequal user profile.user %}
<p>
<a href="{% url profiles_edit_profile %}" class="button blue">Edit my profile</a>
<a href="{% url profile_settings %}" class="button blue">Account settings</a>
</p>
{% endifequal %}
{# Reusable avatar code #}
{% include 'profiles/avatar.html' %}
<h2><a href="{% url list_view profile.user.username %}">{{ profile }}</a></h2>
<p class="smalltop" style="float:left;margin-right:70px;">
{% if profile.city %}
{{ profile.city }}, {{ profile.state }}, {{ profile.country }} <br />
{% endif %}
{% if profile.allow_contact %}
<a href="{% url contact_form profile.user %}">Contact {{ profile.user.first_name }} </a>
<br />
{% endif %}
<a href="/feeds/people/{{profile.user}}"><img src="{{STATIC_URL}}images/feed-icon-14x14.png" width="12" height="12" alt="Feed Icon 14x14"> <span class="minor">{{profile.user.first_name}}'s feed</span></a>
</p>
<div class="clear"></div>
{% if profile.about %}
<div id="oembed" class="profile">
{{profile.about|safe}}
</div>
{% else %}
<p style="margin-top:10px;">No profile information available</p>
{% endif %}
</p>
{% if profile.twitter %}
<p><strong>Twitter:</strong>
<a href="http://twitter.com/{{ profile.twitter }}">{{ profile.twitter }}</a>
</p>
{% endif %}
{% if profile.facebook %}
<p><strong>Facebook:</strong>
<a href="http://facebook.com/{{ profile.facebook }}">{{ profile.facebook }}</a>
</p>
{% endif %}
{% if profile.fax %}
<p><strong>Fax:</strong><br>
{{ profile.fax }}
</p>
{% endif %}
{% endblock content %}

View File

@ -0,0 +1,15 @@
{% extends "base.html" %}
{% block title %}Contact info for {{ user.first_name }} {{ user.last_name }}{% endblock %}
{% block content %}
{{block.super}}
{% for p in object_list %}
<a href="{% url profiles_profile_detail p.user %}">{{ p }}</a><br />
{% endfor %}
{% endblock content %}

16
chaloBEST/users/tests.py Normal file
View File

@ -0,0 +1,16 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this 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.assertEqual(1 + 1, 2)

1
chaloBEST/users/views.py Normal file
View File

@ -0,0 +1 @@
# Create your views here.

View File

@ -1,5 +1,7 @@
Django==1.4.1
PIL==1.1.7
RapidSMS==0.9.6a
South==0.7.5
-e git://github.com/schuyler/arrest.git@0017837a45bcb31786f953fba976d454ae684ecc#egg=arrest-dev
chardet==1.0.1
django-allauth==0.5.0
@ -7,14 +9,18 @@ django-avatar==1.0.5
django-debug-toolbar==0.9.4
django-email-confirmation==0.2
-e git://github.com/bit/django-extensions.git@c495f97a1d37bf5d40508b8e0eb128ae9fa0a6b0#egg=django_extensions-dev
django-grappelli==2.3.8
django-guardian==1.0.4
django-nose==1.1
django-profiles==0.2
django-registration==0.8
django-sms==0.0.4
django-socialregistration==0.5.4
django-userena==1.1.2
djappsettings==0.1.0
djtables==0.1.2
#facebook-python-sdk==0.1
-e git://github.com/jhaddad/facebook-python-sdk#egg=facebook-python-sdk
easy-thumbnails==1.0.3
facebook-python-sdk==0.1
facebook-sdk==0.3.1
feedparser==5.1.2
-e git://github.com/seatgeek/fuzzywuzzy.git@c73e3d32e3bb4d31dc38cc64e3a3362855d4d249#egg=fuzzywuzzy-dev
@ -23,6 +29,6 @@ mock==0.8.0
nose==1.1.2
oauth2==1.5.211
-e bzr+http://code.0x2620.org/python-ox/@354#egg=ox-2.0.354-py2.7-dev_r354
#psycopg2==2.4.5
psycopg2==2.4.5
python-openid==2.2.5
wsgiref==0.1.2