]>
git.ipfire.org Git - ipfire.org.git/blob - src/web/people.py
6 from . import handlers_base
as base
8 class AvatarHandler(base
.BaseHandler
):
10 # Get the desired size of the avatar file
11 size
= self
.get_argument("size", 0)
15 except (TypeError, ValueError):
18 logging
.debug("Querying for avatar of %s" % uid
)
21 account
= self
.backend
.accounts
.get_by_uid(uid
)
23 raise tornado
.web
.HTTPError(404, "Could not find account %s" % uid
)
25 # Allow downstream to cache this for 60 minutes
26 self
.set_expires(3600)
29 avatar
= account
.get_avatar(size
)
31 # If there is no avatar, we serve a default image
33 logging
.debug("No avatar uploaded for %s" % account
)
35 return self
.redirect("https://static.ipfire.org%s" % self
.static_url("img/default-avatar.jpg"))
37 # Set headers about content
38 self
.set_header("Content-Disposition", "inline; filename=\"%s.jpg\"" % account
.uid
)
39 self
.set_header("Content-Type", "image/jpeg")