Example #1
0
    def __init__(self):
        db.connect()
        self.version = None
        self.admin = None
        self.sys_category = None
        self.default_thumbnail = None
        self.sys_image = None

        if not Version.table_exists():
            tables = [
                Version,
                Categories,
                Products,
                News,
                Notifications,
                Images,
                Orders,
                OrderDetails,
                Users,   
                Contacts,
                Accountings,
                AccountIncommings,
                AccountOutgoings,
                Questions,
                Answers,
                Albums
            ]
        
            db.create_tables(tables)

            self.version=Version.create(description=open('VERSION').read())
            self.default_thumbnail = base64.b64encode(buffer(imaging.default_thumbnail()))
  
 
            self.sys_category = Categories.create(
                            name = '系统预置分类',
                            description = '预置的初始父类!',
                         )

            self.sys_image = Images.create(
                            description = '预置的系统图片!',
                            thumbnail = self.default_thumbnail,
                            uuid = 'default'
                         )

            self.admin = Users.create(
                            name = 'admin',
                            cellphone = '13912345678',
                            email = '*****@*****.**',
                            password = '******',
                            gender = 0,
                            avatur = self.sys_image,
                            description = '系统管理员',
                            weixin= '0',
                            address= 'sv',
                         )
Example #2
0
    def __init__(self):
        db.connect()

        tables = [
            Albums,
            ArticleComments,
            Articles,
            Categories,
            Images,
            Users,
            Version,
        ]

        if not Version.table_exists():
            db.create_tables(tables)

        self.version, _ = Version.get_or_create(description="0.1")
        self.default_thumbnail = "data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAAAAAAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCADIAMgDASIAAhEBAxEB/8QAHAAAAQUBAQEAAAAAAAAAAAAAAAMEBQYHAQII/8QARBAAAgEDAQUECAQDBQYHAAAAAQIDAAQRBQYSITFBE1FhcRQigZGhscHRMkJS4SMz8BVDU2JyBySDorLSVWNzgpKj8f/EABsBAAIDAQEBAAAAA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S3LyLlDHd9qoysgCuB0I5H6e6l6KKGIjd/8AeH7MfylPrn9Xh9/dTTXdXj0jT2lJBmcFYk72+wp1f3sWnWUl1MSEQdOZPQe+su1XU59VvWuZzjoiDki9wrcY5GNPQ7ZfgZuzOxZmLMxySepNeaKKKdxLCwgory7bu74nFdJwMmrLO1wHebnwHxrjHOFHM/AV0ADAHKoV3waLsBqJltJ7B2yYTvx5/SeY9/zq5VlOxt36LtJbDOFmzE3tHD4gVrGKNB5R8N6xQqtQ2unyeeNFesUYreTlYOKzLyNe1lPWvO7Xd2pktZFA60V5C0VNzN8mBkZFIFkkPZTKCRyPfRRSx6UxtcWzRJvBiYhxx1Fe4ZUtrQOcktxwKKKgF8PgVti8pMz9eCjupzRRUDR6OitV0BOz0CwXvhVveM/Wiih2dHP9Q6iSVGaKKEcsjdobcXWg3keOPZ7yjxXiPlWVGiiiw6On6f1I5RRRWzpCN0cQ57iD8a5PJho17zk+QooqzD8iqAjJPM869UUVDS6HemzdhqVrMDjs5kb3MDW3iiiiV9Hy3r6XuQ/pnQK7u0UUQ+fR3dru7RRUIegKKKKho//Z"
        # self.default_thumbnail = base64.b64encode(
        #     buffer(Imaging.default_thumbnail()))

        self.sys_categories, _ = Categories.get_or_create(
            name='系统分类',
            description='初始父类!',
            thumbnail=self.default_thumbnail,
        )
        self.article_categories = Categories.create(
            name='文章',
            description='文章',
            thumbnail=self.default_thumbnail,
            parent=self.sys_categories)

        self.admin, _ = Users.get_or_create(
            name='admin',
            cellphone='19999999999',
            email='*****@*****.**',
            address='陕西西安',
            birthday='2020.9',
            password='******',
            gender=0,
            description='系统管理员!',
            avatar=self.default_thumbnail)

        self.sys_album, _ = Albums.get_or_create(
            name='系统专辑',
            description='系统专辑!',
            thumbnail=self.default_thumbnail,
            owner=self.admin)

        self.sys_image, _ = Images.get_or_create(
            description='系统图片!',
            thumbnail=self.default_thumbnail,
            owner=self.admin,
            album=self.sys_album,
            uuid='default')
Example #3
0
    def __init__(self):
        db.connect()
        if not Version.table_exists():
           
            tablesName = [
                Version,
                Albums,
                Chatrooms,
                Categories,
                ProductComments,
                ProductFavorites, 
                ProductRankings,
                ProductPayments,
                Products,
                GroupComments,
                GroupFavorites, 
                GroupRankings,
                GroupPayments,
                Groups,
                Images,
                Roles,
                Transactions,
                Users,   
                Articles,
                Answners,
                Questions, 
            ]
        
            for i in tablesName:
                i.create_table()


        self.version=Version.get_or_create(description=open('VERSION').read())
        self.admin_role = Roles.get_or_create(type=1,  description='系统管理员')
        self.assistant_role = Roles.get_or_create(type=10, description='班级管理员')
        self.student_role = Roles.get_or_create(type=100,  description='注册学员')
        self.default_thumbnail = base64.b64encode(buffer(imaging.default_thumbnail()))
  
 
        self.sys_categories = Categories.get_or_create(
                            name = '系统预置分类',
                            description = '预置的初始父类!',
                            thumbnail = self.default_thumbnail,
                         )


        self.admin = Users.get_or_create(
                            name = 'admin',
                            cellphone = '13912345678',
                            email = '*****@*****.**',
                            password = '******',
                            gender = 0,
                            role = self.admin_role,
                            description = '预置的系统管理员!',
                            avatur = self.default_thumbnail
                     )

        self.sys_album = Albums.get_or_create(
                            name = '系统专辑',
                            description = '预置的系统专辑!',
                            thumbnail = self.default_thumbnail,
                            owner = self.admin
                         )

        self.sys_image = Images.get_or_create(
                            description = '预置的系统图片!',
                            thumbnail = self.default_thumbnail,
                            owner = self.admin,
                            album = self.sys_album,
                            uuid = 'default'
                         )
Example #4
0
File: base.py Project: XinMa1/work
 def isInstalled(self):
     try:
         from models.version import Version
         return True if Version.table_exists() else False
     except Exception, e:
         return False
Example #5
0
 def is_installed(self):
     try:
         from models.version import Version
         return True if Version.table_exists() else False
     except Exception as e:
         return False