コード例 #1
0
    def update(cls, news_id, category_id, title, content, create_uid, status):

        update = {}
        if category_id:
            update['category_id'] = category_id
        if title:
            update['title'] = title
        if content:
            update['content'] = content
        if create_uid:
            update['create_uid'] = create_uid
        if status:
            update['status'] = status

        current_time = datetime.now()
        update_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
        update['update_time'] = update_time

        try:
            db_session.query(News).filter(
                News.news_id == news_id).update(update)
            db_session.commit()
            return True
        except:
            db_session.rollback()
            raise
コード例 #2
0
ファイル: user.py プロジェクト: ListFranz/PyCMS-Tornado
    def update(self, username='', email='', realname='', about_me='', avatar_src=''):
        update = {}
        update_info = {}
        if username:
            update['username'] = username
        if email:
            update['email'] = email
        if realname:
            update['realname'] = realname

        current_time = datetime.now()
        update_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
        update['update_time'] = update_time

        if about_me:
            update_info['about_me'] = about_me
        if avatar_src:
            update_info['avatar_src'] = avatar_src

        try:
            db_session.query(User).filter(User.user_id == self.user_id).update(update)
            #if update_info['about_me'] or update_info['avatar_src']:
            #    db_session.query(UserInfo).filter(UserInfo.user_id == self.user_id).update(update_info)

            db_session.commit()
        except:
            db_session.rollback()
            raise
コード例 #3
0
ファイル: news.py プロジェクト: ListFranz/PyCMS-Tornado
    def update(cls, news_id, category_id, title, content, create_uid, status):

        update = {}
        if category_id:
            update['category_id'] = category_id
        if title:
            update['title'] = title
        if content:
            update['content'] = content
        if create_uid:
            update['create_uid'] = create_uid
        if status:
            update['status'] = status

        current_time = datetime.now()
        update_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
        update['update_time'] = update_time

        try:
            db_session.query(News).filter(News.news_id == news_id).update(update)
            db_session.commit()
            return True
        except:
            db_session.rollback()
            raise
コード例 #4
0
    def update(self,
               username='',
               email='',
               realname='',
               about_me='',
               avatar_src=''):
        update = {}
        update_info = {}
        if username:
            update['username'] = username
        if email:
            update['email'] = email
        if realname:
            update['realname'] = realname

        current_time = datetime.now()
        update_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
        update['update_time'] = update_time

        if about_me:
            update_info['about_me'] = about_me
        if avatar_src:
            update_info['avatar_src'] = avatar_src

        try:
            db_session.query(User).filter(
                User.user_id == self.user_id).update(update)
            #if update_info['about_me'] or update_info['avatar_src']:
            #    db_session.query(UserInfo).filter(UserInfo.user_id == self.user_id).update(update_info)

            db_session.commit()
        except:
            db_session.rollback()
            raise
コード例 #5
0
    def update(cls,
               user_id=0,
               username='',
               email='',
               password='',
               realname='',
               role_id=0):
        update = {}
        if username:
            update['username'] = username
        if email:
            update['email'] = email
        if password:
            update['password'] = password
        if realname:
            update['realname'] = realname
        if role_id:
            update['role_id'] = role_id

        current_time = datetime.now()
        update_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
        update['update_time'] = update_time

        try:
            db_session.query(Admin).filter(
                Admin.user_id == user_id).update(update)
            db_session.commit()
            return True
        except:
            db_session.rollback()
            raise
コード例 #6
0
 def update_email(self, email):
     current_time = datetime.now()
     update_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
     update = {User.email: email, User.update_time: update_time}
     db_session.query(User).filter(
         User.user_id == self.user_id).update(update)
     try:
         return db_session.commit()
     except:
         db_session.rollback()
コード例 #7
0
 def update_password(self, password):
     password = encrypt(password)
     current_time = datetime.now()
     update_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
     update = {Admin.password: password, Admin.update_time: update_time}
     db_session.query(Admin).filter(
         Admin.user_id == self.user_id).update(update)
     try:
         return db_session.commit()
     except:
         db_session.rollback()
コード例 #8
0
ファイル: admin.py プロジェクト: ListFranz/PyCMS-Tornado
 def update_email(self, email):
     current_time = datetime.now()
     update_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
     update = {
         Admin.email: email,
         Admin.update_time: update_time
     }
     db_session.query(Admin).filter(Admin.user_id == self.user_id).update(update)
     try:
         return db_session.commit()
     except:
         db_session.rollback()
コード例 #9
0
ファイル: setting.py プロジェクト: ListFranz/PyCMS-Tornado
    def update(cls, key, value):
        update = {}
        if key and value:
            update['value'] = value

        try:
            db_session.query(Setting).filter(Setting.key == key).update(update)
            db_session.commit()
            return True
        except:
            db_session.rollback()
            raise
コード例 #10
0
ファイル: admin.py プロジェクト: ListFranz/PyCMS-Tornado
    def new(cls, role_name, description, list_order, status):
        """
        add new role
        """
        role = AdminRole(None, role_name, description, list_order, status)

        db_session.add(role)
        try:
            db_session.commit()
            return True
        except:
            db_session.rollback()
            return None
コード例 #11
0
    def new(cls, role_name, description, list_order, status):
        """
        add new role
        """
        role = AdminRole(None, role_name, description, list_order, status)

        db_session.add(role)
        try:
            db_session.commit()
            return True
        except:
            db_session.rollback()
            return None
コード例 #12
0
ファイル: admin.py プロジェクト: ListFranz/PyCMS-Tornado
 def update_password(self, password):
     password = encrypt(password)
     current_time = datetime.now()
     update_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
     update = {
         Admin.password: password,
         Admin.update_time: update_time
     }
     db_session.query(Admin).filter(Admin.user_id == self.user_id).update(update)
     try:
         return db_session.commit()
     except:
         db_session.rollback()
コード例 #13
0
ファイル: admin.py プロジェクト: ListFranz/PyCMS-Tornado
 def update_login_info(self, last_login_ip):
     current_time = datetime.now()
     last_login_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
     update = {
         Admin.last_login_time: last_login_time,
         Admin.last_login_ip: last_login_ip,
         Admin.login_times: Admin.login_times + 1
     }
     db_session.query(Admin).filter(Admin.user_id == self.user_id).update(update)
     try:
         return db_session.commit()
     except:
         db_session.rollback()
コード例 #14
0
ファイル: news.py プロジェクト: ListFranz/PyCMS-Tornado
    def update(cls, category_id, category_name):

        update = {}
        if category_name:
            update['category_name'] = category_name

        try:
            db_session.query(NewsCategory).filter(NewsCategory.category_id == category_id).update(update)
            db_session.commit()
            return True
        except:
            db_session.rollback()
            raise
コード例 #15
0
    def update(cls, category_id, category_name):

        update = {}
        if category_name:
            update['category_name'] = category_name

        try:
            db_session.query(NewsCategory).filter(
                NewsCategory.category_id == category_id).update(update)
            db_session.commit()
            return True
        except:
            db_session.rollback()
            raise
コード例 #16
0
 def update_login_info(self, last_login_ip):
     current_time = datetime.now()
     last_login_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
     update = {
         Admin.last_login_time: last_login_time,
         Admin.last_login_ip: last_login_ip,
         Admin.login_times: Admin.login_times + 1
     }
     db_session.query(Admin).filter(
         Admin.user_id == self.user_id).update(update)
     try:
         return db_session.commit()
     except:
         db_session.rollback()
コード例 #17
0
ファイル: user.py プロジェクト: ListFranz/PyCMS-Tornado
 def update_login_info(self, last_login_ip):
     current_time = datetime.now()
     last_login_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
     update = {
         User.last_login_time: last_login_time,
         User.last_login_ip: last_login_ip,
         User.login_times: User.login_times + 1
     }
     db_session.query(User).filter(User.user_id == self.user_id).update(update)
     try:
         db_session.commit()
         return True
     except:
         db_session.rollback()
コード例 #18
0
ファイル: news.py プロジェクト: ListFranz/PyCMS-Tornado
    def new(cls, category_name):
        """
        add new news
        """
        newsCategory = NewsCategory(None, category_name)

        db_session.add(newsCategory)
        try:
            db_session.commit()
        except:
            db_session.rollback()

        if newsCategory.category_id:
            return cls.get(newsCategory.category_id)
        return None
コード例 #19
0
    def new(cls, category_name):
        """
        add new news
        """
        newsCategory = NewsCategory(None, category_name)

        db_session.add(newsCategory)
        try:
            db_session.commit()
        except:
            db_session.rollback()

        if newsCategory.category_id:
            return cls.get(newsCategory.category_id)
        return None
コード例 #20
0
 def update_login_info(self, last_login_ip):
     current_time = datetime.now()
     last_login_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
     update = {
         User.last_login_time: last_login_time,
         User.last_login_ip: last_login_ip,
         User.login_times: User.login_times + 1
     }
     db_session.query(User).filter(
         User.user_id == self.user_id).update(update)
     try:
         db_session.commit()
         return True
     except:
         db_session.rollback()
コード例 #21
0
    def new(cls, username, email, password, reg_ip):
        """
        add new user
        """
        user = User(None, username, email)
        user.password = encrypt(password) if password else ''
        user.reg_ip = reg_ip
        db_session.add(user)
        #只有提交事务了,才可以获取(user.user_id)数据的ID值
        try:
            db_session.commit()
        except:
            db_session.rollback()
        db_session.close()

        if user.user_id:
            return cls.get(user.user_id)
        return None
コード例 #22
0
ファイル: news.py プロジェクト: ListFranz/PyCMS-Tornado
    def new(cls, category_id, title, content, create_uid, status):
        """
        add new news
        """
        news = News(None, category_id, title, content, create_uid, status)

        #TODO optimize
        news.update_time = '0000-00-00 00:00:00'

        db_session.add(news)
        try:
            db_session.commit()
        except:
            db_session.rollback()

        if news.news_id:
            return cls.get(news.news_id)
        return None
コード例 #23
0
    def new(cls, category_id, title, content, create_uid, status):
        """
        add new news
        """
        news = News(None, category_id, title, content, create_uid, status)

        #TODO optimize
        news.update_time = '0000-00-00 00:00:00'

        db_session.add(news)
        try:
            db_session.commit()
        except:
            db_session.rollback()

        if news.news_id:
            return cls.get(news.news_id)
        return None
コード例 #24
0
ファイル: admin.py プロジェクト: ListFranz/PyCMS-Tornado
    def update(cls, role_id, role_name, description, list_order, status):
        update = {}
        if role_name:
            update['role_name'] = role_name
        if description:
            update['description'] = description
        if list_order:
            update['list_order'] = list_order
        if status:
            update['status'] = status

        try:
            db_session.query(AdminRole).filter(AdminRole.role_id == role_id).update(update)
            db_session.commit()
            return True
        except:
            db_session.rollback()
            raise
コード例 #25
0
ファイル: user.py プロジェクト: ListFranz/PyCMS-Tornado
    def new(cls, username, email, password, reg_ip):
        """
        add new user
        """
        user = User(None, username, email)
        user.password = encrypt(password) if password else ''
        user.reg_ip = reg_ip
        db_session.add(user)
        #只有提交事务了,才可以获取(user.user_id)数据的ID值
        try:
            db_session.commit()
        except:
            db_session.rollback()
        db_session.close()

        if user.user_id:
            return cls.get(user.user_id)
        return None
コード例 #26
0
    def update(cls, role_id, role_name, description, list_order, status):
        update = {}
        if role_name:
            update['role_name'] = role_name
        if description:
            update['description'] = description
        if list_order:
            update['list_order'] = list_order
        if status:
            update['status'] = status

        try:
            db_session.query(AdminRole).filter(
                AdminRole.role_id == role_id).update(update)
            db_session.commit()
            return True
        except:
            db_session.rollback()
            raise
コード例 #27
0
ファイル: admin.py プロジェクト: ListFranz/PyCMS-Tornado
    def new(cls, username, email, password, realname, role_id):
        """
        add new user
        """
        user = Admin(None, username, email, realname, role_id)
        user.password = encrypt(password) if password else ''
        user.status = 1
        #TODO optimize
        user.last_login_time = '0000-00-00 00:00:00'
        user.last_login_ip = ''
        user.login_times = 0
        user.update_time = '0000-00-00 00:00:00'

        db_session.add(user)
        #只有提交事务了,才可以获取(user.user_id)数据的ID值
        try:
            db_session.commit()
        except:
            db_session.rollback()

        if user.user_id:
            return cls.get(user.user_id)
        return None
コード例 #28
0
    def new(cls, username, email, password, realname, role_id):
        """
        add new user
        """
        user = Admin(None, username, email, realname, role_id)
        user.password = encrypt(password) if password else ''
        user.status = 1
        #TODO optimize
        user.last_login_time = '0000-00-00 00:00:00'
        user.last_login_ip = ''
        user.login_times = 0
        user.update_time = '0000-00-00 00:00:00'

        db_session.add(user)
        #只有提交事务了,才可以获取(user.user_id)数据的ID值
        try:
            db_session.commit()
        except:
            db_session.rollback()

        if user.user_id:
            return cls.get(user.user_id)
        return None
コード例 #29
0
ファイル: admin.py プロジェクト: ListFranz/PyCMS-Tornado
    def update(cls, user_id=0, username='', email='', password='', realname='', role_id=0):
        update = {}
        if username:
            update['username'] = username
        if email:
            update['email'] = email
        if password:
            update['password'] = password
        if realname:
            update['realname'] = realname
        if role_id:
            update['role_id'] = role_id

        current_time = datetime.now()
        update_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
        update['update_time'] = update_time

        try:
            db_session.query(Admin).filter(Admin.user_id == user_id).update(update)
            db_session.commit()
            return True
        except:
            db_session.rollback()
            raise