Created
June 21, 2010 02:13
-
-
Save dannyroa/446308 to your computer and use it in GitHub Desktop.
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
# Create your views here. | |
from labs.connectcomments.models import * | |
from labs.connectcomments.googlefriendconnect import * | |
from labs.connectcomments.facebookconnect import * | |
from django.contrib.auth import logout | |
def index(request): | |
return render_to_response('connectcomments_index.html', { | |
}, context_instance=RequestContext(request)) | |
def testbuttons(request): | |
return render_to_response('googlefriendconnect/testbuttons.html', { | |
}, context_instance=RequestContext(request)) | |
def test(request): | |
userInfo = googlefriendconnect_getuserinfo('01669058444367769687') | |
socialId = 'gfc' + userInfo['id'] | |
pictureUrl = userInfo['thumbnailUrl'] | |
displayName = userInfo['displayName'] | |
return HttpResponse(simplejson.dumps(userInfo)) | |
def loginuser(request): | |
return render_to_response('connectcomments/login.html', { | |
}, context_instance=RequestContext(request)) | |
def logoutuser(request): | |
templateUrl = '' | |
if request.user.username.startswith('fbc'): | |
templateUrl = 'facebookconnect/logout.html' | |
else: | |
templateUrl = 'googlefriendconnect/logout.html' | |
logout(request) | |
return render_to_response(templateUrl, { | |
}, context_instance=RequestContext(request)) | |
def index(request): | |
displayName = '' | |
pictureUrl = '' | |
if request.user.is_authenticated(): | |
displayName = request.session['displayName'] | |
pictureUrl = request.session['pictureUrl'] | |
form = None | |
if request.method == 'POST': # If the form has been submitted... | |
form = CommentForm(request.POST) # A form bound to the POST data | |
if form.is_valid(): | |
commentMessage = form.cleaned_data['comment'] | |
newComment = Comment() | |
newComment.message = commentMessage | |
newComment.author = request.user | |
newComment.save() | |
return HttpResponseRedirect('/connectcomments/') | |
form = CommentForm() | |
commentList = Comment.objects.all() | |
for comment in commentList: | |
if comment.author.username.startswith('fbc'): | |
userInfo = facebookconnect_getUserInfo(comment.author.username) | |
comment.connectType = 'fbc' | |
comment.socialId = comment.author.username.replace('fbc','') | |
comment.pictureUrl = userInfo['pic_square'] | |
comment.displayName = userInfo['first_name'] + ' ' + userInfo['last_name'][0:1] | |
else: # user is google friend connect | |
userInfo = googlefriendconnect_getuserinfo(comment.author.username) | |
comment.connectType = 'gfc' | |
comment.socialId = comment.author.username.replace('gfc','') | |
comment.pictureUrl = userInfo['thumbnailUrl'] | |
comment.displayName = userInfo['displayName'] | |
return render_to_response('connectcomments/index.html', { | |
'form': form, 'displayName' : displayName, 'pictureUrl' : pictureUrl, 'commentList' : commentList | |
}, context_instance=RequestContext(request)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment