Пример #1
0
    def bind_weixin_openid(self, user, openid):

        if not openid:
            return False

        if self.is_bind(user):
            return False
        weixin_user_obj = get_object_or_none(WeixinUser, openid=openid)

        if weixin_user_obj:
            weixin_user_obj.is_bind = True
            weixin_user_obj.save()
        else:
            weixin_user = WeixinUser(
                user=user,
                openid=openid,
            )
            weixin_user.save()

        return True
Пример #2
0
    def bind_weixin_openid(self, user, openid):

        if not openid:
            return False

        if self.is_bind(user):
            return False
        weixin_user_obj = get_object_or_none(WeixinUser, openid=openid)

        if weixin_user_obj:
            weixin_user_obj.is_bind = True
            weixin_user_obj.save()
        else:
            weixin_user = WeixinUser(
                user=user,
                openid=openid,
            )
            weixin_user.save()

        return True
Пример #3
0
    def create_weixin_user(self, user, weixin_user):

        weixin_user = WeixinUser(
            user=user,
            openid=weixin_user.get('openid'),
            nickname=weixin_user.get('nickname'),
            sex=weixin_user.get('sex'),
            city=weixin_user.get('city'),
            province=weixin_user.get('province'),
            country=weixin_user.get('country'),
            headimgurl=weixin_user.get('headimgurl'),
            privilege=weixin_user.get('privilege'),
        )
        weixin_user.save()
        return True
Пример #4
0
    def create_weixin_user(self, user, weixin_user):

        weixin_user = WeixinUser(
            user=user,
            openid=weixin_user.get('openid'),
            nickname=weixin_user.get('nickname'),
            sex=weixin_user.get('sex'),
            city=weixin_user.get('city'),
            province=weixin_user.get('province'),
            country=weixin_user.get('country'),
            headimgurl=weixin_user.get('headimgurl'),
            privilege=weixin_user.get('privilege'),
        )
        weixin_user.save()
        return True