当前位置: 首页>>代码示例>>Python>>正文


Python User.real_name方法代码示例

本文整理汇总了Python中forum.models.User.real_name方法的典型用法代码示例。如果您正苦于以下问题:Python User.real_name方法的具体用法?Python User.real_name怎么用?Python User.real_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forum.models.User的用法示例。


在下文中一共展示了User.real_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: import_users

# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import real_name [as 别名]
    def import_users(self, users):
        pkey_map = {}
        doc = dom.parse(users)

        rows = doc.getElementsByTagName('row')
        unknown_count = 0

        added_names = []

        for row in rows:
            values = self.row_to_dic(row)

            username = values.get('displayname',
                            values.get('realname',
                                values.get('email', None)))

            if username is None:
                unknown_count += 1
                username = 'Unknown User %d' % unknown_count

            if username in added_names:
                cnt = 1
                new_username = "%s %d" % (username, cnt)
                while new_username in added_names:
                    cnt += 1
                    new_username = "%s %d" % (username, cnt)

                username = new_username

            added_names.append(username)

            user = User(username=username, email=values.get('email', ''))

            user.reputation = values['reputation']
            user.last_seen = self.from_sx_time(values['lastaccessdate'])

            user.real_name = values.get('realname', '')
            user.about = values.get('aboutme', '')
            user.website = values.get('websiteurl', '')
            user.date_of_birth = self.from_sx_time(values.get('birthday', None))
            user.location = values.get('location', '')

            user.is_active = True
            user.email_isvalid = True


            if int(values['usertypeid']) == 5:
                user.is_superuser = True

            if int(values['usertypeid']) == 5:
                user.is_staff = True

            user.save()

            pkey_map[values['id']] = user

        return users
开发者ID:EzerchE,项目名称:askbot-devel,代码行数:59,代码来源:sximport.py

示例2: update_forum_user

# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import real_name [as 别名]
def update_forum_user(request):
    """ Create or Update Forum User model """

    try:
        # Customise User Model
        # username = request.user.username.split('@')[0]
        user = User.objects.get(user_ptr_id=request.user.id)
        user.user_ptr = request.user
        user.save()
    except ObjectDoesNotExist:
        obj = User()
        obj.user_ptr = request.user
        obj.email_isvalid = True

        obj.last_seen = request.user.last_login
        obj.username = request.user.username if '@' not in request.user.username else request.user.username.split('@')[0]
        obj.real_name = "%s %s" % (request.user.first_name, request.user.last_name)
        # obj.is_active = request.user.is_active
        obj.email = request.user.email
        obj.profile_image_url = request.session['profile_image'] if 'profile_image' in request.session else ''
        obj.save()
开发者ID:mahammed786,项目名称:test-repo,代码行数:23,代码来源:forum_helpers.py


注:本文中的forum.models.User.real_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。