Ejemplo n.º 1
0
def create_user_by_tel_name(tel, name, nickname, sex):
    """
    根据电话号用户名生成用户
    y:尚宗凯 at:2015-3-4
    :param tel , name:
    :return:
    """
    user = get_user_model()()
    user.tel = tel
    user.set_password('123456')
    user.name = str(name)
    user.nickname = str(nickname)
    user.save()

    bf = BaseFile()
    tel = tel[1:]
    # bf.fileurl = '/static/headicon/001宋江.jpg'
    bf.name = tel
    bf.fileurl = '/static/headicon/' + bf.name + '.jpg'
    bf.filetype = 'jpg'
    bf.file_status = True
    bf.bucket = 'pubfriendsicon'
    bf.user = user
    bf.save()
    user.icon_url = bf

    assert sex in ('male', 'female')
    if sex == 'male':
        user.sex = True
    else:
        user.sex = False
    user.save()
    return user
Ejemplo n.º 2
0
def create_user_by_tel_name(tel, name, nickname, sex):
    """
    根据电话号用户名生成用户
    y:尚宗凯 at:2015-3-4
    :param tel , name:
    :return:
    """
    user = get_user_model()()
    user.tel = tel
    user.set_password('123456')
    user.name = str(name)
    user.nickname = str(nickname)
    user.save()

    bf = BaseFile()
    tel = tel[1:]
    # bf.fileurl = '/static/headicon/001宋江.jpg'
    bf.name = tel
    bf.fileurl = '/static/headicon/'+bf.name+'.jpg'
    bf.filetype = 'jpg'
    bf.file_status = True
    bf.bucket = 'pubfriendsicon'
    bf.user = user
    bf.save()
    user.icon_url = bf

    assert sex in ('male','female')
    if sex == 'male':
        user.sex = True
    else:
        user.sex = False
    user.save()
    return user
Ejemplo n.º 3
0
def create_user_icon_fileobj(request, bucket=QN_FRIENDS_ICON_BUCKET):
    """
    创建用户头像
    by:王健 at:2015-1-29
    用户头像存储位置 标记为以用户id为文件夹目录的位置
    by:王健 at:2015-2-3
    :param request:
    :param bucket:
    :return:
    """
    fileobj = BaseFile()
    fileobj.user_id = request.user.pk
    fileobj.bucket = bucket
    fileobj.file_status = False
    fileobj.filetype = request.REQUEST.get('filetype', 'file')
    fileobj.size = int(request.REQUEST.get('size', '0'))
    fileobj.name = request.REQUEST.get('filename', '')[-50:]
    uuidname = str(uuid.uuid4())
    object_name = str('/%s/%s.%s' % (fileobj.user_id, uuidname, fileobj.filetype))
    fileobj.fileurl = object_name
    # fileobj.shareurl = bcs.sign('GET', FILE_BUCKET, object_name)
    # posturl = bcs.sign('POST', FILE_BUCKET, object_name, T=int(time.time() + 3600), S=fileobj.size)
    fileobj.save()
    return fileobj