Commit ffc5b4be authored by Jason D Yeomans's avatar Jason D Yeomans

Some work on allauth

parent b0b19bd5
......@@ -2,6 +2,8 @@ from django.db import models
from housing.models import User, Room, Class
from autoslug import AutoSlugField
from model_utils.models import TimeStampedModel
from allauth.socialaccount.models import SocialAccount
import hashlib
# Create your models here.
class Major(TimeStampedModel):
......@@ -19,5 +21,14 @@ class Student(TimeStampedModel):
slug = AutoSlugField(populate_from='user', unique=True)
def profile_image_url(self):
fb_uid = SocialAccount.objects.filter(user_id=self.user.id, provider='facebook')
if len(fb_uid):
return "http://graph.facebook.com/{}/picture?width=40&height=40".format(fb_uid[0].uid)
return "http://www.gravatar.com/avatar/{}?s=40".format(hashlib.md5(self.user.email).hexdigest())
def __str__(self): # __unicode__ on Python 2
return self.user.username
{% extends 'layouts/base.html' %} {% block title %} GMU RoomList | {{ student.user.first_name }} {{ student.user.last_name }} {% endblock %} {% block content %} {% load gravatar %}
{% extends 'layouts/base.html' %} {% block title %} GMU RoomList | {{ student.user.first_name }} {{ student.user.last_name }} {% endblock %} {% block content %} {% load socialaccount %} {% load gravatar %}
<div class="page-header" id="banner">
<div class="row">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment