コード例 #1
0
ファイル: views.py プロジェクト: ahrokib/mozillians
def photo(request, unique_id):
    needs_master = request.user.unique_id == unique_id

    ldap = UserSession.connect(request)
    image = ldap.profile_photo(unique_id, use_master=needs_master)
    if image:
        return HttpResponse(image, mimetype="image/jpeg")
    else:
        # If gravatar has no image, it will return this image.
        default = "http://%s/media/img/unknown.png" % request.get_host()
        email = ldap.get_by_unique_id(unique_id, needs_master).username
        return redirect(gravatar(email, default))
コード例 #2
0
ファイル: views.py プロジェクト: ahrokib/mozillians
def photo(request, unique_id):
    needs_master = (request.user.unique_id == unique_id)

    ldap = UserSession.connect(request)
    image = ldap.profile_photo(unique_id, use_master=needs_master)
    if image:
        return HttpResponse(image, mimetype="image/jpeg")
    else:
        # If gravatar has no image, it will return this image.
        default = 'http://%s/media/img/unknown.png' % request.get_host()
        email = ldap.get_by_unique_id(unique_id, needs_master).username
        return redirect(gravatar(email, default))
コード例 #3
0
    def get_photo_url(self, cachebust=False):
        """Gets a user's userpic URL.  Appends cachebusting if requested."""
        # Import this here to avoid circular imports because other apps are loading this file in init.py
        from phonebook.helpers import gravatar
        if self.photo:
            url = '%s/%d.jpg' % (settings.USERPICS_URL, self.id)

            if cachebust:
                url += '?%d' % int(time.time())
        else:
            url = gravatar(self.user.email)

        return url
コード例 #4
0
ファイル: models.py プロジェクト: pmclanahan/mozillians
    def get_photo_url(self, cachebust=False):
        """Gets a user's userpic URL.  Appends cachebusting if requested."""
        # Import this here to avoid circular imports because other apps are loading this file in init.py
        from phonebook.helpers import gravatar
        if self.photo:
            url = '%s/%d.jpg' % (settings.USERPICS_URL, self.user_id)

            if cachebust:
                url += '?%d' % int(time.time())
        else:
            url = gravatar(self.user.email)

        return url
コード例 #5
0
ファイル: models.py プロジェクト: m8ttyB/mozillians
    def photo_url(self):
        if self.photo:
            return self.photo.url

        return gravatar(self.user.email)
コード例 #6
0
    def photo_url(self):
        if self.photo:
            return self.photo.url

        return gravatar(self.user.email)