Exemplo n.º 1
0
def del_blog_lib(self, id):
    if Blog.by_id(id):
        blog = Blog.by_id(id)
        dbSession.delete(blog)
        dbSession.commit()
        return {'status': True, 'msg': 'it is ok'}
    return {'status': False, 'msg': 'nobody'}
Exemplo n.º 2
0
def del_comment_lib(self, id):
    if id is None:
        return {'status': False, 'msg': '评论不存在'}
    comment = Comment.by_id(id)
    dbSession.delete(comment)
    dbSession.commit()
    return {'status': True, 'msg': 'ok'}
Exemplo n.º 3
0
def del_contact_lib(self, id):
    if id:
        contact = Contact.by_id(id)
        dbSession.delete(contact)
        dbSession.commit()
        return {'status': True, 'msg': 'OK'}
    return {'status': False, 'msg': 'error'}
Exemplo n.º 4
0
def del_user_lib(self,id):
    if User.by_id(id) is None:
        return {'status':False,'msg':'error'}
    user = User.by_id(id)
    dbSession.delete(user)
    dbSession.commit()
    return {'status':True, 'msg': '删除成功'}
Exemplo n.º 5
0
 def get(self):
     for i in range(2, 200):
         add_data = pt_bs_msg(
             bednum=str(i),
             name=str(i),
             gender=str(i),
             age=i,
             contact=str(i),
             doctor=str(i),
             IDcard=str(i),
             ill=str(i),
         )
         dbSession.add(add_data)
         dbSession.commit()
Exemplo n.º 6
0
def create_h():
    dbSession.add_all([
        Hous_area(area_id=1, area_name='天河区', area_ctime=datetime.now()),
        Hous_area(area_id=2, area_name='荔湾区', area_ctime=datetime.now()),
        Hous_area(area_id=3, area_name='海珠区', area_ctime=datetime.now()),
        Hous_area(area_id=4, area_name='越秀区', area_ctime=datetime.now()),
        Hous_area(area_id=5, area_name='白云区', area_ctime=datetime.now()),
        Hous_area(area_id=6, area_name='黄埔区', area_ctime=datetime.now()),
        Hous_area(area_id=7, area_name='番禺区', area_ctime=datetime.now()),
        Hous_area(area_id=8, area_name='花都区', area_ctime=datetime.now()),
        Hous_area(area_id=9, area_name='南沙区', area_ctime=datetime.now()),
        Hous_area(area_id=10, area_name='增城区', area_ctime=datetime.now()),
        Hous_area(area_id=11, area_name='从化区', area_ctime=datetime.now()),
    ])
    dbSession.commit()
Exemplo n.º 7
0
def create_h():
    dbSession.add_all([
        Hous_area(area_id=1, area_name='越秀区', area_ctime=datetime.now()),
        Hous_area(area_id=2, area_name='荔湾区', area_ctime=datetime.now()),
        Hous_area(area_id=3, area_name='海珠区', area_ctime=datetime.now()),
        Hous_area(area_id=4, area_name='天河区', area_ctime=datetime.now()),
        Hous_area(area_id=5, area_name='白云区', area_ctime=datetime.now()),
        Hous_area(area_id=6, area_name='黄埔区', area_ctime=datetime.now()),
        Hous_area(area_id=7, area_name='番禺区', area_ctime=datetime.now()),
        Hous_area(area_id=8, area_name='花都区', area_ctime=datetime.now()),
        Hous_area(area_id=9, area_name='南沙区', area_ctime=datetime.now()),
        Hous_area(area_id=10, area_name='增城区', area_ctime=datetime.now()),
        Hous_area(area_id=11, area_name='从化区', area_ctime=datetime.now()),
    ])

    dbSession.add_all([
        Facility(id=1, name='无线网络', cretetime=datetime.now()),
        Facility(id=2, name='热水淋浴', cretetime=datetime.now()),
        Facility(id=3, name='空调', cretetime=datetime.now()),
        Facility(id=4, name='暖气', cretetime=datetime.now()),
        Facility(id=5, name='允许吸烟', cretetime=datetime.now()),
        Facility(id=6, name='饮水设备', cretetime=datetime.now()),
        Facility(id=7, name='牙具', cretetime=datetime.now()),
        Facility(id=8, name='香皂', cretetime=datetime.now()),
        Facility(id=9, name='拖鞋', cretetime=datetime.now()),
        Facility(id=10, name='手纸', cretetime=datetime.now()),
        Facility(id=11, name='毛巾', cretetime=datetime.now()),
        Facility(id=12, name='沐浴露、洗发露', cretetime=datetime.now()),
        Facility(id=13, name='冰箱', cretetime=datetime.now()),
        Facility(id=14, name='洗衣机', cretetime=datetime.now()),
        Facility(id=15, name='电梯', cretetime=datetime.now()),
        Facility(id=16, name='允许做饭', cretetime=datetime.now()),
        Facility(id=17, name='允许带宠物', cretetime=datetime.now()),
        Facility(id=18, name='允许聚会', cretetime=datetime.now()),
        Facility(id=19, name='门禁系统', cretetime=datetime.now()),
        Facility(id=20, name='停车位', cretetime=datetime.now()),
        Facility(id=21, name='有线网络', cretetime=datetime.now()),
        Facility(id=22, name='电视', cretetime=datetime.now()),
        Facility(id=23, name='浴缸', cretetime=datetime.now())
    ])
    dbSession.commit()
Exemplo n.º 8
0
from config import settings
from handlers.main.main_urls import handlers
from models.account.account_user_model import User
from models.files.upload_file_model import Files
from models.article import article_model
from libs.db import create_talbes
from libs.db.dbsession import dbSession
#定义一个默认的端口
define("port", default=8000, help="run port ", type=int)
define("runserver", default=False, help="start server", type=bool)
define("t", default=False, help="create table", type=bool)
define("u", default=False, help="create user", type=bool)

if __name__ == "__main__":
    options.parse_command_line()
    if options.t:
        create_talbes.run()
    if options.u:
        user = User()
        user.name = 'zhangsan'
        user.password = '******'
        dbSession.add(user)
        dbSession.commit()

    if options.runserver:
        app = tornado.web.Application(handlers, **settings)  #创建应用实例
        http_server = tornado.httpserver.HTTPServer(app)  #通过应用实例创建服务器实例
        http_server.listen(options.port)  #监听9000端口
        print 'start server...'
        tornado.ioloop.IOLoop.instance().start()  #启动服务器
Exemplo n.º 9
0
define("port", default=8000, help="run port ", type=int)  # 定义端口号
define("runserver", default=False, help="start server", type=bool)  # 启动服务
define("t", default=False, help="create table", type=bool)  # 创建表
define("u", default=False, help="create user", type=bool)  # 创建用户

if __name__ == "__main__":
    # option(所有已定义的选项都可以作为该对象的属性可用).解析在命令行上给出的所有选项
    # 即在命令行输入命令时进行解析
    options.parse_command_line()

    # 当是属性.t时,执行创建表函数
    if options.t:
        create_talbes.run()  # 调用创建数据库的映射函数生成数据库中的表

    # 当是属性.u时,就是创建用户命令
    # 定义如果执行-u时,为创建一个用户
    if options.u:
        user = User()  # 类的实例化
        user.name = 'achjiang'  # 属性的实例化
        user.password = '******'  # 属性的实例化
        dbSession.add(user)  # 在session中添加一个数据
        dbSession.commit()  # 将添加的数据提交到数据库执行

    # 当是属性.runserver时,执行如下函数:
    if options.runserver:
        app = tornado.web.Application(handlers, **settings)  #创建应用实例
        http_server = tornado.httpserver.HTTPServer(app)  #通过应用实例创建服务器实例
        http_server.listen(options.port)  #监听8000端口
        print 'start server...'
        tornado.ioloop.IOLoop.instance().start()  #启动服务器
Exemplo n.º 10
0
def create_super_admin():
    emp = Employee()
    emp.username = "******"
    emp.password = '******'
    dbSession.add(emp)
    dbSession.commit()
Exemplo n.º 11
0
def del_article_lib(self, id):
    article = Article.by_id(id)
    dbSession.delete(article)
    dbSession.commit()
    return {'status': True, 'msg': 'delete ok'}
Exemplo n.º 12
0
def init_data():
    """往permission_role表中添加admin这个角色"""
    role = permission_model.Role()
    role.name = 'admin'
    dbSession.add(role)
    dbSession.commit()

    """添加权限"""
    for i in range(13):
        pa = permission_model.Permission()
        pa.name = pp[i][0]
        pa.strcode = pp[i][1]
        dbSession.add(pa)
    dbSession.commit()

    """添加管理员用户"""
    u = [
        ('admin', '111111'),
    ]
    for i in xrange(1):
        user = User()
        user.name = u[i][0]
        user.password = u[i][1]
        dbSession.add(user)
    dbSession.commit()

    """为处理器添加权限"""
    for i in xrange(11):
        user = permission_model.Handler()
        user.name = h[i][0]
        user.p_id = h[i][1]
        dbSession.add(user)
    dbSession.commit()
    p = dbSession.query(permission_model.Permission).all()
    r = dbSession.query(permission_model.Role).filter_by(name='admin').first()
    for i in p:
        r.permissions.append(i)
    dbSession.add(r)
    dbSession.commit()

    """给admin用户赋予角色"""
    u_r = ["1", "1"]
    user_to_role = permission_model.UserToRole()
    user_to_role.u_id = u_r[0]
    user_to_role.r_id = u_r[1]
    dbSession.add(user_to_role)
    dbSession.commit()

    """给admin添加权限管理菜单显示"""
    p_r = ["adminmenu", "7"]
    menu = permission_model.Menu()
    menu.name = p_r[0]
    menu.p_id = p_r[1]
    dbSession.add(menu)
    dbSession.commit()