コード例 #1
0
 def init_data(self):
    #default test user
    demo =User(
          first_name=u'demo',
          last_name=u'demo',
          user_name=u'demo',
          password=u'123456',
          role_code=ADMIN,
          status_code=ACTIVE,
          user_settings=UserSettings(
              sex_code=MALE,
              phone='555-555-5555',
              bio=u'just a demo guy'))
    email = Email(address= "*****@*****.**", is_primary=True, status_code=VERIFIED) 
    demo.add_email(email)
    
    db.session.add(demo)
    db.session.add(email)
    db.session.commit()
    
    """Add in post categories"""
    for c in CATEGORIES:
       hashtag = Hashtag(name = c)      
       db.session.add(hashtag)
    db.session.commit()
    
    self.demo_user= demo
    
    '''Add in circles'''
    ucla = Circle(name=u'ucla', description=u'ucla.edu emails only')
    ucla.add_member(demo)
    db.session.add(ucla)
    db.session.commit()
コード例 #2
0
def initdb():
    """Init/reset database."""

    db.drop_all(bind=None)
    db.create_all(bind=None)

    admin = User(
        first_name=u"admin",
        last_name=u"admin",
        user_name=u"admin",
        password=u"123456",
        role_code=ADMIN,
        status_code=ACTIVE,
        user_settings=UserSettings(
            sex_code=MALE, age=10, phone="555-555-5555", bio=u"admin Guy is ... hmm ... just a admin guy."
        ),
    )
    email = Email(address="*****@*****.**", is_primary=True, status_code=VERIFIED)
    admin.add_email(email)
    db.session.add(admin)
    db.session.add(email)
    db.session.commit()

    hashtag = None
    """Add in all post hashtag"""
    for (key, id) in CATEGORIES.iteritems():
        hashtag = Hashtag(id=id, name=key)
        db.session.add(hashtag)
    db.session.commit()

    # generate 1000 random post
    """
    for x in range(0,1000):
      post = Post(name='test-'+str(x), price=10, description='AOH LALAL')
      post.user_id = admin.id
      post.add_hashtag(hashtag)
      db.session.add(post)
   
      db.session.commit()

      chat = Chat(buyer= admin)
      msg = ChatMessage(body = "TEST MESSAGE", created_by = admin.id)
      post.add_chat(chat)
      chat.add_message(msg)
      db.session.commit()

    db.session.commit()
    """

    # Add in ucla circle
    ucla = Circle(name=u"ucla", description=u"ucla.edu emails only")
    ucla.add_member(admin)
    db.session.add(ucla)
    db.session.commit()

    ucla_info = CollegeInfo(
        circle_id=ucla.id, domain=u"ucla.edu", fb_group_id=267279833349705, fb_sell_id=267375200006835
    )
    db.session.add(ucla_info)
    db.session.commit()
コード例 #3
0
    def init_data(self):
        #default test user
        demo = User(first_name=u'demo',
                    last_name=u'demo',
                    user_name=u'demo',
                    password=u'123456',
                    role_code=ADMIN,
                    status_code=ACTIVE,
                    user_settings=UserSettings(sex_code=MALE,
                                               phone='555-555-5555',
                                               bio=u'just a demo guy'))
        email = Email(address="*****@*****.**",
                      is_primary=True,
                      status_code=VERIFIED)
        demo.add_email(email)

        db.session.add(demo)
        db.session.add(email)
        db.session.commit()
        """Add in post categories"""
        for c in CATEGORIES:
            hashtag = Hashtag(name=c)
            db.session.add(hashtag)
        db.session.commit()

        self.demo_user = demo
        '''Add in circles'''
        ucla = Circle(name=u'ucla', description=u'ucla.edu emails only')
        ucla.add_member(demo)
        db.session.add(ucla)
        db.session.commit()
コード例 #4
0
def initdb():
    """Init/reset database."""

    db.drop_all(bind=None)
    db.create_all(bind=None)

    admin = User(first_name=u'admin',
                 last_name=u'admin',
                 user_name=u'admin',
                 password=u'gFcPU5XB',
                 role_code=ADMIN,
                 status_code=ACTIVE,
                 user_settings=UserSettings(sex_code=MALE,
                                            age=10,
                                            phone='555-555-5555',
                                            bio=u''))
    email = Email(address="*****@*****.**",
                  is_primary=True,
                  status_code=VERIFIED)
    admin.add_email(email)
    db.session.add(admin)
    db.session.add(email)
    db.session.commit()

    hashtag = None
    """Add in all post hashtag"""
    for (key, id) in CATEGORIES.iteritems():
        hashtag = Hashtag(id=id, name=key)
        db.session.add(hashtag)
    db.session.commit()

    #Add in ucla circle
    ucla = Circle(name=u'ucla', description=u'ucla.edu emails only')
    ucla.add_member(admin)
    db.session.add(ucla)
    db.session.commit()

    ucla_info = CollegeInfo(circle_id=ucla.id,
                            domain=u'ucla.edu',
                            fb_group_id=267279833349705,
                            fb_sell_id=267375200006835)
    db.session.add(ucla_info)
    db.session.commit()
コード例 #5
0
def initdb():
    """Init/reset database."""

    db.drop_all(bind=None)
    db.create_all(bind=None)

    admin = User(
            first_name=u'admin',
            last_name=u'admin',
            user_name=u'admin',
            password=u'gFcPU5XB',
            role_code=ADMIN,
            status_code=ACTIVE,
            user_settings=UserSettings(
                sex_code=MALE,
                age=10,
                phone='555-555-5555',
                bio=u''))
    email = Email(address= "*****@*****.**", is_primary=True, status_code=VERIFIED) 
    admin.add_email(email)
    db.session.add(admin)
    db.session.add(email)
    db.session.commit()
    
        
    hashtag = None
    """Add in all post hashtag"""
    for (key,id) in CATEGORIES.iteritems():
      hashtag = Hashtag(id=id, name = key)     
      db.session.add(hashtag)
    db.session.commit()
    
    #Add in ucla circle
    ucla = Circle(name=u'ucla', description=u'ucla.edu emails only')  
    ucla.add_member(admin)
    db.session.add(ucla)   
    db.session.commit()
       
    ucla_info = CollegeInfo(circle_id = ucla.id, domain=u'ucla.edu',fb_group_id=267279833349705, fb_sell_id=267375200006835)
    db.session.add(ucla_info)
    db.session.commit()
コード例 #6
0
ファイル: manage.py プロジェクト: yashubh/DoubleDibz-tutorial
def initdb():
    """Init/reset database."""

    db.drop_all(bind=None)
    db.create_all(bind=None)

    admin = User(first_name=u'admin',
                 last_name=u'admin',
                 user_name=u'admin',
                 password=u'123456',
                 role_code=ADMIN,
                 status_code=ACTIVE,
                 user_settings=UserSettings(
                     sex_code=MALE,
                     age=10,
                     phone='555-555-5555',
                     bio=u'admin Guy is ... hmm ... just a admin guy.'))
    email = Email(address="*****@*****.**",
                  is_primary=True,
                  status_code=VERIFIED)
    admin.add_email(email)
    db.session.add(admin)
    db.session.add(email)
    db.session.commit()

    hashtag = None
    """Add in all post hashtag"""
    for (key, id) in CATEGORIES.iteritems():
        hashtag = Hashtag(id=id, name=key)
        db.session.add(hashtag)
    db.session.commit()

    #generate 1000 random post
    '''
    for x in range(0,1000):
      post = Post(name='test-'+str(x), price=10, description='AOH LALAL')
      post.user_id = admin.id
      post.add_hashtag(hashtag)
      db.session.add(post)
   
      db.session.commit()

      chat = Chat(buyer= admin)
      msg = ChatMessage(body = "TEST MESSAGE", created_by = admin.id)
      post.add_chat(chat)
      chat.add_message(msg)
      db.session.commit()

    db.session.commit()
    '''

    #Add in ucla circle
    ucla = Circle(name=u'ucla', description=u'ucla.edu emails only')
    ucla.add_member(admin)
    db.session.add(ucla)
    db.session.commit()

    ucla_info = CollegeInfo(circle_id=ucla.id,
                            domain=u'ucla.edu',
                            fb_group_id=267279833349705,
                            fb_sell_id=267375200006835)
    db.session.add(ucla_info)
    db.session.commit()