コード例 #1
0
ファイル: models.py プロジェクト: hkmshb/Booktype
    def get_author(self):
        from django.conf import settings
        from booktype.apps.account import utils

        if self.user:
            return {
                'name': self.user.get_full_name() or self.user.username,
                'avatar': utils.get_profile_image(self.user, 35)
            }
        else:
            return {
                'name': self.author,
                'avatar': '{}{}'.format(settings.STATIC_URL, 'account/images/anonymous.png')
            }
コード例 #2
0
    def get_author(self):
        from django.conf import settings
        from booktype.apps.account import utils

        if self.user:
            return {
                'name': self.user.get_full_name() or self.user.username,
                'avatar': utils.get_profile_image(self.user, 35)
            }
        else:
            return {
                'name': self.author,
                'avatar': '{}{}'.format(settings.STATIC_URL, 'account/images/anonymous.png')
            }
コード例 #3
0
 def render(self, context):
     user = resolve_variable(self.user, context)
     image_url = utils.get_profile_image(user)
     return mark_safe('<img src="{url}?{anti_cache}"/>'.format(url=image_url, anti_cache=str(uuid.uuid4())))
コード例 #4
0
ファイル: serializers.py プロジェクト: xanjay/Booktype
 def get_profile_image_url(self, obj):
     return account_utils.get_profile_image(obj)