示例#1
0
def adduser(**kwargs):
    name = kwargs['name']
    pwd = kwargs['pwd']

    user = User(name=name, pwd=pwd)
    user.people = People(name=name)

    session = getsession()
    session.add(user)
    session.commit()
    session.close()
示例#2
0
def getuser(**kwargs):
    name = kwargs.get('name')
    pwd = kwargs.get('pwd')
    all = kwargs.get('all')
    session = getsession()
    query = session.query(User)
    conditioned = False

    if (all):
        return query.all()

    if (name != None and pwd != None):
        query = query.filter(and_(User.name == name, User.pwd == pwd))
        conditioned = True

    if (conditioned):
        return query.all()
    else:
        return []
示例#3
0
def checkmeeting(meeting):
    session = getsession()
    if (time2timestamp(paramdecode(meeting.begin_time)) > time2timestamp(
            paramdecode(meeting.end_time))):
        return genret(1, msg='begin_time > end_time')

    meetings = session.query(Meeting).filter(
        Meeting.room_id == meeting.room_id, ).filter(
            or_(
                and_(Meeting.begin_time <= meeting.begin_time,
                     Meeting.end_time > meeting.begin_time),
                and_(Meeting.begin_time < meeting.end_time,
                     Meeting.end_time > meeting.end_time),
                and_(Meeting.begin_time >= meeting.begin_time,
                     Meeting.end_time < meeting.end_time),
            )).all()

    if len(meetings) > 0:
        return genret(2, msg='meeting\' s checking not pass')
    else:
        return genret(0)
示例#4
0
def addroom(room):
    session = getsession()
    session.add(room)
    session.commit()
示例#5
0
def getmeetings():
    session = getsession()
    data = session.query(Meeting).all()
    return genret(0, data=data)
示例#6
0
def addmeeting(meeting):
    session = getsession()
    session.add(meeting)
    session.commit()
示例#7
0
def getroom():
    session = getsession()
    return session.query(Room).all()
示例#8
0
def upduser(user):
    session = getsession()
    session.query(User).filter(User.id == user.id).update(
        {'logintime': user.logintime}, synchronize_session=False)
    session.commit()
    session.close()