Пример #1
0
def approve_woman_profile(obj):
    print("Approving")
    data = json.loads(obj.data)
    #print(data)
    pwd = random.randint(11111, 99999)
    u = UserProfile()
    u.username = data['email']
    u.gender = 'female'
    u.set_password(pwd)
    u.is_active = True
    u.is_staff = False
    u.email = data['email']
    u.is_superuser = False
    u.about_me = data['about_me']
    u.goal = data['goal']
    u.job = data['job']
    u.city = data['city']
    u.lookingfor = data['lookingfor']
    bd = '%s-%s-%s' % (data['birthday'][0:4], data['birthday'][5:7],data['birthday'][8:10])
    print(bd)
    u.birthday = parse_date(bd)
    u.save()
    fillprops(u, data)
    obj.delete()
    for im in data['images']:
        format, imgstr = im.split(';base64,')
        ext = format.split('/')[-1]
        data = ContentFile(base64.b64decode(imgstr))  
        file_name = '%s-%s.%s' % (u.id,random.randint(111,999),ext)
        c = UserPhoto()
        c.user = u
        c.is_approved = True
        c.image.save(file_name, data, save=True)
        c.save() 
        c.setAsMain()
Пример #2
0
 def save(self):
     profile = UserProfile()
     profile.username = self.validated_data['username']
     profile.set_password(self.validated_data['password'])
     profile.birthday = self.validated_data['birthday']
     profile.gender = self.validated_data['gender']
     profile.save()
     return profile
Пример #3
0
def users_fabric(name, gender, is_superuser):
    print('Creating....%s' % name)
    u = UserProfile()
    u.username = name
    u.gender = gender
    u.set_password(name)
    u.is_active = True
    u.is_staff = True
    u.email = '*****@*****.**' % name
    u.is_superuser = is_superuser
    u.about_me = 'I am %s' % 'admin'
    bd = '1978-%s-01' % random.randint(1, 12)
    u.birthday = parse_date(bd)
    u.hight = 160
    u.save()
    return u