Example #1
0
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))
Example #2
0
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))
Example #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
Example #4
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.user_id)

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

        return url
Example #5
0
    def photo_url(self):
        if self.photo:
            return self.photo.url

        return gravatar(self.user.email)
Example #6
0
    def photo_url(self):
        if self.photo:
            return self.photo.url

        return gravatar(self.user.email)