Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial progress toward twitter and facebook sign in
- Loading branch information
Showing
38 changed files
with
950 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
vendor/ | ||
env/ | ||
xfers/ | ||
venv/ | ||
tmp/ | ||
src/ | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import re | ||
|
||
from django import forms | ||
from django.conf import settings | ||
from django.template.loader import render_to_string | ||
from django.utils.translation import ugettext_lazy as _, ugettext | ||
|
||
from pinax.apps.account.forms import SignupForm | ||
|
||
class OauthSignupForm(SignupForm): | ||
|
||
def __init__(self, *args, **kwargs): | ||
# remember provided (validated!) OpenID to attach it to the new user | ||
# later. | ||
self.openid = kwargs.pop("openid", None) | ||
# pop these off since they are passed to this method but we can't | ||
# pass them to forms.Form.__init__ | ||
kwargs.pop("reserved_usernames", []) | ||
kwargs.pop("no_duplicate_emails", False) | ||
|
||
super(OauthSignupForm, self).__init__(*args, **kwargs) | ||
|
||
# these fields make no sense in OpenID | ||
del self.fields["password1"] | ||
del self.fields["password2"] | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.43 KB
apps/socialconnect/media/socialconnect/img/sign-in-with-twitter-l.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# encoding: utf-8 | ||
import datetime | ||
from south.db import db | ||
from south.v2 import SchemaMigration | ||
from django.db import models | ||
|
||
class Migration(SchemaMigration): | ||
|
||
def forwards(self, orm): | ||
|
||
# Adding model 'UserOauthAssociation' | ||
db.create_table('socialconnect_useroauthassociation', ( | ||
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | ||
('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), | ||
('auth_type', self.gf('django.db.models.fields.CharField')(max_length=32, null=True)), | ||
('profile_id', self.gf('django.db.models.fields.CharField')(max_length=255, null=True)), | ||
('username', self.gf('django.db.models.fields.CharField')(max_length=255, null=True)), | ||
('access_token', self.gf('django.db.models.fields.CharField')(max_length=255, null=True)), | ||
('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), | ||
)) | ||
db.send_create_signal('socialconnect', ['UserOauthAssociation']) | ||
|
||
|
||
def backwards(self, orm): | ||
|
||
# Deleting model 'UserOauthAssociation' | ||
db.delete_table('socialconnect_useroauthassociation') | ||
|
||
|
||
models = { | ||
'auth.group': { | ||
'Meta': {'object_name': 'Group'}, | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), | ||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) | ||
}, | ||
'auth.permission': { | ||
'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, | ||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | ||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) | ||
}, | ||
'auth.user': { | ||
'Meta': {'object_name': 'User'}, | ||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), | ||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), | ||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), | ||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}), | ||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), | ||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), | ||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), | ||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), | ||
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), | ||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), | ||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) | ||
}, | ||
'contenttypes.contenttype': { | ||
'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, | ||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | ||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) | ||
}, | ||
'socialconnect.useroauthassociation': { | ||
'Meta': {'object_name': 'UserOauthAssociation'}, | ||
'access_token': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), | ||
'auth_type': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), | ||
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'profile_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), | ||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), | ||
'username': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}) | ||
} | ||
} | ||
|
||
complete_apps = ['socialconnect'] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.db import models | ||
|
||
class UserOauthAssociation(models.Model): | ||
user = models.ForeignKey('auth.User') | ||
auth_type = models.CharField(max_length = 32, null=True) | ||
profile_id = models.CharField(max_length = 255, null=True) | ||
username = models.CharField(max_length = 255, null=True) | ||
access_token = models.CharField(max_length = 255, null=True) | ||
created = models.DateTimeField(auto_now_add = True) | ||
|
||
def __unicode__(self): | ||
return u'%s can log in with %s %s (%s)' % ( | ||
self.user, self.auth_type, self.username, self.profile_id | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% extends "account/base.html" %} | ||
|
||
{% load i18n %} | ||
{% load uni_form_tags %} | ||
|
||
{% block head_title %}{% trans "Choose a Username" %}{% endblock %} | ||
|
||
{% block body %} | ||
<h1>{% trans "Choose a Username" %}</h1> | ||
|
||
{% if form.errors %} | ||
<p class="error">{% trans "Please correct the errors below:" %}</p> | ||
{% endif %} | ||
|
||
<p>{% blocktrans %}Now that you have logged in with your {{auth_label}} profile, we need you to choose a username for this site.{% endblocktrans %}</p> | ||
|
||
<form class="uniForm signup" id="edit-profile" method="POST" action=""> | ||
{% csrf_token %} | ||
<fieldset class="inlineLabels"> | ||
{{ form|as_uni_form }} | ||
<div class="form_block"> | ||
<input type="submit" value="{% trans "Sign Up »" %}"/> | ||
</div> | ||
</fieldset> | ||
</form> | ||
|
||
{% url terms as terms_url %} | ||
{% url privacy as privacy_url %} | ||
{% url acct_login as acct_login %} | ||
<p>{% blocktrans %}<strong>Already have an account?</strong> <a href="{{ acct_login }}?next={{ signin_url }}">Login here</a> to associate your {{auth_label}} profile with your existing account.{% endblocktrans %}</p> | ||
<p>{% blocktrans %}By clicking "Sign Up", you are indicating that you have read and agree to the <a href="{{ terms_url }}">Terms of Use</a> and <a href="{{ privacy_url }}">Privacy Policy</a>.{% endblocktrans %}</p> | ||
<p>{% blocktrans %}If you have any trouble creating your account, contact us at <a href="mailto:{{ CONTACT_EMAIL }}">{{ CONTACT_EMAIL }}</a>.{% endblocktrans %}</p> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
""" | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
from socialconnect.views import TwitterAuthView, FacebookAuthView | ||
|
||
urlpatterns = patterns("", | ||
(r"^twitter/", include(TwitterAuthView().urls)), | ||
(r"^facebook/", include(FacebookAuthView().urls)), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
"""Utilities for class-based views and more | ||
see also: http://www.slideshare.net/simon/classbased-views-with-django | ||
""" | ||
|
||
from django.http import HttpResponseRedirect, HttpResponse | ||
from django.conf.urls.defaults import patterns | ||
from django.core import urlresolvers | ||
|
||
class Router(object): | ||
|
||
def __init__(self, *urlpairs): | ||
self.urlpatterns = patterns('', *urlpairs) | ||
# for 1.0 compatibility we pass in None for urlconf_name and then | ||
# modify the _urlconf_module to make self hack as if its the module. | ||
self.resolver = urlresolvers.RegexURLResolver(r'^/', None) | ||
self.resolver._urlconf_module = self | ||
|
||
def handle(self, request, path_override=None): | ||
if path_override is not None: | ||
path = path_override | ||
else: | ||
path = request.path_info | ||
path = '/' + path # Or it doesn't work | ||
callback, callback_args, callback_kwargs = self.resolver.resolve(path) | ||
return callback(request, *callback_args, **callback_kwargs) | ||
|
||
def __call__(self, request, path_override=None): | ||
return self.handle(request, path_override) | ||
|
||
class ViewObject(object): | ||
|
||
def get_urlpatterns(self): | ||
# Default behaviour is to introspect self for do_* methods | ||
from django.conf.urls.defaults import url | ||
urlpatterns = [] | ||
for method in dir(self): | ||
if method.startswith('do_'): | ||
callback = getattr(self, method) | ||
name = method.replace('do_', '') | ||
urlname = self.urlname_pattern % name | ||
urlregex = getattr(callback, 'urlregex', '^%s/$' % name) | ||
urlpatterns.append( | ||
url(urlregex, callback, name=urlname) | ||
) | ||
return urlpatterns | ||
|
||
def get_urls(self): | ||
# In Django 1.1 and later you can hook this in to your urlconf | ||
from django.conf.urls.defaults import patterns | ||
return patterns('', *self.get_urlpatterns()) | ||
|
||
def urls(self): | ||
return self.get_urls() | ||
urls = property(urls) | ||
|
||
def __call__(self, request, rest_of_url=''): | ||
if not request.path.endswith('/'): | ||
return HttpResponseRedirect(request.path + '/') | ||
router = Router(*self.get_urlpatterns()) | ||
return router(request, path_override = rest_of_url) | ||
|
||
|
||
def render(self, request, template, context=None): | ||
context = context or {} | ||
context['base_template'] = self.base_template | ||
return TemplateResponse(request, template, context) | ||
|
Oops, something went wrong.