[copr] master: add support for libravatar (ea241bb)
msuchy at fedoraproject.org
msuchy at fedoraproject.org
Thu Sep 5 08:20:37 UTC 2013
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit ea241bb765ae8ff03d9aa1b262439daf5e41eb18
Author: Miroslav Suchý <msuchy at redhat.com>
Date: Wed Sep 4 13:11:18 2013 +0200
add support for libravatar
>---------------------------------------------------------------
copr.spec | 1 +
coprs_frontend/coprs/models.py | 6 ++++++
coprs_frontend/coprs/templates/coprs/show.html | 2 +-
3 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/copr.spec b/copr.spec
index 0a5bfd0..03d282e 100644
--- a/copr.spec
+++ b/copr.spec
@@ -55,6 +55,7 @@ Requires: python-flask-whooshee
#Requires: python-virtualenv
Requires: python-blinker
Requires: python-psycopg2
+Requires: python-pylibravatar
Requires: python-whoosh
# for tests:
Requires: pytest
diff --git a/coprs_frontend/coprs/models.py b/coprs_frontend/coprs/models.py
index b1c684e..002ebcb 100644
--- a/coprs_frontend/coprs/models.py
+++ b/coprs_frontend/coprs/models.py
@@ -3,6 +3,7 @@ import time
import sqlalchemy
from sqlalchemy.ext.associationproxy import association_proxy
+from libravatar import libravatar_url
from coprs import constants
from coprs import db
@@ -126,6 +127,11 @@ class User(db.Model, Serializer):
filter_by(deleted=False).\
count()
+ @property
+ def gravatar_url(self):
+ """Return url to libravatar image."""
+ return libravatar_url(email = self.mail)
+
class Copr(db.Model, Serializer):
"""Represents a single copr (private repo with builds, mock chroots, etc.)."""
diff --git a/coprs_frontend/coprs/templates/coprs/show.html b/coprs_frontend/coprs/templates/coprs/show.html
index 5ccde32..3df2771 100644
--- a/coprs_frontend/coprs/templates/coprs/show.html
+++ b/coprs_frontend/coprs/templates/coprs/show.html
@@ -6,7 +6,7 @@
{% if g.user %}
<div class="user-info">
<a href="{{ url_for('coprs_ns.coprs_by_owner', username=g.user.name) }}" title="My Coprs">
- <img src="{{ url_for('static', filename='default_user.png') }}" alt="User Image">
+ <img src="{{ g.user.gravatar_url }}" alt="User Image">
</a>
<p>{{ g.user.name }}</p>
<p class="coprs-count">{{ g.user.coprs_count }}</p>
More information about the copr-devel
mailing list