Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
a36ab2ff
Commit
a36ab2ff
authored
Jan 09, 2015
by
Jason D Yeomans
Browse files
Profile Image: Facebook => Gravatar, Links to social profiles in roomlist profile
parent
e3994068
Changes
2
Hide whitespace changes
Inline
Side-by-side
roomlist/accounts/models.py
View file @
a36ab2ff
...
...
@@ -22,12 +22,13 @@ 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'
)
fb_uid
=
SocialAccount
.
objects
.
filter
(
user
=
self
.
user
.
id
,
provider
=
'facebook'
)
print
(
"profile_image"
)
if
len
(
fb_uid
):
return
"http://graph.facebook.com/{}/picture?width=
40
&height=
40
"
.
format
(
fb_uid
[
0
].
uid
)
if
len
(
fb_uid
)
>
0
:
return
"http://graph.facebook.com/{}/picture?width=
175
&height=
175
"
.
format
(
fb_uid
[
0
].
uid
)
return
"http://www.gravatar.com/avatar/{}?s=
40
"
.
format
(
hashlib
.
md5
(
self
.
user
.
email
).
hexdigest
())
return
"http://www.gravatar.com/avatar/{}?s=
175
"
.
format
(
hashlib
.
md5
(
self
.
user
.
email
).
hexdigest
())
def
__str__
(
self
):
# __unicode__ on Python 2
...
...
roomlist/accounts/templates/detailStudent.html
View file @
a36ab2ff
{% 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 %} {% load socialaccount %} {% block content %}
<!-- gravatar_url student.user.email 175 %} -->
{% get_social_accounts student.user as accounts %}
<div
class=
"page-header"
id=
"banner"
>
<div
class=
"row"
>
<div
class=
"col-md-8 col-md-offset-2 text-center"
>
<img
class=
"img-circle img-responsive center center-block"
src=
"{
% gravatar_url student.user.email 175 %
}"
alt=
"{{ student.user.first_name }} Gravatar picture"
>
<img
class=
"img-circle img-responsive center center-block"
src=
"{
{ student.profile_image_url }
}"
alt=
"{{ student.user.first_name }} Gravatar picture"
>
<h1>
{{ student.user.first_name }} {{ student.user.last_name }}
</h1>
</div>
</div>
...
...
@@ -47,18 +43,19 @@
<table
class=
"table table-hover text-center"
>
<tbody>
<tr>
<td><i
class=
"fa fa-facebook fa-lg"
></i></td>
<td>
link
</td>
<td><i
class=
"fa fa-facebook fa-lg"
></i>
</td>
<td>
{% if accounts.facebook %}
<a
href=
"http://www.facebook.com/{{ accounts.facebook.0.uid }}"
target=
"_blank"
>
Facebook
</a>
{% endif %}
</td>
</tr>
<tr>
<td><i
class=
"fa fa-google fa-lg"
></i></td>
<td>
link
</td>
<td><i
class=
"fa fa-google fa-lg"
></i>
</td>
<td>
{% if accounts.google %}
<a
href=
"https://plus.google.com/{{ accounts.google.0.uid }}"
target=
"_blank"
>
Google+
</a>
{% endif %}
</td>
</tr>
<tr>
<td><i
class=
"fa fa-twitter fa-lg"
></i></td>
<td>
link
</td>
<td><i
class=
"fa fa-twitter fa-lg"
></i>
</td>
<td>
{% if accounts.twitter %}
<a
href=
"https://twitter.com/intent/user?user_id={{ accounts.twitter.0.uid }}"
target=
"_blank"
>
Twitter
</a>
{% endif %}
</td>
</tr>
</tbody>
</table>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment