Esempio n. 1
0
def create_test_user():
    facebook_id = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    user = User()
    user.name = 'Rafael Goncalves'
    user.facebook_id = facebook_id
    user.birthday = date.today()
    user.friends = 299
    user.gender = 'male'
    user.platform = USER_PLATFORM_iOS
    user.email = '*****@*****.**'
    db.session.add(user)
    db.session.commit()
    token = Token(user.id)
    db.session.add(token)
    db.session.commit()
    return user
Esempio n. 2
0
def create_data():
    #create some users
    facebook_id = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    rafael = User()
    rafael.name = 'Rafael Goncalves'
    rafael.facebook_id = facebook_id
    rafael.birthday = date.today()
    rafael.friends = 299
    rafael.gender = 'male'
    rafael.nickname = 'rafael'
    rafael.email = '*****@*****.**'
    db.session.add(rafael)
    token = Token(rafael.id)
    db.session.commit()

    facebook_id2 = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    bola = User()
    bola.name = 'Bola Domingues'
    bola.facebook_id = facebook_id2
    bola.birthday = date.today()
    bola.friends = 532
    bola.gender = 'male'
    bola.nickname = 'bola'
    bola.email = '*****@*****.**'
    db.session.add(bola)
    token = Token(bola.id)
    db.session.commit()

    facebook_id3 = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    bolovo = User()
    bolovo.name = 'Doutor Bolovo'
    bolovo.facebook_id = facebook_id3
    bolovo.birthday = date.today()
    bolovo.friends = 23
    bolovo.gender = 'male'
    bolovo.nickname = 'bolovo'
    bolovo.email = '*****@*****.**'
    db.session.add(bolovo)
    token = Token(bolovo.id)
    db.session.commit()

    #create some groups
    share_t = Group()
    share_t.active = True
    share_t.title = "Share Your Thoughts"
    share_t.description = "Grupo copiado do facebook chamado share-your-thoughts"
    share_t.admins.append(bola)
    share_t.subscriptions.append(bola)
    share_t.subscriptions.append(bolovo)
    share_t.subscriptions.append(rafael)
    db.session.add(share_t)
    db.session.commit()

    shammu = Group()
    shammu.active = True
    shammu.title = "Salvem as Baleias!"
    shammu.description = "Grupo dedicado ao salvamento de baleias e o fechamentos de parques de entretenimento que usam animais em cativeiro para estrelar em suas atracoes"
    shammu.admins.append(bola)
    shammu.subscriptions.append(bolovo)
    shammu.subscriptions.append(bola)
    db.session.add(shammu)
    db.session.commit()

    share_c = Group()
    share_c.active = True
    share_c.title = "Share Your Career"
    share_c.description = "Grupo dedicado ao compartilhamento de informacoes sobre estagios, empregos e carreiras em geral"
    share_c.admins.append(bolovo)
    share_c.subscriptions.append(bolovo)
    share_c.subscriptions.append(rafael)
    share_c.subscriptions.append(bola)
    db.session.add(share_c)
    db.session.commit()

    #create some posts to share_t
    share_t_post1 = Post('E possivel a contratacao de anoes para animar festar de criancas acima de 11 anos?', 0)
    share_t_post1.group_id = bola.id
    share_t_post1.user_id = share_t.id
    db.session.add(share_t_post1)
    db.session.commit()

    share_t_post2 = Post('Algo para fazer esse fds??? Geoconda ta com nada me disseram migas!', 0)
    share_t_post2.group_id = bolovo.id
    share_t_post2.user_id = share_t.id
    db.session.add(share_t_post2)
    db.session.commit()

    #create some posts to share_t
    share_c_post1 = Post('[PUC][FACULDADE] Puc ou mackenzie!!!??', 0)
    share_c_post1.group_id = bolovo.id
    share_c_post1.user_id = share_c.id
    db.session.add(share_c_post1)
    db.session.commit()

    share_c_post2 = Post('[EMPREGO][ENTREVISTA] Como e fazer uma entrevista no JPMorgan gente?', 0)
    share_c_post2.group_id = bolovo.id
    share_c_post2.user_id = share_c.id
    db.session.add(share_c_post2)
    db.session.commit()

    #create some posts to shammu
    shammu_post1 = Post('O seaworld realmente acabou ou o boato vem do cu do desentendido?', 0)
    shammu_post1.group_id = bola.id
    shammu_post1.user_id = shammu.id
    db.session.add(shammu_post1)
    db.session.commit()

    #create comments
    share_t_post1_comment = Comment('Obvio que sim querido, anoes sao para todos!')
    share_t_post1_comment.user_id = bolovo.id
    share_t_post1_comment.post_id = share_t_post1.id
    db.session.add(share_t_post1_comment)
    db.session.commit()

    #create rules
    only_woman = Rule('gender', RuleOperands.OPERAND_EQUAL, 'female', 'str', shammu)
    shammu.rules.append(only_woman)
    db.session.add(only_woman)
    db.session.commit()

        #create rules
    only_male = Rule('gender', RuleOperands.OPERAND_EQUAL, 'male', 'str', shammu)
    share_c.rules.append(only_male)
    db.session.add(only_male)
    db.session.commit()