def additem(request): category = int(request.POST['category']) item_authornum = int(request.POST['item_authornum']) itemname = request.POST['itemname'] price = int(request.POST['price']) itemdate = request.POST['itemdate'] iteminfo = request.POST['iteminfo'] sells = int(request.POST['sells']) series = int(request.POST['series']) newbooknum = ItemDb().getautoincre() try: ItemDb().insert(category, item_authornum, itemname, price, itemdate, iteminfo, sells, series) context = { 'section': 'admin/admin_additems.html', 'series': series, 'newbooknum': newbooknum, } except: context = { 'section': 'admin/admin_additems.html', 'error': ErrorCode.e0011, 'newbooknum': newbooknum, } return render(request, 'admin/manage.html', context)
def mainSection(request): # catenum 2 일반 소설 # 신간 page = 1; maxItemlist = 4; searchmod = 0; searchword = ''; ordercon=2; catenum = 2; cate2_new = ItemDb().select(catenum, page, maxItemlist, searchmod, searchword, ordercon); # 베스트셀러 ordercon = 3; cate2_best = ItemDb().select(catenum, page, maxItemlist, searchmod, searchword, ordercon); # catenum 12 장르 소설 # 신간 page = 1; maxItemlist = 4; searchmod = 0; searchword = ''; ordercon=2; catenum = 12; cate12_new = ItemDb().select(catenum, page, maxItemlist, searchmod, searchword, ordercon); # 베스트셀러 ordercon = 3; cate12_best = ItemDb().select(catenum, page, maxItemlist, searchmod, searchword, ordercon); context = { 'section': 'jasmine/mainsection.html', 'cate2_new': cate2_new, 'cate2_best': cate2_best, 'cate12_new': cate12_new, 'cate12_best': cate12_best, }; return render(request, 'jasmine/home.html', context)
def pay2(request): userid = str(request.session['suser']) itemlist = [] for n in range(1, 3): data = request.POST[str(n)] itemlist.append(data) item1 = ItemDb().selectone(itemlist[0]) item2 = ItemDb().selectone(itemlist[1]) context = { 'section': 'jasmine/pay2.html', 'id': userid, 'item1': item1, 'item2': item2, } return render(request, 'jasmine/home.html', context)
def additemspage(request): newbooknum = ItemDb().getautoincre() context = { 'section': 'admin/admin_additems.html', 'newbooknum': newbooknum, } return render(request, 'admin/manage.html', context)
def itemlist(request): items = ItemDb().select() context = { 'section': 'shop2/itemlist.html', 'itemlist': items, } return render(request, 'shop2/shop2.html', context)
def itemlistall(request): ritemlist = ItemDb().selectall() context = { 'section': 'admin/itemlist.html', 'itemlist': ritemlist } return render(request, 'admin/manage.html', context)
def itemupdate(request): id = request.GET['id'] item = ItemDb().selectone(int(id)) context = { 'section': 'shop2/itemupdate.html', 'item': item, } return render(request, 'shop2/shop2.html', context)
def searchauthor(request): # max recent published list shown in each authors limit = 5 search_authorname = request.POST['search_authorname'] authorlist = AuthorDb().searchauthor(search_authorname) newbooknum = ItemDb().getautoincre() publistAll = [] for author in authorlist: publist = ItemDb().recentPublished(author.authornum, limit) publistAll.append(publist) context = { 'section': 'admin/admin_additems.html', 'authorlist': authorlist, 'publistAll': publistAll, 'newbooknum': newbooknum, } return render(request, 'admin/manage.html', context)
def itemcontent(request): itemnum = int(request.GET['itemnum']) item = ItemDb().selectone(itemnum) context = { 'section': 'jasmine/itemcontent.html', 'item': item, } return render(request, 'jasmine/home.html', context)
def itemdetail(request): id = request.GET['id'] item = ItemDb().selectone(int(id)) logger.debug(item.name + ' ' + str(item.price)) context = { 'section': 'shop2/itemdetail.html', 'item': item, } return render(request, 'shop2/shop2.html', context)
def payment(request): userid = str(request.session['suser']) itemnum = int(request.GET['itemnum']) item = ItemDb().selectone(itemnum) context = { 'section': 'jasmine/payment.html', 'item': item, 'id': userid, } return render(request, 'jasmine/home.html', context)
def paycart(request): try: itemnum = int(request.GET['itemnum']); userid = request.GET['id']; paymethod = request.GET['paymethod']; user = UserDb().selectone(userid); item = ItemDb().selectone(itemnum); # 해당 아이템 주문/결제정보 생성 OrdersDb().insert(user.usernum, itemnum, paymethod); # 총 주문기록에 새로운 내역 추가. ordernum = int(OrdersDb().selectone(user.usernum)); OrderDb().listinsert(ordernum, user.usernum, itemnum); # 사용자의 주문내역에 추가. PaymentDb().insert(ordernum, user.usernum, item.itemname, item.price); # 결제정보 추가. paylist = PaymentDb().selectone(user.usernum); # 유저의 지난 구매기록 모두 불러오기 ItemDb().sellitem(itemnum); # 아이템 판매처리, 판매수량 + 1 context = { 'section': 'jasmine/paycart.html', 'paylist': paylist, }; return render(request, 'jasmine/home.html', context); except: return redirect('payment')
def payment(request): try: userid = str(request.session['suser']); itemnum = int(request.GET['itemnum']); item = ItemDb().selectone(itemnum); context = { 'section': 'jasmine/payment.html', 'item': item, 'id': userid, }; except: return redirect('login') return render(request, 'jasmine/home.html', context);
def payimpl(request): itemnum = int(request.POST['itemnum']) userid = request.POST['id'] paymethod = request.POST['PayMethod'] user = UserDb().selectone(userid) item = ItemDb().selectone(itemnum) # 해당 아이템 주문/결제정보 생성 OrdersDb().insert(user.usernum, itemnum, paymethod) # 총 주문기록에 새로운 내역 추가. ordernum = int(OrdersDb().selectone(user.usernum)) OrderDb().listinsert(ordernum, user.usernum, itemnum) # 사용자의 주문내역에 추가. PaymentDb().insert(ordernum, user.usernum, item.itemname, item.price) # 결제정보 추가. paylist = PaymentDb().selectone(user.usernum) # 유저의 지난 구매기록 모두 불러오기 ItemDb().sellitem(itemnum) # 아이템 판매처리, 판매수량 + 1 context = { 'section': 'jasmine/payresult.html', 'paylist': paylist, } return render(request, 'jasmine/home.html', context)
def itemaddimpl(request): name = request.POST['name'] price = request.POST['price'] imgname = '' if 'img' in request.FILES: img = request.FILES['img'] imgname = img._name fp = open('%s/%s' % (UPLOAD_DIR, imgname), 'wb') for chunk in img.chunks(): fp.write(chunk) fp.close() ItemDb().insert(name, int(price), imgname) return redirect('itemlist')
def addauthor(request): authorname = request.POST['add_authorname'] authorinfo = request.POST['add_authorinfo'] newbooknum = ItemDb().getautoincre() try: AuthorDb().insert(authorname, authorinfo) context = { 'section': 'admin/admin_additems.html', 'newbooknum': newbooknum, } except: context = { 'section': 'admin/admin_additems.html', 'error': ErrorCode.e0011, 'newbooknum': newbooknum, } return render(request, 'admin/manage.html', context)
def itemupdateimpl(request): id = request.POST['id'] name = request.POST['name'] price = request.POST['price'] img = request.POST['img'] imgname = '' if 'newimg' in request.FILES: newimg = request.FLLES['newimg'] imgname = newimg._name fp = open('%s/%s' % (UPLOAD_DIR, imgname), 'wb') for chunk in newimg.chunks(): fp.write(chunk) fp.close() else: imgname = img ItemDb().update(int(id), name, int(price), imgname) qstr = urlencode({'id': id}) return HttpResponseRedirect('%s?%s' % ('itemdetail', qstr))
def itemlist(request): # max items shown in a one page maxItemlist = 20 # max pages shown maxPageview = 5 try: catenum = int(request.GET['category']) except: catenum = 1 try: page = int(request.GET['page']) except: page = 1 try: searchmod = int(request.GET['searchmod']) except: searchmod = 0 try: searchword = request.GET['searchword'] except: searchword = '' try: ordercon = int(request.GET['ordercon']) except: ordercon = 1 if catenum == 1: catename = '모든 소설' elif catenum == 2: catename = '일반 소설' elif catenum == 12: catename = '장르 소설' else: catename = '' if searchmod == 1: searchmodname = '제목과 작가' elif searchmod == 2: searchmodname = '제목' elif searchmod == 3: searchmodname = '작가' else: searchmodname = '' itemlist = ItemDb().select(catenum, page, maxItemlist, searchmod, searchword, ordercon) itemlistcount = ItemDb().listcount(catenum, searchmod, searchword) lastpage = math.ceil(itemlistcount / maxItemlist) pagerange = range(max(1, page - 2), min(page + 2, lastpage) + 1) prevpage = page - 1 nextpage = page + 1 context = { 'section': 'jasmine/itemlist.html', 'catenum': catenum, 'catename': catename, 'itemlist': itemlist, 'itemlistcount': itemlistcount, 'pageRange': pagerange, 'currentpage': page, 'prevpage': prevpage, 'nextpage': nextpage, 'lastpage': lastpage, 'searchmod': searchmod, 'searchmodname': searchmodname, 'searchword': searchword, 'ordercon': ordercon, } return render(request, 'jasmine/home.html', context)