Exemplo n.º 1
0
def _goods_itemgroup_(_id):
    store_id = c.session['store']

    if c.is_json():
        if c.is_GET():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                only = c.simple_query(ss, orm.상품_분류, no=_id)
                return c.jsonify(c.for_json(only))
        elif c.is_POST():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                only = c.newitem_web(orm.상품_분류, c.session)
                cnt = itemgroup_query(ss, store_id).count()
                only.번호 = cnt + 1
                for k, v in c.data_POST().items():
                    if hasattr(only, k) and k != 'no':
                        if getattr(only, k) != v:
                            setattr(only, k, v)
                ss.add(only)
                return 'added'
        elif c.is_PUT():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                only = c.simple_query(ss, orm.상품_분류, no=_id)
                if only.s == c.session['store']:
                    for k, v in c.data_POST().items():
                        if hasattr(only, k) and k != 'no':
                            if getattr(only, k) != v:
                                print(k, 'is changed')
                                setattr(only, k, v)
                    only.issync = None
                    return 'modified'
                else:
                    c.abort(403)
        elif c.is_DELETE():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                only = c.simple_query(ss, orm.상품_분류, no=_id)
                if only.s == c.session['store']:
                    only.isdel = c.O
                    l = itemgroup_query(ss, store_id).all()
                    for i in range(len(l)):
                        l[i].번호 = i + 1
                    only.issync = None
                    return 'deleted'
                else:
                    c.abort(403)
    c.abort(404)
Exemplo n.º 2
0
def _system_menugroup_(_id):
    sid = c.session['store']

    if c.is_json():
        if c.is_GET():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                r = c.simple_query(ss, orm.설정_메뉴그룹, id=_id)
                return c.jsonify(c.for_json(r))
        elif c.is_POST():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                r = c.newitem_web(orm.설정_메뉴그룹, c.session)
                cnt = menugroup_query(ss, sid).count()
                r.번호 = cnt + 1
                for k, v in c.data_POST().items():
                    if hasattr(r, k) and k != 'id':
                        if getattr(r, k) != v:
                            setattr(r, k, v)
                ss.add(r)
                return 'added'
        elif c.is_PUT():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                r = c.simple_query(ss, orm.설정_메뉴그룹, id=_id)
                if r.sid == c.session['store']:
                    for k, v in c.data_POST().items():
                        if hasattr(r, k) and k != 'id':
                            if getattr(r, k) != v:
                                print(k, 'is changed')
                                setattr(r, k, v)
                    r.issync = None
                    return 'modified'
                else:
                    c.abort(403)
        elif c.is_DELETE():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                r = c.simple_query(ss, orm.설정_메뉴그룹, id=_id)
                if r.sid == c.session['store']:
                    r.isdel = c.O
                    l = menugroup_query(ss, sid).all()
                    for i in range(len(l)):
                        l[i].번호 = i + 1
                    r.issync = None
                    return 'deleted'
                else:
                    c.abort(403)
    c.abort(404)
Exemplo n.º 3
0
def _goods_item_upload_(_id):
    store_id = c.session['store']
    gd = c.dict_itemgroup(orm, store_id)
    if c.is_json():
        if c.is_GET():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                only = c.simple_query(ss, orm.상품_품목, no=_id)
                only.분류 = gd[only.분류no]
                return c.jsonify(c.for_json(only))
        elif c.is_POST():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                only = c.newitem_web(orm.상품_품목, c.session)
                for k, v in c.data_POST().items():
                    if hasattr(only, k) and k != 'no':
                        if getattr(only, k) != v:
                            setattr(only, k, v)
                only.분류no = c.fs2i(c.data_POST()['분류'].split('|',
                                                             1)[0].strip())
                ss.add(only)
                return 'added'
        elif c.is_PUT():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                only = c.simple_query(ss, orm.상품_품목, no=_id)
                if only.s == c.session['store']:
                    for k, v in c.data_POST().items():
                        if hasattr(only, k) and k != 'no':
                            if getattr(only, k) != v:
                                print(k, 'is changed')
                                setattr(only, k, v)
                    only.분류no = c.fs2i(c.data_POST()['분류'].split('|',
                                                                 1)[0].strip())
                    only.issync = None
                    return 'modified'
                else:
                    c.abort(403)
        elif c.is_DELETE():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                only = c.simple_query(ss, orm.상품_품목, no=_id)
                if only.s == c.session['store']:
                    only.isdel = c.O
                    only.issync = None
                    return 'deleted'
                else:
                    c.abort(403)
    c.abort(404)
Exemplo n.º 4
0
def _board_board_(_id):
    store_id = c.session['store']
    if c.is_GET():
        if True:  # c.is_json()
            l = []
            with orm.session_scope() as ss:  # type:c.typeof_Session
                q1 = ss.query(orm.상품_품목) \
                    .filter_by(s=store_id) \
                    .filter_by(isdel='X') \
                    .all()
                for x in q1:
                    dummy = x.__dict__.copy()
                    del dummy['_sa_instance_state']
                    for k, v in dummy.items():
                        if v is None:
                            dummy[k] = ''
                        elif isinstance(v, date):
                            dummy[k] = v.isoformat()
                        elif isinstance(v, datetime):
                            dummy[k] = v.isoformat(' ')
                    l.append(dummy)
            return c.jsonify(l)
    elif c.is_POST():
        with orm.session_scope() as ss:  # type:c.typeof_Session


            if c.data_POST()['i'] == '신규':

                only = c.newitem_web(orm.상품_품목, c.session)
                for k, v in c.data_POST().items():
                    if hasattr(only, k) and k != 'i':
                        if getattr(only, k) != v:
                            setattr(only, k, v)

                ss.add(only)
                return 'modified'

            elif c.data_POST()['i'] != '신규':
                only = c.simple_query(ss, orm.상품_품목, s=c.session['store'])

                for x in only:

                    if int(x.i) == int(c.data_POST()['i']):
                        for k, v in c.data_POST().items():
                            if hasattr(x, k) and k != 'i':
                                if getattr(x, k) != v:
                                    print(k, 'is changed')
                                    setattr(x, k, v)
                        x.issync = None
                        return 'modified'


            return 'modified'
Exemplo n.º 5
0
def _goods_itemgroup_(_id):
    store_id = c.session['store']
    if c.is_GET():
        if True:  # c.is_json()
            l = []
            with orm.session_scope() as ss:  # type:c.typeof_Session
                q1 = ss.query(orm.상품_분류) \
                    .filter_by(s=c.session['store']) \
                    .filter_by(isdel='X') \
                    .all()
                for x in q1:
                    dummy = x.__dict__.copy()
                    del dummy['_sa_instance_state']
                    for k, v in dummy.items():
                        if v is None:
                            dummy[k] = ''
                        elif isinstance(v, date):
                            dummy[k] = v.isoformat()
                        elif isinstance(v, datetime):
                            dummy[k] = v.isoformat(' ')
                    l.append(dummy)
            return c.jsonify(l)
    elif c.is_PUT():
        with orm.session_scope() as ss:  # type:c.typeof_Session

            temp = []
            for i in c.data_POST():
                for j in c.json.loads(i):
                    temp.append(j)

            only = c.simple_query(ss, orm.상품_분류, s=c.session['store'])
            for i in temp:
                if '코드' not in i:
                    only1 = c.newitem_web(orm.상품_분류, c.session)
                    only1.분류명 = i['대분류']
                    ss.add(only1)

                elif i['코드'] != None:

                    for x in only:
                        if x.i == i['코드']:
                            x.분류명 = i['대분류']
                            x.isdel = i['isdel']

            return 'modified'
Exemplo n.º 6
0
def _goods_item_modify():
    store_id = c.session['store']
    with orm.session_scope() as ss:  # type:c.typeof_Session
        gd = c.dict_itemgroup(orm, store_id)
        gl = list(gd.values())
        form_types[0]['l'] = gl
        # print(gd, gl)
        if c.is_GET():
            if c.is_json():
                l = c.for_json_l(
                    c.simple_query(ss, orm.상품_품목, s=store_id, order_by_asc='no'))
                for i in l:
                    i['분류'] = gd[i['분류no']]
                    i['idx'] = i['no']
                    i['enabled'] = True
                return c.jsonify(l)
            return c.display(item=c.newitem_web(orm.상품_품목, c.session),
                             thead=thead,
                             form_types=form_types,
                             no=store_id,
                             gl=gl)
Exemplo n.º 7
0
def _system_menugroup_movedown(_id):
    sid = c.session['store']

    if c.is_json():
        if c.is_PUT():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                r = c.simple_query(ss, orm.설정_메뉴그룹, id=_id).번호
                l = menugroup_query(ss, sid).all()
                if sid == c.session['store']:
                    if r >= len(l):
                        return 'modified'
                    else:
                        for i in l:
                            if i.번호 == r:
                                i.번호 += 1
                            elif i.번호 == r + 1:
                                i.번호 -= 1
                    return 'modified'
                else:
                    c.abort(403)

    c.abort(404)
Exemplo n.º 8
0
def _system_tablegroup_moveup(_id):
    sid = c.session['store']

    if c.is_json():
        if c.is_PUT():
            with orm.session_scope() as ss:  # type:c.typeof_Session
                r = c.simple_query(ss, orm.설정_테이블그룹, id=_id).번호
                l = tablegroup_query(ss, sid).all()
                if sid == c.session['store']:
                    if r <= 1:
                        return 'modified'
                    else:
                        for i in l:
                            if i.번호 == r - 1:
                                i.번호 += 1
                            elif i.번호 == r:
                                i.번호 -= 1
                    return 'modified'
                else:
                    c.abort(403)

    c.abort(404)
Exemplo n.º 9
0
def _goods_item_(_id):
    store_id = c.session['store']
    if c.is_GET():
        if True:  # c.is_json()
            l = []
            with orm.session_scope() as ss:  # type:c.typeof_Session
                q1 = ss.query(orm.상품_품목) \
                    .filter_by(s=store_id) \
                    .filter_by(isdel='X') \
                    .all()
                for x in q1:
                    dummy = x.__dict__.copy()
                    del dummy['_sa_instance_state']
                    for k, v in dummy.items():
                        if v is None:
                            dummy[k] = ''
                        elif isinstance(v, date):
                            dummy[k] = v.isoformat()
                        elif isinstance(v, datetime):
                            dummy[k] = v.isoformat(' ')
                    l.append(dummy)
            return c.jsonify(l)
    elif c.is_POST():
        with orm.session_scope() as ss:  # type:c.typeof_Session

            if c.data_POST()['i'] == '신규':

                only = c.newitem_web(orm.상품_품목, c.session)
                for k, v in c.data_POST().items():
                    if hasattr(only, k) and k != 'i':

                        if getattr(only, k) != v:
                            if k == '프린터j':
                                _lst = []
                                if v != '':
                                    for ch in v.split(','):
                                        _lst.append(int(ch.strip()))
                                v = _lst
                            setattr(only, k, v)

                ss.add(only)
                return 'modified'

            elif c.data_POST()['i'] != '신규':
                only = c.simple_query(ss, orm.상품_품목, s=c.session['store'])

                for x in only:

                    if int(x.i) == int(c.data_POST()['i']):
                        for k, v in c.data_POST().items():
                            if hasattr(x, k) and k != 'i':
                                if getattr(x, k) != v:
                                    if k == '프린터j':
                                        _lst = []
                                        if v != '':
                                            for ch in v.split(','):
                                                _lst.append(int(ch.strip()))
                                        v = _lst
                                    print(k, 'is changed')
                                    setattr(x, k, v)
                        x.issync = None
                        return 'modified'

            temp = []
            # for i in c.data_POST():
            #     for j in c.json.loads(i):
            #         temp.append(j)

            # print(temp)

            # only = c.simple_query(ss, orm.상품_품목, s=c.session['store'])
            # for i in temp:
            #     if '코드' not in i:
            #         only1 = c.newitem_web(orm.상품_품목, c.session)
            #         only1.품목명 = i['명']
            #         ss.add(only1)
            #
            #     elif i['코드'] != None:
            #
            #         for x in only:
            #             if x.i == i['코드']:
            #                 x.품목명 = i['명']
            #                 x.isdel = i['isdel']

            return 'modified'