Beispiel #1
0
    def handle(self, *args, **options):
        print('Loading users')
        user_file = os.path.join(FIXTURES_PATH, 'users.json')
        with open(user_file, 'r') as f:
            jdata = json.loads(f.read())
            UserProfile.objects.all().delete()
            for user in jdata['administratiors']:
                profile = UserProfile()
                profile.username = user['username']
                profile.set_password(user['password'])
                profile.publicname = user['username']
                profile.is_staff = True
                profile.is_superuser = True
                profile.is_superuser = True
                profile.save()
                print('Creating ... %s' % user['username'])

            for user in jdata['female']:
                rez = requests.post(API_URL + 'account/registration',
                                    json=user)
                print(json.loads(rez.text)['message'])

            for user in jdata['male']:
                rez = requests.post(API_URL + 'account/registration',
                                    json=user)
                print(json.loads(rez.text)['message'])
Beispiel #2
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()
Beispiel #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'
    u.hight = 160
    u.save()
    return u
Beispiel #4
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