Example #1
0
    def get(self):
        user = users.get_current_user()
        if user:
            all_buffrs = memcache.get('%s-buffrs' % user.user_id())
            if not all_buffrs:
                all_buffrs = Buffr.all()
                all_buffrs.filter('user_id =', user.user_id())
                all_buffrs = all_buffrs.fetch(how_many_buffrs_per_user)
                memcache.set('%s-buffrs' % user.user_id(), all_buffrs)

            user_icon = get_gravatar(user.email())

            render(self, 'userinfo.html', {
                'user': users.get_current_user(),
                'gravatar': user_icon,
                'currentAddress': self.request.host_url,
                'to_console': {'gravatar': user_icon},
                'all_buffrs': all_buffrs})
        else:
            self.redirect(users.create_login_url('/user'))
Example #2
0
    def get_mugshot_url(self):
    # First check for a mugshot and if any return that.
        if self.mugshot:
            return self.mugshot.url

        # Use Gravatar if the user wants to.
        if accounts_settings.MUGSHOT_GRAVATAR:
            return get_gravatar(self.user.email,
                                accounts_settings.MUGSHOT_SIZE,
                                accounts_settings.MUGSHOT_DEFAULT)

        # Gravatar not used, check for a default image.
        else:
            if accounts_settings.MUGSHOT_DEFAULT not in ['404', 'mm',
                                                                'identicon',
                                                                'monsterid',
                                                                'wavatar']:
                return accounts_settings.MUGSHOT_DEFAULT
            else:
                return None